info.aduna.collections.iterators
Class LimitIterator<E>

java.lang.Object
  extended by info.aduna.iteration.CloseableIterationBase<E,X>
      extended by info.aduna.iteration.IterationWrapper<E,X>
          extended by info.aduna.iteration.LimitIteration<E,RuntimeException>
              extended by info.aduna.collections.iterators.LimitIterator<E>
All Implemented Interfaces:
CloseableIterator<E>, CloseableIteration<E,RuntimeException>, Iteration<E,RuntimeException>, Closeable, Iterator<E>

public class LimitIterator<E>
extends LimitIteration<E,RuntimeException>
implements CloseableIterator<E>

An iterator that limits the amount of elements that it returns from an underlying iterator to a fixed amount. This class returns the first limit elements from the underlying iterator and drops the rest.


Field Summary
 
Fields inherited from class info.aduna.iteration.IterationWrapper
wrappedIter
 
Fields inherited from class info.aduna.iteration.CloseableIterationBase
logger
 
Constructor Summary
LimitIterator(Iterator<? extends E> iter, int limit)
          Creates a new LimitIterator.
 
Method Summary
 
Methods inherited from class info.aduna.iteration.LimitIteration
hasNext, next
 
Methods inherited from class info.aduna.iteration.IterationWrapper
handleClose, remove
 
Methods inherited from class info.aduna.iteration.CloseableIterationBase
close, isClosed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.aduna.collections.iterators.CloseableIterator
close
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Constructor Detail

LimitIterator

public LimitIterator(Iterator<? extends E> iter,
                     int limit)
Creates a new LimitIterator.

Parameters:
iter - The underlying iterator, must not be null.
limit - The number of query answers to return, must be larger than 0.


Copyright © 1997-2008 Aduna. All Rights Reserved.