Class NestedIterator<T>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    Iterator<T>

    public class NestedIterator<T>
    extends Object
    implements Iterator<T>
    Given an iterable of iterables of T, this class simulates an iterator of T. For example, it can be used to iterate over every element in a list of lists of T.

    This implementation does not support the removal of elements.

    Author:
    Markus Kroetzsch
    • Constructor Detail

      • NestedIterator

        public NestedIterator​(Iterable<? extends Iterable<T>> iterableOfIterables)
        Constructor.
        Parameters:
        iterableOfIterables - the nested iterable to iterate over
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<T>
      • next

        public T next()
        Specified by:
        next in interface Iterator<T>
      • remove

        public void remove()
        Specified by:
        remove in interface Iterator<T>