removeLast() and addFirst(Object).
| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| protected int | head
Index of first element. |
| private transient Queue. | |
| public int | size
Number of elements in the queue. |
| protected int | tail
Index of last element. |
| protected T[] | values
Contains the values in the queue. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Queue(int initialSize)
Creates a new Queue which can hold the specified number of values without needing to resize backing array. |
| public | Queue(int initialSize, Class<T> type)
Deprecated
Use
Queue#Queue(int, ArraySupplier) instead
Creates a new Queue which can hold the specified number of values without needing to resize backing array. |
| public | Queue(int initialSize, ArraySupplier<T[]> arraySupplier)
Creates a new Queue which can hold the specified number of values without needing to resize backing array. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public void | ensureCapacity(int additional)
Increases the size of the backing array to accommodate the specified number of additional items. |
| public boolean | equals(Object o)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public boolean | |
| public T | |
| public T | |
| public int | |
| public int | Returns: An index of first occurrence of value in queue or -1 if no such value existsIf true, == comparison will be used. If false, .equals() comparison will be used. identity)Returns the index of first occurrence of value in the queue, or -1 if no such value exists. |
| public boolean | |
| public Iterator | |
| public T | |
| public boolean | |
| public T | |
| public T | |
| public T | |
| public boolean | Returns: true if value was found and removed, false otherwiseIf true, == comparison will be used. If false, .equals() comparison will be used. identity)Removes the first instance of the specified value in the queue. |
| protected void | |
| public String | |
| public String |
| head | back to summary |
|---|---|
| protected int head Index of first element. Logically smaller than tail. Unless empty, it points to a valid element inside queue. | |
| iterable | back to summary |
|---|---|
| private transient Queue. | |
| size | back to summary |
|---|---|
| public int size Number of elements in the queue. | |
| tail | back to summary |
|---|---|
| protected int tail Index of last element. Logically bigger than head. Usually points to an empty position, but points to the head when full (size == values.length). | |
| values | back to summary |
|---|---|
| protected T[] values Contains the values in the queue. Head and tail indices go in a circle around this array, wrapping at the end. | |
| Queue | back to summary |
|---|---|
| public Queue() Creates a new Queue which can hold 16 values without needing to resize backing array. | |
| Queue | back to summary |
|---|---|
| public Queue(int initialSize) Creates a new Queue which can hold the specified number of values without needing to resize backing array. | |
| Queue | back to summary |
|---|---|
| public Queue(int initialSize, Class<T> type)
Deprecated Use Creates a new Queue which can hold the specified number of values without needing to resize backing array. This creates backing array of the specified type via reflection, which is necessary only when accessing the backing array directly.
| |
| Queue | back to summary |
|---|---|
| public Queue(int initialSize, ArraySupplier<T[]> arraySupplier) Creates a new Queue which can hold the specified number of values without needing to resize backing array. This creates backing array of the specified type via the supplier, which is necessary only when accessing the backing array directly. | |
| addFirst | back to summary |
|---|---|
| public void addFirst(T object) Prepend given object to the head. (enqueue to head) Unless backing array needs resizing, operates in O(1) time.
| |
| addLast | back to summary |
|---|---|
| public void addLast(T object) Append given object to the tail. (enqueue to tail) Unless backing array needs resizing, operates in O(1) time.
| |
| clear | back to summary |
|---|---|
| public void clear() Removes all values from this queue. Values in backing array are set to null to prevent memory leak, so this operates in O(n). | |
| ensureCapacity | back to summary |
|---|---|
| public void ensureCapacity(int additional) Increases the size of the backing array to accommodate the specified number of additional items. Useful before adding many items to avoid multiple backing array resizes. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| equalsIdentity | back to summary |
|---|---|
| public boolean equalsIdentity(Object o) Uses == for comparison of each item. | |
| first | back to summary |
|---|---|
| public T first() Returns the first (head) item in the queue (without removing it).
| |
| get | back to summary |
|---|---|
| public T get(int index) Retrieves the value in queue without removing it. Indexing is from the front to back, zero based. Therefore get(0) is the
same as
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| indexOf | back to summary |
|---|---|
| public int indexOf(T value, boolean identity) Returns the index of first occurrence of value in the queue, or -1 if no such value exists.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Returns true if the queue is empty. | |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Returns an iterator for the items in the queue. Remove is supported.
If | |
| last | back to summary |
|---|---|
| public T last() Returns the last (tail) item in the queue (without removing it).
| |
| notEmpty | back to summary |
|---|---|
| public boolean notEmpty() Returns true if the queue has one or more items. | |
| removeFirst | back to summary |
|---|---|
| public T removeFirst() Remove the first item from the queue. (dequeue from head) Always O(1).
| |
| removeIndex | back to summary |
|---|---|
| public T removeIndex(int index) Removes and returns the item at the specified index. | |
| removeLast | back to summary |
|---|---|
| public T removeLast() Remove the last item from the queue. (dequeue from tail) Always O(1).
| |
| removeValue | back to summary |
|---|---|
| public boolean removeValue(T value, boolean identity) Removes the first instance of the specified value in the queue.
| |
| resize | back to summary |
|---|---|
| protected void resize(int newSize) Resize backing array. newSize must be bigger than current size. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| toString | back to summary |
|---|---|
| public String toString(String separator) | |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private Queue. | |
| private Queue. | |
| private final Queue |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Iterator |
| allowRemove | back to summary |
|---|---|
| private final boolean allowRemove | |
| iterator1 | back to summary |
|---|---|
| private Queue. | |
| iterator2 | back to summary |
|---|---|
| private Queue. | |
| queue | back to summary |
|---|---|
| private final Queue<T> queue | |
| QueueIterable | back to summary |
|---|---|
| public QueueIterable(Queue<T> queue) | |
| QueueIterable | back to summary |
|---|---|
| public QueueIterable(Queue<T> queue, boolean allowRemove) | |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type
| |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| pack-priv int | |
| private final Queue | |
| pack-priv boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public Iterator | |
| public T | |
| public void | remove()
Overrides default java. Removes from the underlying collection the last element returned by this iterator (optional operation). |
| public void |
| allowRemove | back to summary |
|---|---|
| private final boolean allowRemove | |
| index | back to summary |
|---|---|
| pack-priv int index | |
| queue | back to summary |
|---|---|
| private final Queue<T> queue | |
| valid | back to summary |
|---|---|
| pack-priv boolean valid | |
| QueueIterator | back to summary |
|---|---|
| public QueueIterator(Queue<T> queue) | |
| QueueIterator | back to summary |
|---|---|
| public QueueIterator(Queue<T> queue, boolean allowRemove) | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns | |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type | |
| next | back to summary |
|---|---|
| public T next() Implements java. Doc from java. Returns the next element in the iteration. | |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the | |
| reset | back to summary |
|---|---|
| public void reset() | |