LimitingIterator (Neo4j Community 1.8.RC1 API)
Date: 2012-09-07

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Neo4j Community
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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

Constructor Summary
`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`.

Method Summary
`protected T` | `fetchNextOrNull()`
`boolean` | `limitReached()`

Methods inherited from class org.neo4j.helpers.collection.PrefetchingIterator
`getPrefetchedNextOrNull, hasNext, next, remove, setPrefetchedNext`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### 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.

Method Detail

### 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`.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Neo4j Community
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.