public class CircularQueue<E>
extends java.util.AbstractList<E>
implements java.util.Queue<E>, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
private static int |
DEFAULT_CAPACITY
Minimal size of the underlying array
|
private int |
first |
private boolean |
full |
private int |
initialCapacity
The initial capacity of the list
|
private java.lang.Object[] |
items |
private int |
last |
private int |
mask |
private static long |
serialVersionUID
The serialVersionUID : mandatory for serializable classes
|
private int |
shrinkThreshold |
| Constructor and Description |
|---|
CircularQueue()
Construct a new, empty queue.
|
CircularQueue(int initialCapacity) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E o) |
void |
add(int idx,
E o) |
int |
capacity()
Returns the capacity of this queue.
|
private void |
checkIndex(int idx) |
void |
clear() |
private void |
decreaseSize() |
E |
element() |
private void |
expandIfNeeded() |
E |
get(int idx) |
private int |
getRealIndex(int idx) |
private void |
increaseSize() |
boolean |
isEmpty() |
private static int |
normalizeCapacity(int initialCapacity)
The capacity must be a power of 2.
|
boolean |
offer(E item) |
E |
peek() |
E |
poll() |
E |
remove() |
E |
remove(int idx) |
E |
set(int idx,
E o) |
private void |
shrinkIfNeeded() |
int |
size() |
java.lang.String |
toString() |
addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListaddAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitprivate static final long serialVersionUID
private static final int DEFAULT_CAPACITY
private final int initialCapacity
private volatile java.lang.Object[] items
private int mask
private int first
private int last
private boolean full
private int shrinkThreshold
public CircularQueue()
public CircularQueue(int initialCapacity)
private static int normalizeCapacity(int initialCapacity)
public int capacity()
public void clear()
public E get(int idx)
public boolean isEmpty()
public int size()
public java.lang.String toString()
toString in class java.util.AbstractCollection<E>private void checkIndex(int idx)
private int getRealIndex(int idx)
private void increaseSize()
private void decreaseSize()
private void expandIfNeeded()
private void shrinkIfNeeded()
public boolean add(E o)
public void add(int idx,
E o)
public E remove(int idx)