Class ConcatIterator<E>

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.util.Iterator<E>, CloseableIterator<E>

    public class ConcatIterator<E>
    extends AbstractIterator<E>
    implements CloseableIterator<E>
    Iterator that concatenates a bunch of iterables into 1 big iterator. Each iterable is retrieved lazily as requested. Note that if any of the produced iterators from the iterable implement CloseableIterator they will be closed when iterated upon fully or the last used iterator will be close when this iterator this closed.

    Removal is implemented and will invoke remove on the last used iterator

    Since:
    9.3
    Author:
    wburns
    • Constructor Summary

      Constructors 
      Constructor Description
      ConcatIterator​(java.lang.Iterable<? extends java.lang.Iterable<E>> iterableIterables)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      protected E getNext()
      Method to implement to provide an iterator implementation.
      void 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, hasNext, next
    • Constructor Detail

      • ConcatIterator

        public ConcatIterator​(java.lang.Iterable<? extends java.lang.Iterable<E>> iterableIterables)
    • Method Detail

      • getNext

        protected E getNext()
        Description copied from class: AbstractIterator
        Method to implement to provide an iterator implementation. When this method returns null, the iterator is complete.
        Specified by:
        getNext in class AbstractIterator<E>
        Returns:
        the next value for the iterator to return or null for it to be complete.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface CloseableIterator<E>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<E>