Package repast.simphony.util.collections
Class FilteredIterator<X>
java.lang.Object
repast.simphony.util.collections.FilteredIterator<X>
An iterator that decorates another iterator with filtering capabilities based
on a specified rule. This allows for early stopping of iteration on the first
invalid entry or full traversal.
This does not support the remove operation.
- Version:
- $Revision: 1.1 $ $Date: 2005/12/21 22:25:35 $
- Author:
- Jerry Vos
-
Constructor Summary
ConstructorsConstructorDescriptionFilteredIterator
(Iterator<X> innerIterator, org.apache.commons.collections15.Predicate<X> predicate) Constructs this iterator working on the specified iterator with the specified predicate, and searching through all the iterator.FilteredIterator
(Iterator<X> innerIterator, org.apache.commons.collections15.Predicate<X> predicate, boolean scanAll) Constructs this iterator working on the specified iterator with the specified predicate. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
FilteredIterator
public FilteredIterator(Iterator<X> innerIterator, org.apache.commons.collections15.Predicate<X> predicate) Constructs this iterator working on the specified iterator with the specified predicate, and searching through all the iterator.- Parameters:
innerIterator
- the iterator to add the functionality topredicate
- the predicate that determines the validity of objects (the filtering rule)
-
FilteredIterator
public FilteredIterator(Iterator<X> innerIterator, org.apache.commons.collections15.Predicate<X> predicate, boolean scanAll) Constructs this iterator working on the specified iterator with the specified predicate.- Parameters:
innerIterator
- the iterator to add the functionality topredicate
- the predicate that determines the validity of objects (the filtering rule)
-
-
Method Details
-
next
Returns the next element in the iteration. Calling this method repeatedly until thehasNext()
method returns false will return each element in the underlying collection exactly once.- Specified by:
next
in interfaceIterator<X>
- Returns:
- the next element in the iteration.
- Throws:
NoSuchElementException
- iteration has no more elements.
-
hasNext
public boolean hasNext()Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.) -
iterator
Returns an iterator over a set of elements of type T. -
remove
public void remove()Unsupported, throws an UnsupportedOperationException.
-