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

    Fields
    Modifier and Type Field Description
    protected boolean hasNext
    A flag indicating whether there are more elements to iterate over.
    protected T next
    The next element to iterate over.
  • Constructor Summary

    Constructors
    Constructor Description
    EfficientIterator()  
  • Method Summary

    Modifier and Type Method Description
    boolean hasNext()  
    T next()  
    protected abstract void setNext()
    This method should set the values of the fields next and hasNext.

    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 hasNext
      A flag indicating whether there are more elements to iterate over. This flag should be set to false by the setNext() method once there are no more elements.
    • next

      protected T next
      The next element to iterate over. This element should be set by the setNext() 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 interface java.util.Iterator<T>
    • next

      public final T next()
      Specified by:
      next in interface java.util.Iterator<T>
    • setNext

      protected abstract void setNext()
      This method should set the values of the fields next and hasNext. Each subsequent call to this method should set next to the subsequent element of the iterable. If there are more elements, then next should be set to the next element that is to be returned by next(). Otherwise, hasNext should be set to false (the value of naxt is irrelevant in this case). This method may be used by the derived constructors to set the values of next initially in preperation for the first iteration.