Package diva.util

Class IteratorIterator

  • All Implemented Interfaces:
    java.util.Iterator

    public abstract class IteratorIterator
    extends IteratorAdapter
    An iterator that takes an iterator over objects that themselves produce iterators, and which iterators over the elements in the sub-iterators. To get the iterators from the objects iterated over, the method iterator() must be over-ridden to convert a given result from the top-level iterator into a sub-iterator.
    Version:
    $Id$
    Author:
    John Reekie
    • Constructor Summary

      Constructors 
      Constructor Description
      IteratorIterator​(java.util.Iterator i)
      Construct a new iterator over the contents of the given iterator.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Test if there are more elements.
      protected abstract java.util.Iterator iterator​(java.lang.Object o)
      Convert an object returned by the top-level iterator into a sub-iterator.
      java.lang.Object next()
      Return the next object.
      • 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
    • Constructor Detail

      • IteratorIterator

        public IteratorIterator​(java.util.Iterator i)
        Construct a new iterator over the contents of the given iterator.
        Parameters:
        i - The iterator
    • Method Detail

      • hasNext

        public boolean hasNext()
        Test if there are more elements. This will return false if the top-level iterator has no more elements.
        Specified by:
        hasNext in interface java.util.Iterator
        Overrides:
        hasNext in class IteratorAdapter
      • iterator

        protected abstract java.util.Iterator iterator​(java.lang.Object o)
        Convert an object returned by the top-level iterator into a sub-iterator.
      • next

        public java.lang.Object next()
                              throws java.util.NoSuchElementException
        Return the next object.
        Specified by:
        next in interface java.util.Iterator
        Overrides:
        next in class IteratorAdapter
        Returns:
        The next object
        Throws:
        java.util.NoSuchElementException