Class JoinIterator<E>

java.lang.Object
com.globalmentor.collections.iterators.AbstractIteratorDecorator<E>
com.globalmentor.collections.iterators.JoinIterator<E>
Type Parameters:
E - The type of element being iterated.
All Implemented Interfaces:
Enumeration<E>, Iterator<E>

public class JoinIterator<E> extends AbstractIteratorDecorator<E>
An iterator that joins the contents of zero or more iterators. This class also implements the Enumeration interface. Element removal is not supported.
Author:
Garret Wilson
  • Constructor Details

    • JoinIterator

      public JoinIterator(@Nonnull Stream<Iterator<E>> iterators)
      Iterators constructor.
      Parameters:
      iterators - The iterators to join.
      Throws:
      NullPointerException - if any of the given iterators is null.
  • Method Details

    • getIterator

      protected Iterator<E> getIterator()

      This implementation returns the first iterator in the queue that is not empty. If no further iterators remain in the queue, an empty iterator is returned. This ensures that empty iterators are discarded as soon as possible, as well as allowing the actual iteration implementation to be delegated to the base classes.

      Specified by:
      getIterator in class AbstractIteratorDecorator<E>
      Returns:
      The iterator this class decorates.
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<E>
      Overrides:
      remove in class AbstractIteratorDecorator<E>