net.cscott.jutil

Class FilterIterator<A,B>

public class FilterIterator<A,B> extends UnmodifiableIterator<B>

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.2 2006-10-30 19:58:05 cananian Exp $

Author: C. Scott Ananian

Nested Class Summary
static classFilterIterator.Filter<A,B>
Constructor Summary
FilterIterator(Iterator<A> i, Filter<A,B> f)
Creates a FilterIterator.
Method Summary
booleanhasNext()
Bnext()

Constructor Detail

FilterIterator

public FilterIterator(Iterator<A> i, Filter<A,B> f)
Creates a FilterIterator.

Method Detail

hasNext

public boolean hasNext()

next

public B next()
Copyright (c) 2006 C. Scott Ananian