public abstract class PrefetchingIterator<T> extends Object implements Iterator<T>
hasNext()
method will look up the next object and
cache it with setPrefetchedNext(Object)
. The cached object is
then set to null
in next()
. So you only have to implement
one method, fetchNextOrNull
which returns null
when the
iteration has reached the end, and you're done.Constructor and Description |
---|
PrefetchingIterator() |
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Tries to fetch the next item and caches it so that consecutive calls
(w/o an intermediate call to
next() will remember it and won't
try to fetch it again. |
T |
next()
Uses
hasNext() to try to fetch the next item and returns it
if found, otherwise it throws a NoSuchElementException . |
void |
remove() |
public boolean hasNext()
next()
will remember it and won't
try to fetch it again.public T next()
hasNext()
to try to fetch the next item and returns it
if found, otherwise it throws a NoSuchElementException
.next
in interface Iterator<T>
NoSuchElementException
if there's no more items to return.Copyright © 2002–2013 The Neo4j Graph Database Project. All rights reserved.