Class ConcatenatingIterator<E>

  • All Implemented Interfaces:
    Iterator<E>

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

      • ConcatenatingIterator

        public ConcatenatingIterator​(Iterator<? extends E> first,
                                     Supplier<Iterator<? extends E>> second)
        Create an iterator that concatenates the results of two supplied iterators. 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 Iterator<E>
      • next

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