public class FilterIterator<A,B> extends UnmodifiableIterator<B>
FilterIterator filters and maps a source
Iterator to generate a new one.
Note that this implementation reads one element ahead, so if the
Filter changes for an object 'o' between the time that is read
(when next() is called, returning the object preceding 'o', and
checking that 'o' satisfies the current Filter) and the time when
hasNext() is called, 'o' will still be returned, regardless of what
Filter.isElement(o) returns. Thus, it is recommended that only
Filters which remain consistent throughout the iteration be used.| Modifier and Type | Class and Description |
|---|---|
static class |
FilterIterator.Filter<A,B> |
| Constructor and Description |
|---|
FilterIterator(java.util.Iterator<A> i,
FilterIterator.Filter<A,B> f)
Creates a
FilterIterator. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext()
Returns
true if the iteration has more elements. |
B |
next()
Returns the next element in the iteration.
|
proxy, removepublic FilterIterator(java.util.Iterator<A> i, FilterIterator.Filter<A,B> f)
FilterIterator.public B next()
UnmodifiableIteratornext in interface java.util.Iterator<B>next in class UnmodifiableIterator<B>public boolean hasNext()
UnmodifiableIteratortrue if the iteration has more elements.hasNext in interface java.util.Iterator<B>hasNext in class UnmodifiableIterator<B>true if the iterator has more elements.Copyright (c) 2006 C. Scott Ananian