public class BoundedQueue<E> extends java.util.AbstractCollection<E>
Modifier and Type | Field and Description |
---|---|
private int |
count |
private java.util.ArrayList<E> |
elements |
private int |
head |
private int |
tail |
Constructor and Description |
---|
BoundedQueue(int capacity)
Constructs an empty queue.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E anObject)
Append an object at tail.
|
boolean |
isFull()
Checks whether this queue is full.
|
java.util.Iterator<E> |
iterator() |
E |
peek()
Gets object at head.
|
E |
remove()
Remove object at head.
|
int |
size() |
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public BoundedQueue(int capacity)
capacity
- the maximum capacity of the queue
Precondition: capacity > 0
public E remove()
Precondition: size() > 0
public int size()
public boolean isFull()