Class LazyIterator<T>
- java.lang.Object
-
- com.googlecode.concurrenttrees.common.LazyIterator<T>
-
- All Implemented Interfaces:
java.util.Iterator<T>
public abstract class LazyIterator<T> extends java.lang.Object implements java.util.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
LazyIterator.State
-
Field Summary
Fields Modifier and Type Field Description (package private) T
next
(package private) LazyIterator.State
state
-
Constructor Summary
Constructors Constructor Description LazyIterator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract T
computeNext()
protected T
endOfData()
boolean
hasNext()
T
next()
void
remove()
(package private) boolean
tryToComputeNext()
-
-
-
Field Detail
-
next
T next
-
state
LazyIterator.State state
-
-
Method Detail
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<T>
-
hasNext
public final boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<T>
-
tryToComputeNext
boolean tryToComputeNext()
-
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
-
-