Get the next item from the stream, advancing the cursor, while
honoring previous calls to pushback()
.
Get the next item from the stream, advancing the cursor, while
honoring previous calls to pushback()
.
an Option
containing the next item, or None
if the iterator is exhausted.
Push a single item back onto the stream.
Push a single item back onto the stream.
the item
Push a list of items back onto the stream.
Push a list of items back onto the stream. The items are pushed back in reverse order, so the items in the list should be in the order they were retrieved from the stream. For example:
val stream = new SafeIterator[Char]("foobar") with Pushback[Char] val list = List(stream.next.get, stream.next.get) // At this point, the list contains ('f', 'o'), and the stream // contains "obar". stream.pushback(list) // Stream now contains "foobar"
the items to push back.
The
Pushback
trait can be mixed into anSafeIterator
to permit arbitrary pushback.NOTE: This trait it not thread-safe.