Package com.complexible.common.collect

# Class BatchingIterator<T>

java.lang.Object
com.google.common.collect.UnmodifiableIterator<Iterator<T>>
com.google.common.collect.AbstractIterator<Iterator<T>>
com.complexible.common.collect.BatchingIterator<T>

Type Parameters:
  `T` - element type

All Implemented Interfaces:
  `Iterator<Iterator<T>>`

public class BatchingIterator<T> extends com.google.common.collect.AbstractIterator<Iterator<T>>
An iterator which batches elements of the underlying iterator. This iterator iterates over batches (iterators) of the element type. Each returned iterator is one batch. Batches must be exhausted sequentially to avoid interfering with each other.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BatchingIterator(Iterator<T> sourceIterator, Predicate<T> theBatchPredicate)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected Iterator<T>`
  `computeNext()`
  `static <T> Iterator<Iterator<T>>`
  `sized(Iterator<T> source, int size)`
  Return a `BatchingIterator` which creates fixed size batches.

  ### Methods inherited from class com.google.common.collect.AbstractIterator

  `endOfData, hasNext, next, peek`

  ### Methods inherited from class com.google.common.collect.UnmodifiableIterator

  `remove`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.util.Iterator

  `forEachRemaining`

- ## Constructor Details

  - ### BatchingIterator

    public BatchingIterator(Iterator<T> sourceIterator, Predicate<T> theBatchPredicate)
    Parameters:
      `sourceIterator` - underlying source iterator where elements will be taken from
      `theBatchPredicate` - a predicate indicating whether the element should be included in the current batch

- ## Method Details

  - ### computeNext

    protected Iterator<T> computeNext()
    Specified by:
      `computeNext` in class `com.google.common.collect.AbstractIterator<Iterator<T>>`

  - ### sized

    public static <T> Iterator<Iterator<T>> sized(Iterator<T> source, int size)
    Return a `BatchingIterator` which creates fixed size batches.