Package overit.geocall.util
Class IteratorFilter<T>
java.lang.Object
overit.geocall.util.IteratorFilter<T>
- All Implemented Interfaces:
Iterator<T>
An IteratorFilter is used to filter Objects in an Iterator
and present them as a new Iterator.
The filter is initialised with a Predicate; only Objects for which
the predicate p.valid(Object o) returns true
will be passed on, other object will be left out.
The next object from the original
iterator will be only accessed with a call to the
next() method of this IteratorFilter.
The IteratorFilter does not allow removal of objects.
Example:
Example:
..
Iterator it = someSetOfStrings.iterator();
Predicate p = new Predicate() {
public boolean valid(Object o) {
return ((String)o).startsWith("a");
}
};
Iterator filteredIt = new IteratorFilter(it, p);
..
-
Constructor Details
-
IteratorFilter
- Parameters:
i- The Iterator to filterp- The Predicate
-
-
Method Details