Package manifold.rt.api.util
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 Summary
Constructors Constructor Description AbstractIterator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidcomputeNext()Computes the next item in the iterator.protected voiddone()Sets the state to done so that the iteration terminates.booleanhasNext()Tnext()protected voidsetNext(T value)Sets the next value in the iteration, called from the [computeNext] function-
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, remove
-
-
-
-
Method Detail
-
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
-
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.
-
-