Class CompoundIterator

  • All Implemented Interfaces:
    java.util.Iterator

    public class CompoundIterator
    extends java.lang.Object
    implements java.util.Iterator
    A compound iterator, which iterates over all of the elements in the given iterators.
    Version:
    $Revision$
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int index
      The index of the current iterator.
      protected java.util.Iterator[] iters
      The array of iterators to iterate over.
    • Constructor Summary

      Constructors 
      Constructor Description
      CompoundIterator​(java.util.Iterator[] iters)
      Construct a CompoundIterator over the given array of iterators.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Check if there are more elements.
      java.lang.Object next()
      Return the next element from the current iterator.
      void remove()
      Remove the current element from the current iterator.
      • 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
    • Field Detail

      • iters

        protected final java.util.Iterator[] iters
        The array of iterators to iterate over.
      • index

        protected int index
        The index of the current iterator.
    • Constructor Detail

      • CompoundIterator

        public CompoundIterator​(java.util.Iterator[] iters)
        Construct a CompoundIterator over the given array of iterators.
        Parameters:
        iters - Array of iterators to iterate over.
        Throws:
        java.lang.IllegalArgumentException - Array is null or empty.
    • Method Detail

      • hasNext

        public boolean hasNext()
        Check if there are more elements.
        Specified by:
        hasNext in interface java.util.Iterator
        Returns:
        True if there are more elements.
      • next

        public java.lang.Object next()
        Return the next element from the current iterator.
        Specified by:
        next in interface java.util.Iterator
        Returns:
        The next element from the current iterator.
        Throws:
        java.util.NoSuchElementException - There are no more elements.
      • remove

        public void remove()
        Remove the current element from the current iterator.
        Specified by:
        remove in interface java.util.Iterator
        Throws:
        java.lang.IllegalStateException
        java.lang.UnsupportedOperationException