Given an iterator and a predicate function, emit iterators containing maximal runs of sequential elements that all satisfy the predicate, or individual elements that do not.
Wrap a BufferedReader and emit lines.
Given an Iterator of Ints, collapse contiguous "ranges" of integers that are each 1 greater than their predecessor.
Given an Iterator of Ints, collapse contiguous "ranges" of integers that are each 1 greater than their predecessor.
For example, given an input [2, 3, 1, 4, 5, 6, 5, 6, 8], this would emit Ranges (in half-open notation): [2, 4), [1, 2), [4, 7), [5, 7), [8, 9).
See RangeAccruingIteratorTest for more examples.
Run-length encode an input iterator, replacing contiguous runs of identical elements with pairs consisting of the first element in the run and the number of elements observed.
Run-length encode an input iterator, replacing contiguous runs of identical elements with pairs consisting of the first element in the run and the number of elements observed.
See RunLengthIteratorTest for examples.
Interface for implementing BufferedIterators following a common pattern: the hasNext
implementation must
actually compute the next element (or return a sentinel that implies that one doesn't exist), and should therefore
cache that element to serve head
and next()
calls.
Interface for implementing BufferedIterators following a common pattern: the hasNext
implementation must
actually compute the next element (or return a sentinel that implies that one doesn't exist), and should therefore
cache that element to serve head
and next()
calls.
This interface allows subclasses to simply implement an _advance
method that returns an Option containing the
next element, if one exists, and None otherwise, and it takes care of the rest of the boilerplate.
It also exposes protected clear
and postNext
methods for Noneing the internal state and responding to
next()
having been called, respectively.
Given an Iterator[T], emit each element sandwiched between its preceding and succeeding elements.
For each element in an input Iterator, emit the sequence of elements from the current one to the next sentinel
value (or the end of the iterator, if no more sentinels follow the current element).
For each element in an input Iterator, emit the sequence of elements from the current one to the next sentinel
value (or the end of the iterator, if no more sentinels follow the current element).
See TakeUntilIteratorTest for examples.
Given an iterator and a predicate function, emit iterators containing maximal runs of sequential elements that all satisfy the predicate, or individual elements that do not.
For example, given an Iterator containing Ints [1, 2, 4, 3, 5, 6, 2, 8] and predicate function
_ % 2 == 0
, GroupRunsIterator would emit Iterators containing [1], [2, 4], [3], [5], [6, 2, 8].See GroupRunsIteratorTest for more examples.