LongArrayQueue
@UnstableApi
public final class LongArrayQueue
Array-based unbounded queue for long primitives with amortized O(1) add and remove.
Use this class instead of a java.util.Deque to avoid boxing long primitives to Long instances.
Summary
Constants |
|
|---|---|
static final int |
Default initial capacity. |
Public constructors |
|---|
|
Creates a queue with an initial capacity of |
LongArrayQueue(int minCapacity)Creates a queue with capacity for at least |
Public methods |
|
|---|---|
void |
add(long value)Add a new item to the queue. |
void |
clear()Clears the queue. |
long |
element()Retrieves, but does not remove, the head of the queue. |
boolean |
isEmpty()Returns whether the queue is empty. |
long |
remove()Remove an item from the queue. |
int |
size()Returns the number of items in the queue. |
Constants
DEFAULT_INITIAL_CAPACITY
public static final int DEFAULT_INITIAL_CAPACITY = 16
Default initial capacity.
Public constructors
LongArrayQueue
public LongArrayQueue()
Creates a queue with an initial capacity of DEFAULT_INITIAL_CAPACITY.
LongArrayQueue
public LongArrayQueue(int minCapacity)
Creates a queue with capacity for at least minCapacity
| Parameters | |
|---|---|
int minCapacity |
minCapacity the minimum capacity, between 1 and 2^30 inclusive |
Public methods
element
public long element()
Retrieves, but does not remove, the head of the queue.
| Throws | |
|---|---|
java.util.NoSuchElementException |
if the queue is empty. |
remove
public long remove()
Remove an item from the queue.
| Throws | |
|---|---|
java.util.NoSuchElementException |
if the queue is empty. |