public class LongArrayQueue extends AbstractQueue<Long> implements Serializable
nullValue()
.
The LongArrayQueue.LongIterator
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 |
LongArrayQueue.LongIterator
Specialised
Iterator from which the value can be retrieved without boxing via LongArrayQueue.LongIterator.nextValue() . |
Modifier and Type | Field and Description |
---|---|
static long |
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 |
---|
LongArrayQueue()
Construct a new queue defaulting to
MIN_CAPACITY capacity, DEFAULT_NULL_VALUE
and cached iterators. |
LongArrayQueue(int initialCapacity,
long nullValue)
Construct a new queue default to cached iterators.
|
LongArrayQueue(int initialCapacity,
long nullValue,
boolean shouldAvoidAllocation)
Construct a new queue providing all the config options.
|
LongArrayQueue(long nullValue)
Construct a new queue defaulting to
MIN_CAPACITY capacity and cached iterators. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Long element) |
boolean |
addLong(long element)
Offer an element to the tail of the queue without boxing.
|
int |
capacity()
The current capacity for the collection.
|
void |
clear() |
Long |
element() |
long |
elementLong()
Peek at the element on the head of the queue without boxing.
|
void |
forEach(Consumer<? super Long> action) |
void |
forEachLong(LongConsumer action)
Iterate over the collection without boxing.
|
boolean |
isEmpty() |
LongArrayQueue.LongIterator |
iterator() |
long |
nullValue()
The value representing a null element.
|
boolean |
offer(Long element) |
boolean |
offerLong(long element)
Offer an element to the tail of the queue without boxing.
|
Long |
peek() |
long |
peekLong()
Peek at the element on the head of the queue without boxing.
|
Long |
poll() |
long |
pollLong()
Poll the element from the head of the queue without boxing.
|
Long |
remove() |
long |
removeLong()
Remove the element at the head of the queue without boxing.
|
int |
size() |
String |
toString() |
addAll
contains, containsAll, remove, removeAll, retainAll, toArray, toArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, containsAll, equals, hashCode, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
public static final long DEFAULT_NULL_VALUE
public static final int MIN_CAPACITY
public LongArrayQueue()
MIN_CAPACITY
capacity, DEFAULT_NULL_VALUE
and cached iterators.public LongArrayQueue(long nullValue)
MIN_CAPACITY
capacity and cached iterators.nullValue
- cannot be stored in the queue and used as a sentinel.public LongArrayQueue(int initialCapacity, long 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 LongArrayQueue(int initialCapacity, long 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 long nullValue()
public int capacity()
public int size()
size
in interface Collection<Long>
size
in class AbstractCollection<Long>
public boolean isEmpty()
isEmpty
in interface Collection<Long>
isEmpty
in class AbstractCollection<Long>
public void clear()
clear
in interface Collection<Long>
clear
in class AbstractQueue<Long>
public boolean offerLong(long element)
element
- to be offer to the queue.public boolean add(Long element)
add
in interface Collection<Long>
add
in interface Queue<Long>
add
in class AbstractQueue<Long>
public boolean addLong(long element)
element
- to be offer to the queue.public long peekLong()
public long pollLong()
nullValue
.public Long remove()
public Long element()
public long elementLong()
NoSuchElementException
- if the queue is empty.public long removeLong()
NoSuchElementException
- if the queue is empty.public String toString()
toString
in class AbstractCollection<Long>
public void forEachLong(LongConsumer action)
action
- to be taken for each element.public LongArrayQueue.LongIterator iterator()
iterator
in interface Iterable<Long>
iterator
in interface Collection<Long>
iterator
in class AbstractCollection<Long>
Copyright © 2014-2019 Real Logic Ltd. All Rights Reserved.