LimitingIterator (Neo4j Community 2.1.0-M01 API)
Date: 2014-02-20

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

    Constructors
    Constructor and Description
    `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

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `limitReached()`

    - ### Methods inherited from class org.neo4j.helpers.collection.PrefetchingIterator

      `hasNext, next, peek, remove`

    - ### Methods inherited from class java.lang.Object

      `equals, 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

    - #### 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–2014 The Neo4j Graph Database Project. All rights reserved.