org.neo4j.helpers.collection
Class LimitingIterator<T>
java.lang.Object
org.neo4j.helpers.collection.PrefetchingIterator<T>
org.neo4j.helpers.collection.LimitingIterator<T>
- Type Parameters:
T
- the type of items in this Iterator
.
- All Implemented Interfaces:
- Iterator<T>
public class LimitingIterator<T>
- extends PrefetchingIterator<T>
Limits the amount of items returned by an Iterator
.
- Author:
- Mattias Persson
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LimitingIterator
public LimitingIterator(Iterator<T> source,
int limit)
- Instantiates a new limiting iterator which iterates over
source
and if limit
items have been returned the next PrefetchingIterator.hasNext()
will return false
.
- Parameters:
source
- the source of items.limit
- the limit, i.e. the max number of items to return.
fetchNextOrNull
protected T fetchNextOrNull()
- Specified by:
fetchNextOrNull
in class PrefetchingIterator<T>
limitReached
public boolean limitReached()
- Returns:
true
if the number of items returned up to this point
is equal to the limit given in the constructor, otherwise false
.
Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.