public class ArrayQueue<T>
extends java.util.AbstractQueue<T>
// Create a queue with some initial elements
Queue<Integer> a=new ArrayQueue<Integer>(1,2,3,4,5,6,7,8);
int counter=9;
// Always add one new element and poll two
while(a.size()!=0) {
a.offer(counter++);
D.p(a.poll());
D.p(a.poll());
}
-->
1,2,3,...,14
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.Object[] |
blanks
Dummy blank objects used to enlarge the data array
|
protected java.util.List<T> |
data
Holds the queue elements
|
protected int |
first
Index of the first element
|
protected int |
last
Index of the last element
|
| Constructor and Description |
|---|
ArrayQueue(java.util.Collection<T> initialData) |
ArrayQueue(int size) |
ArrayQueue(T... initialData) |
| Modifier and Type | Method and Description |
|---|---|
java.util.Iterator<T> |
iterator() |
static void |
main(java.lang.String[] args)
Test routine
|
boolean |
offer(T o) |
T |
peek() |
T |
poll() |
int |
size() |
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitprotected java.util.List<T> data
protected int first
protected int last
protected static java.lang.Object[] blanks
public ArrayQueue(T... initialData)
public ArrayQueue(java.util.Collection<T> initialData)
public ArrayQueue(int size)