Class LazyIteratorChain<T>

  • Type Parameters:
    T - type of values iterating over
    All Implemented Interfaces:
    java.util.Iterator<T>

    public class LazyIteratorChain<T>
    extends java.lang.Object
    implements java.util.Iterator<T>
    This class implements the concatenation of iterators. The implementation is lazy in the sense that advancing of any iterator is deferred as much as possible. Specifically no iterator is fully unwrapped at one single point of time.
    • Constructor Summary

      Constructors 
      Constructor Description
      LazyIteratorChain​(java.util.Iterator<java.util.Iterator<T>> iterators)  
      LazyIteratorChain​(java.util.Iterator<T>... iterators)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.Iterator<T> chain​(java.util.Iterator<java.util.Iterator<T>> iterators)
      Returns the concatenation of all iterators in iterators.
      static <T> java.util.Iterator<T> chain​(java.util.Iterator<T>... iterators)
      Returns the concatenation of all iterators in iterators.
      boolean hasNext()  
      T next()  
      void remove()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • LazyIteratorChain

        public LazyIteratorChain​(java.util.Iterator<java.util.Iterator<T>> iterators)
      • LazyIteratorChain

        public LazyIteratorChain​(java.util.Iterator<T>... iterators)
    • Method Detail

      • chain

        public static <T> java.util.Iterator<T> chain​(java.util.Iterator<java.util.Iterator<T>> iterators)
        Returns the concatenation of all iterators in iterators.
        Type Parameters:
        T -
        Parameters:
        iterators -
        Returns:
      • chain

        public static <T> java.util.Iterator<T> chain​(java.util.Iterator<T>... iterators)
        Returns the concatenation of all iterators in iterators.
        Type Parameters:
        T -
        Parameters:
        iterators -
        Returns:
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<T>
      • next

        public T next()
        Specified by:
        next in interface java.util.Iterator<T>
      • remove

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