|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.runtime.misc.FastQueue<T>
public class FastQueue<T>
A queue that can dequeue and get(i) in O(1) and grow arbitrarily large. A linked list is fast at dequeue but slow at get(i). An array is the reverse. This is O(1) for both operations. List grows until you dequeue last element at end of buffer. Then it resets to start filling at 0 again. If adds/removes are balanced, the buffer will not grow too large. No iterator stuff as that's not how we'll use it.
Field Summary | |
---|---|
protected List<T> |
data
dynamically-sized buffer of elements |
protected int |
p
index of next element to fill |
protected int |
range
|
Constructor Summary | |
---|---|
FastQueue()
|
Method Summary | |
---|---|
void |
add(T o)
|
void |
clear()
|
T |
elementAt(int i)
Return element i elements ahead of current element. |
T |
head()
|
int |
range()
|
T |
remove()
Get and remove first element in queue |
void |
reset()
|
int |
size()
|
String |
toString()
Return string of current buffer contents; non-destructive |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected List<T> data
protected int p
protected int range
Constructor Detail |
---|
public FastQueue()
Method Detail |
---|
public void reset()
public void clear()
public T remove()
public void add(T o)
public int size()
public int range()
public T head()
public T elementAt(int i)
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |