public class IntArrayQueue extends AbstractQueue<Integer>
nullValue().
The IntArrayQueue.IntIterator is cached by default to avoid allocation unless directed to do so in the constructor.
Note: This class is not threadsafe.
| Modifier and Type | Class and Description |
|---|---|
class |
IntArrayQueue.IntIterator
Specialised
Iterator from which the value can be retrieved without boxing via IntArrayQueue.IntIterator.nextValue(). |
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_NULL_VALUE
Default representation of null for an element.
|
static int |
MIN_CAPACITY
Minimum capacity for the queue which must also be a power of 2.
|
| Constructor and Description |
|---|
IntArrayQueue()
Construct a new queue defaulting to
MIN_CAPACITY capacity, DEFAULT_NULL_VALUE
and cached iterators. |
IntArrayQueue(int nullValue)
Construct a new queue defaulting to
MIN_CAPACITY capacity and cached iterators. |
IntArrayQueue(int initialCapacity,
int nullValue)
Construct a new queue default to cached iterators.
|
IntArrayQueue(int initialCapacity,
int nullValue,
boolean shouldAvoidAllocation)
Construct a new queue providing all the config options.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Integer element) |
boolean |
addInt(int element)
Offer an element to the tail of the queue without boxing.
|
int |
capacity()
The current capacity for the collection.
|
void |
clear() |
Integer |
element() |
int |
elementInt()
Peek at the element on the head of the queue without boxing.
|
void |
forEach(Consumer<? super Integer> action) |
void |
forEachInt(IntConsumer action)
Iterate over the collection without boxing.
|
boolean |
isEmpty() |
IntArrayQueue.IntIterator |
iterator() |
int |
nullValue()
The value representing a null element.
|
boolean |
offer(Integer element) |
boolean |
offerInt(int element)
Offer an element to the tail of the queue without boxing.
|
Integer |
peek() |
int |
peekInt()
Peek at the element on the head of the queue without boxing.
|
Integer |
poll() |
int |
pollInt()
Poll the element from the head of the queue without boxing.
|
Integer |
remove() |
int |
removeInt()
Remove the element at the head of the queue without boxing.
|
int |
size() |
String |
toString() |
addAllcontains, containsAll, remove, removeAll, retainAll, toArray, toArrayclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcontains, containsAll, equals, hashCode, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArraypublic static final int DEFAULT_NULL_VALUE
public static final int MIN_CAPACITY
public IntArrayQueue()
MIN_CAPACITY capacity, DEFAULT_NULL_VALUE
and cached iterators.public IntArrayQueue(int nullValue)
MIN_CAPACITY capacity and cached iterators.nullValue - cannot be stored in the queue and used as a sentinel.public IntArrayQueue(int initialCapacity,
int nullValue)
initialCapacity - for the queue which will be rounded up to the nearest power of 2.nullValue - which cannot be stored in the queue and used as a sentinel.public IntArrayQueue(int initialCapacity,
int nullValue,
boolean shouldAvoidAllocation)
initialCapacity - for the queue which will be rounded up to the nearest power of 2.nullValue - which cannot be stored in the queue and used as a sentinel.shouldAvoidAllocation - true to cache the iterator otherwise false to allocate a new iterator each time.public int nullValue()
public int capacity()
public int size()
size in interface Collection<Integer>size in class AbstractCollection<Integer>public boolean isEmpty()
isEmpty in interface Collection<Integer>isEmpty in class AbstractCollection<Integer>public void clear()
clear in interface Collection<Integer>clear in class AbstractQueue<Integer>public boolean offer(Integer element)
public boolean offerInt(int element)
element - to be offered to the queue.public boolean add(Integer element)
add in interface Collection<Integer>add in interface Queue<Integer>add in class AbstractQueue<Integer>public boolean addInt(int element)
element - to be offered to the queue.public Integer peek()
public int peekInt()
public Integer poll()
public int pollInt()
nullValue.public Integer remove()
public Integer element()
public int elementInt()
NoSuchElementException - if the queue is empty.public int removeInt()
NoSuchElementException - if the queue is empty.public String toString()
toString in class AbstractCollection<Integer>public void forEachInt(IntConsumer action)
action - to be taken for each element.public IntArrayQueue.IntIterator iterator()
iterator in interface Iterable<Integer>iterator in interface Collection<Integer>iterator in class AbstractCollection<Integer>Copyright © 2014-2021 Real Logic Limited. All Rights Reserved.