Methods Summary |
---|
public final void | append(persistence.antlr.Token tok)Add token to end of the queue
if (nbrEntries == buffer.length) {
expand();
}
buffer[(offset + nbrEntries) & sizeLessOne] = tok;
nbrEntries++;
|
public final persistence.antlr.Token | elementAt(int idx)Fetch a token from the queue by index
return buffer[(offset + idx) & sizeLessOne];
|
private final void | expand()Expand the token buffer by doubling its capacity
Token[] newBuffer = new Token[buffer.length * 2];
// Copy the contents to the new buffer
// Note that this will store the first logical item in the
// first physical array element.
for (int i = 0; i < buffer.length; i++) {
newBuffer[i] = elementAt(i);
}
// Re-initialize with new contents, keep old nbrEntries
buffer = newBuffer;
sizeLessOne = buffer.length - 1;
offset = 0;
|
private final void | init(int size)Initialize the queue.
// Allocate buffer
buffer = new Token[size];
// Other initialization
sizeLessOne = size - 1;
offset = 0;
nbrEntries = 0;
|
public final void | removeFirst()Remove token from front of queue
offset = (offset + 1) & sizeLessOne;
nbrEntries--;
|
public final void | reset()Clear the queue. Leaving the previous buffer alone.
offset = 0;
nbrEntries = 0;
|