All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.code.yanf4j.util.SimpleQueue Maven / Gradle / Ivy

package com.google.code.yanf4j.util;

import java.util.Iterator;
import java.util.LinkedList;

/**
 * Simple queue. All methods are thread-safe.
 * 
 * @author dennis zhuang
 */
public class SimpleQueue extends java.util.AbstractQueue {

  protected final LinkedList list;

  public SimpleQueue(int initializeCapacity) {
    this.list = new LinkedList();
  }

  public SimpleQueue() {
    this(100);
  }

  public synchronized boolean offer(T e) {
    return this.list.add(e);
  }

  public synchronized T peek() {
    return this.list.peek();
  }

  public synchronized T poll() {
    return this.list.poll();
  }

  @Override
  public Iterator iterator() {
    return this.list.iterator();
  }

  @Override
  public int size() {
    return this.list.size();
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy