Package util
Class EfficientIterator<T>
java.lang.Object
util.EfficientIterator<T>
- All Implemented Interfaces:
java.util.Iterator<T>
- Direct Known Subclasses:
CameraIterator
,GeometryList.GeometriesIterator
public abstract class EfficientIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>
Provides a framework to implement iterators without having to worry about executing hasNext() twice per iteration.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description EfficientIterator()
-
Method Summary
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
-
Field Details
-
hasNext
protected boolean hasNextA flag indicating whether there are more elements to iterate over. This flag should be set to false by thesetNext()
method once there are no more elements. -
next
The next element to iterate over. This element should be set by thesetNext()
method and must also be initialised by constructors of derived classes.
-
-
Constructor Details
-
EfficientIterator
public EfficientIterator()
-
-
Method Details
-
hasNext
public final boolean hasNext()- Specified by:
hasNext
in interfacejava.util.Iterator<T>
-
next
- Specified by:
next
in interfacejava.util.Iterator<T>
-
setNext
protected abstract void setNext()This method should set the values of the fieldsnext
andhasNext
. Each subsequent call to this method should set next to the subsequent element of the iterable. If there are more elements, thennext
should be set to the next element that is to be returned bynext()
. Otherwise,hasNext
should be set to false (the value ofnaxt
is irrelevant in this case). This method may be used by the derived constructors to set the values ofnext
initially in preperation for the first iteration.
-