Class BatchingIterator<T>

  • Type Parameters:
    T - element type
    All Implemented Interfaces:

    public class BatchingIterator<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

      Constructor Description
      BatchingIterator​(java.util.Iterator<T> sourceIterator, java.util.function.Predicate<T> theBatchPredicate)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.util.Iterator<T> computeNext()  
      static <T> java.util.Iterator<java.util.Iterator<T>> sized​(java.util.Iterator<T> source, int size)
      Return a BatchingIterator which creates fixed size batches.
      • Methods inherited from class

        endOfData, hasNext, next, peek
      • Methods inherited from class

      • 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

    • Constructor Detail

      • BatchingIterator

        public BatchingIterator​(java.util.Iterator<T> sourceIterator,
                                java.util.function.Predicate<T> theBatchPredicate)
        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 Detail

      • computeNext

        protected java.util.Iterator<T> computeNext()
        Specified by:
        computeNext in class<java.util.Iterator<T>>
      • sized

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