Class AbstractIterator<T>

java.lang.Object
manifold.rt.api.util.AbstractIterator<T>
All Implemented Interfaces:
Iterator<T>

public abstract class AbstractIterator<T> extends Object implements Iterator<T>
A base class to simplify implementing iterators so that implementations only have to implement [computeNext] to implement the iterator, calling [done] when the iteration is complete.
  • Constructor Details

    • AbstractIterator

      public AbstractIterator()
  • Method Details

    • computeNext

      protected abstract void computeNext()
      Computes the next item in the iterator.

      This callback method should call one of these two methods:

      * [setNext] with the next value of the iteration * [done] to indicate there are no more elements

      Failure to call either method will result in the iteration terminating with a failed state

    • hasNext

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

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

      protected void setNext(T value)
      Sets the next value in the iteration, called from the [computeNext] function
    • done

      protected void done()
      Sets the state to done so that the iteration terminates.