E - the type of object the queue holdsjava.lang.Iterable<E>, java.util.Collection<E>, java.util.Queue<E>public class ArrayQueue<E>
extends java.util.AbstractList<E>
implements java.util.Queue<E>
This partial Queue implementation (also with remove() for stack operation)
is backed by a growable circular array.
| Modifier and Type | Field | Description |
|---|---|---|
protected java.lang.Object[] |
_elements |
|
protected int |
_growCapacity |
|
protected java.lang.Object |
_lock |
|
protected int |
_nextE |
|
protected int |
_nextSlot |
|
protected int |
_size |
|
static int |
DEFAULT_CAPACITY |
|
static int |
DEFAULT_GROWTH |
| Constructor | Description |
|---|---|
ArrayQueue() |
|
ArrayQueue(int capacity) |
|
ArrayQueue(int initCapacity,
int growBy) |
|
ArrayQueue(int initCapacity,
int growBy,
java.lang.Object lock) |
|
ArrayQueue(java.lang.Object lock) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
add(int index,
E element) |
|
boolean |
add(E e) |
|
void |
addUnsafe(E e) |
Add without synchronization or bounds checking
|
void |
clear() |
|
protected E |
dequeue() |
|
E |
element() |
|
protected boolean |
enqueue(E e) |
|
E |
get(int index) |
|
int |
getCapacity() |
|
int |
getNextSlotUnsafe() |
|
E |
getUnsafe(int index) |
Get without synchronization or bounds checking.
|
protected boolean |
growUnsafe() |
|
boolean |
isEmpty() |
|
java.lang.Object |
lock() |
|
boolean |
offer(E e) |
|
E |
peek() |
|
E |
peekUnsafe() |
|
E |
poll() |
|
E |
pollUnsafe() |
|
E |
remove() |
|
E |
remove(int index) |
|
protected void |
resizeUnsafe(int newCapacity) |
|
E |
set(int index,
E element) |
|
int |
size() |
|
int |
sizeUnsafe() |
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toStringaddAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListaddAll, contains, containsAll, equals, hashCode, iterator, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArraypublic static final int DEFAULT_CAPACITY
public static final int DEFAULT_GROWTH
protected final java.lang.Object _lock
protected final int _growCapacity
protected java.lang.Object[] _elements
protected int _nextE
protected int _nextSlot
protected int _size
public ArrayQueue()
public ArrayQueue(java.lang.Object lock)
public ArrayQueue(int capacity)
public ArrayQueue(int initCapacity,
int growBy)
public ArrayQueue(int initCapacity,
int growBy,
java.lang.Object lock)
public java.lang.Object lock()
public int getCapacity()
public int getNextSlotUnsafe()
public boolean add(E e)
protected boolean enqueue(E e)
public void addUnsafe(E e)
e - the element to addadd(Object)public E peekUnsafe()
public E pollUnsafe()
protected E dequeue()
public void clear()
public boolean isEmpty()
public int size()
public int sizeUnsafe()
public E getUnsafe(int index)
index - index of the element to returnget(int)protected void resizeUnsafe(int newCapacity)
protected boolean growUnsafe()
Copyright © 1995–2018 Webtide. All rights reserved.