java.lang.Object
Util.Collections.UnmodifiableIterator
Util.Collections.FilterIterator
- All Implemented Interfaces:
- java.util.Iterator
- public class FilterIterator
- extends UnmodifiableIterator
- implements java.util.Iterator
A 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.
- Version:
- $Id: FilterIterator.java,v 1.1 2003/03/05 08:26:27 joewhaley Exp $
|
Method Summary |
private void |
advance()
|
boolean |
hasNext()
Tests whether there are elements remaining in the collection. |
java.lang.Object |
next()
Obtain the next element in the collection. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
i
java.util.Iterator i
f
FilterIterator.Filter f
next
private java.lang.Object next
done
private boolean done
FilterIterator
public FilterIterator(java.util.Iterator i,
FilterIterator.Filter f)
- Creates a
FilterIterator.
advance
private void advance()
next
public java.lang.Object next()
- Description copied from interface:
java.util.Iterator
- Obtain the next element in the collection.
- Specified by:
next in interface java.util.Iterator- Specified by:
next in class UnmodifiableIterator
hasNext
public boolean hasNext()
- Description copied from interface:
java.util.Iterator
- Tests whether there are elements remaining in the collection. In other
words, calling
next() will not throw an exception.
- Specified by:
hasNext in interface java.util.Iterator- Specified by:
hasNext in class UnmodifiableIterator