Class AbstractIterator<E>

java.lang.Object
io.github.mmm.base.collection.AbstractIterator<E>
Type Parameters:
E - type of the elements to iterate.
All Implemented Interfaces:
Iterator<E>

public abstract class AbstractIterator<E> extends Object implements Iterator<E>
Abstract base implementation of Iterator as reusable pattern to simplify implementations of Iterator. Please carefully consider the following constraints before use:
  • Constructor Details

    • AbstractIterator

      public AbstractIterator()
  • Method Details

    • findFirst

      protected final void findFirst()
      Has to be called from the constructor after initialization of fields to find the first element.
    • findNext

      protected abstract E findNext()
      Returns:
      the next element or null if done.
    • hasNext

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

      public final E next()
      Specified by:
      next in interface Iterator<E>
    • toString

      public String toString()
      Overrides:
      toString in class Object