Package com.google.code.yanf4j.util
Class CircularQueue<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- com.google.code.yanf4j.util.CircularQueue<E>
-
- Type Parameters:
E
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
,java.util.Queue<E>
public class CircularQueue<E> extends java.util.AbstractList<E> implements java.util.List<E>, java.util.Queue<E>, java.io.Serializable
A circular queue from mina- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_CAPACITY
private int
first
private boolean
full
private int
initialCapacity
private java.lang.Object[]
items
private int
last
private int
mask
private static long
serialVersionUID
private int
shrinkThreshold
-
Constructor Summary
Constructors Constructor Description CircularQueue()
Construct a new, empty queue.CircularQueue(int initialCapacity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int idx, E o)
boolean
add(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)
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()
-
Methods inherited from class java.util.AbstractList
addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
DEFAULT_CAPACITY
private static final int DEFAULT_CAPACITY
- See Also:
- Constant Field Values
-
initialCapacity
private final int initialCapacity
-
items
private volatile java.lang.Object[] items
-
mask
private int mask
-
first
private int first
-
last
private int last
-
full
private boolean full
-
shrinkThreshold
private int shrinkThreshold
-
-
Method Detail
-
normalizeCapacity
private static int normalizeCapacity(int initialCapacity)
-
capacity
public int capacity()
Returns the capacity of this queue.
-
clear
public void clear()
-
get
public E get(int idx)
-
isEmpty
public boolean isEmpty()
-
size
public int size()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<E>
-
checkIndex
private void checkIndex(int idx)
-
getRealIndex
private int getRealIndex(int idx)
-
increaseSize
private void increaseSize()
-
decreaseSize
private void decreaseSize()
-
expandIfNeeded
private void expandIfNeeded()
-
shrinkIfNeeded
private void shrinkIfNeeded()
-
add
public boolean add(E o)
-
add
public void add(int idx, E o)
-
remove
public E remove(int idx)
-
-