Class ConcatenatingIterator<E>

  • All Implemented Interfaces:
    java.util.Iterator<E>

    public class ConcatenatingIterator<E>
    extends java.lang.Object
    implements java.util.Iterator<E>
    An iterator over nodes, that concatenates the nodes returned by two supplied iterators.
    • Constructor Summary

      Constructors 
      Constructor Description
      ConcatenatingIterator​(java.util.Iterator<? extends E> first, java.util.function.Supplier<java.util.Iterator<? extends E>> second)
      Create an iterator that concatenates the results of two supplied iterator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      E next()
      Get the next item in the sequence.
      • 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, remove
    • Constructor Detail

      • ConcatenatingIterator

        public ConcatenatingIterator​(java.util.Iterator<? extends E> first,
                                     java.util.function.Supplier<java.util.Iterator<? extends E>> second)
        Create an iterator that concatenates the results of two supplied iterator. The second iterator isn't created until it is actually needed.
        Parameters:
        first - the first iterator
        second - a function that can be called to supply the second iterator
    • Method Detail

      • hasNext

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

        public E next()
        Get the next item in the sequence.
        Specified by:
        next in interface java.util.Iterator<E>
        Returns:
        the next Item. If there are no more items, return null.