Class LazyIterator<T>

java.lang.Object
com.googlecode.concurrenttrees.common.LazyIterator<T>
All Implemented Interfaces:
Iterator<T>

public abstract class LazyIterator<T> extends Object implements Iterator<T>
An unmodifiable iterator which computes the next element to return only when it is requested.

This class is inspired by com.google.common.collect.AbstractIterator in Google Guava, which was written by the Google Guava Authors, in particular by Kevin Bourrillion.

  • Field Details

  • Constructor Details

    • LazyIterator

      public LazyIterator()
  • Method Details

    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<T>
    • hasNext

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

      boolean tryToComputeNext()
    • next

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

      protected final T endOfData()
      Returns:
      a dummy value which if returned by the computeNext() method, signals that there are no more elements to return
    • computeNext

      protected abstract T computeNext()
      Returns:
      The next element which the iterator should return, or the result of calling endOfData() if there are no more elements to return