public abstract class LookaheadStream<T> extends FastQueue<T>
| Modifier and Type | Field and Description |
|---|---|
protected int |
currentElementIndex
Absolute token index.
|
T |
eof
Track object returned by nextElement upon end of stream;
Return it later when they ask for LT passed end of input.
|
protected int |
lastMarker
Track the last mark() call result value for use in rewind().
|
protected int |
markDepth
tracks how deep mark() calls are nested
|
protected T |
prevElement |
static int |
UNINITIALIZED_EOF_ELEMENT_INDEX |
| Constructor and Description |
|---|
LookaheadStream() |
| Modifier and Type | Method and Description |
|---|---|
void |
consume()
Make sure we have at least one element to remove, even if EOF
|
void |
fill(int n)
add n elements to buffer
|
int |
index() |
abstract boolean |
isEOF(T o) |
protected T |
LB(int k) |
T |
LT(int k) |
int |
mark() |
abstract T |
nextElement()
Implement nextElement to supply a stream of elements to this
lookahead buffer.
|
void |
release(int marker) |
T |
remove()
Get and remove first element in queue; override FastQueue.remove();
it's the same, just checks for backtracking.
|
void |
reset() |
void |
rewind() |
void |
rewind(int marker) |
void |
seek(int index)
Seek to a 0-indexed position within data buffer.
|
int |
size()
Size of entire stream is unknown; we only know buffer size from FastQueue
|
protected void |
syncAhead(int need)
Make sure we have 'need' elements from current position p.
|
public static final int UNINITIALIZED_EOF_ELEMENT_INDEX
protected int currentElementIndex
protected T prevElement
public T eof
protected int lastMarker
protected int markDepth
public abstract T nextElement()
public abstract boolean isEOF(T o)
public T remove()
public void consume()
protected void syncAhead(int need)
public void fill(int n)
public int size()
public T LT(int k)
public int index()
public int mark()
public void release(int marker)
public void rewind(int marker)
public void rewind()
public void seek(int index)
protected T LB(int k)