A lookahead queue that knows how to mark/release locations in the buffer for backtracking purposes. Any markers force the FastQueue superclass to keep all elements until no more markers; then can reset to avoid growing a huge buffer.

Type parameters

  • T

Hierarchy

Index

Properties

_data

_data: List<T> = new List<T>()

dynamically-sized buffer of elements

_eof

_eof: T = null

Track object returned by nextElement upon end of stream; Return it later when they ask for LT passed end of input.

_lastMarker

_lastMarker: number
Track the last mark() call result value for use in rewind().

_markDepth

_markDepth: number
tracks how deep mark() calls are nested

_p

_p: number = 0

index of next element to fill

range

range: number = 0

How deep have we gone?

Accessors

count

  • get count(): number
  • Size of entire stream is unknown; we only know buffer size from FastQueue

    Returns number

endOfFile

  • get endOfFile(): T
  • set endOfFile(value: T): void
  • Returns T

  • Parameters

    • value: T

    Returns void

index

  • get index(): number
  • Returns number

previousElement

  • get previousElement(): T
  • Returns T

Methods

clear

  • clear(): void

consume

  • consume(): void
  • Make sure we have at least one element to remove, even if EOF

    Returns void

dequeue

  • dequeue(): T
  • Get and remove first element in queue; override {@link FastQueue#remove()}; it's the same, just checks for backtracking.

    Returns T

enqueue

  • enqueue(o: T): void

fill

  • fill(n: number): void
  • add n elements to buffer

    Parameters

    • n: number

    Returns void

get

  • get(i: number): T
  • Return element {@code i} elements ahead of current element. {@code i==0} gets current element. This is not an absolute index into {@link #data} since {@code p} defines the start of the real list.

    Parameters

    • i: number

    Returns T

isEndOfFile

  • isEndOfFile(o: T): boolean
  • Parameters

    • o: T

    Returns boolean

lb

  • lb(k: number): T
  • Parameters

    • k: number

    Returns T

lt

  • lt(k: number): T
  • Parameters

    • k: number

    Returns T

mark

  • mark(): number
  • Returns number

nextElement

  • nextElement(): T
  • Implement nextElement to supply a stream of elements to this lookahead buffer. Return EOF upon end of the stream we're pulling from.

    Returns T

peek

  • peek(): T

release

  • release(marker: number): void
  • Parameters

    • marker: number

    Returns void

reset

  • reset(): void
  • Returns void

rewind

  • rewind(): void
  • Returns void

rewind2

  • rewind2(marker: number): void
  • Parameters

    • marker: number

    Returns void

seek

  • seek(index: number): void
  • Seek to a 0-indexed absolute token index. Normally used to seek backwards in the buffer. Does not force loading of nodes. To preserve backward compatibility, this method allows seeking past the end of the currently buffered data. In this case, the input pointer will be moved but the data will only actually be loaded upon the next call to {@link #consume} or {@link #LT} for {@code k>0}.

    Parameters

    • index: number

    Returns void

syncAhead

  • syncAhead(need: number): void
  • Make sure we have 'need' elements from current position p. Last valid p index is data.size()-1. p+need-1 is the data index 'need' elements ahead. If we need 1 element, (p+1-1)==p must be < data.size().

    Parameters

    • need: number

    Returns void

toString

  • toString(): string
  • Return string of current buffer contents; non-destructive

    Returns string

Generated using TypeDoc