|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.twelvemonkeys.util.FilterIterator<E>
public class FilterIterator<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.
remove operation is implemented, but may throw
UnsupportedOperationException if the underlying iterator does not
support the remove operation.
FilterIterator.Filter| Nested Class Summary | |
|---|---|
static interface |
FilterIterator.Filter<E>
Used to tests whether or not an element fulfills certain criteria, and hence should be accepted by the FilterIterator instance. |
| Field Summary | |
|---|---|
protected FilterIterator.Filter<E> |
filter
|
protected Iterator<E> |
iterator
|
| Constructor Summary | |
|---|---|
FilterIterator(Iterator<E> pIterator,
FilterIterator.Filter<E> pFilter)
Creates a FilterIterator that wraps the Iterator. |
|
| Method Summary | |
|---|---|
boolean |
hasNext()
Returns true if the iteration has more elements. |
E |
next()
Returns the next element in the iteration. |
void |
remove()
Removes from the underlying collection the last element returned by the iterator (optional operation). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final FilterIterator.Filter<E> filter
protected final Iterator<E> iterator
| Constructor Detail |
|---|
public FilterIterator(Iterator<E> pIterator,
FilterIterator.Filter<E> pFilter)
FilterIterator that wraps the Iterator. Each
element is filtered against the given Filter, and only elements
that are accepted are returned by the next method.
pIterator - the iterator to filterpFilter - the filterFilterIterator.Filter| Method Detail |
|---|
public boolean hasNext()
true if the iteration has more elements. (In other
words, returns true if next would return an element
rather than throwing an exception.)
hasNext in interface Iterator<E>true if the iterator has more elements.FilterIterator.Filter.accept(E)public E next()
next in interface Iterator<E>FilterIterator.Filter.accept(E)public void remove()
next. 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.
remove in interface Iterator<E>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||