Class FilterIterator<E>
java.lang.Object
com.twelvemonkeys.util.FilterIterator<E>
- All Implemented Interfaces:
Iterator<E>
Wraps (decorates) an
Iterator with extra functionality, to allow
element filtering. Each
element is filtered against the given Filter, and only elements
that are accepted are returned by the next method.
The optional remove operation is implemented, but may throw
UnsupportedOperationException if the underlying iterator does not
support the remove operation.
- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/util/FilterIterator.java#1 $
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceUsed to tests whether or not an element fulfills certain criteria, and hence should be accepted by the FilterIterator instance. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFilterIterator(Iterator<E> pIterator, FilterIterator.Filter<E> pFilter) Creates aFilterIteratorthat wraps theIterator. -
Method Summary
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining
-
Field Details
-
filter
-
iterator
-
next
-
current
-
-
Constructor Details
-
FilterIterator
Creates aFilterIteratorthat wraps theIterator. Each element is filtered against the givenFilter, and only elements that areaccepted are returned by thenextmethod.- Parameters:
pIterator- the iterator to filterpFilter- the filter- See Also:
-
-
Method Details
-
hasNext
-
next
-
remove
public void remove()Removes from the underlying collection the last element returned by the iterator (optional operation). This method can be called only once per call tonext. The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method.
-