com.googlecode.concurrenttrees.common
Class LazyIterator<T>

java.lang.Object
  extended by 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.

Author:
Niall Gallagher

Constructor Summary
LazyIterator()
           
 
Method Summary
protected abstract  T computeNext()
           
protected  T endOfData()
           
 boolean hasNext()
           
 T next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyIterator

public LazyIterator()
Method Detail

remove

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

hasNext

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

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


Copyright © 2013. All Rights Reserved.