Package

org.hammerlab.magic

iterator

Permalink

package iterator

Visibility
  1. Public
  2. All

Type Members

  1. class GroupRunsIterator[T] extends Iterator[Iterator[T]]

    Permalink

    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.

    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.

  2. class LinesIterator extends SimpleBufferedIterator[String]

    Permalink

    Wrap a BufferedReader and emit lines.

  3. class RangeAccruingIterator extends Iterator[Range]

    Permalink

    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.

  4. class RunLengthIterator[K] extends Iterator[(K, Int)]

    Permalink

    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.

  5. trait SimpleBufferedIterator[+T] extends BufferedIterator[T]

    Permalink

    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.

  6. case class Sliding3OptIterator[T](it: BufferedIterator[T]) extends SimpleBufferedIterator[(Option[T], T, Option[T])] with Product with Serializable

    Permalink

    Given an Iterator[T], emit each element sandwiched between its preceding and succeeding elements.

  7. class TakeUntilIterator[T] extends Iterator[Seq[T]]

    Permalink

    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.

Value Members

  1. object GroupRunsIterator

    Permalink
  2. object LinesIterator

    Permalink
  3. object RunLengthIterator

    Permalink

Ungrouped