com.phoenixst.collections

Class FilteredIterator

public class FilteredIterator extends Object implements Iterator

A filtered Iterator. Because this class must advance the underlying Iterator to correctly implement hasNext, remove has unusual semantics. See the javadocs for that method for details.

Since: 1.0

Version: $Revision: 1.7 $

Author: Ray A. Conner

Constructor Summary
FilteredIterator(Iterator delegate, Predicate predicate)
Creates a new FilteredIterator.
Method Summary
booleanhasNext()
Objectnext()
voidremove()
Removes from the last object returned by next.
protected voidremove(Object object)
This method is called by remove if hasNext() was called after the last calls to both next() and remove() (if any) and remove() has not been called after the last call to next().

Constructor Detail

FilteredIterator

public FilteredIterator(Iterator delegate, Predicate predicate)
Creates a new FilteredIterator.

Method Detail

hasNext

public boolean hasNext()

next

public Object next()

remove

public void remove()
Removes from the last object returned by next. Because the underlying Iterator must be advanced to correctly implement FilteredIterator, this method has unusual semantics. These are the possible states that an instance of this class may be in, and how this method will behave:

Description copied from interface: Iterator
{@inheritDoc }

remove

protected void remove(Object object)
This method is called by remove if hasNext() was called after the last calls to both next() and remove() (if any) and remove() has not been called after the last call to next(). In other words, this method is called if the call sequence goes something like next(), hasNext(), remove(), which means the underlying Iterator has been advanced beyond the element to be removed. This provides an extension point for an implementation to correctly handle this case if it is capable of doing so.

This implementation throws an IllegalStateException.

See the Plexus project home, hosted by SourceForge.
Copyright B) 1994-2006, by Phoenix Software Technologists, Inc. and others. All Rights Reserved. Use is subject to license terms.