Plexus v0.13.1

com.phoenixst.collections
Class FilteredIterator

java.lang.Object
  extended by com.phoenixst.collections.FilteredIterator
All Implemented Interfaces:
Iterator
Direct Known Subclasses:
FilteredEdgeIterator, FilteredNodeIterator

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, org.apache.commons.collections.Predicate predicate)
          Creates a new FilteredIterator.
 
Method Summary
 boolean hasNext()
           
 Object next()
           
 void remove()
          Removes from the last object returned by next.
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().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteredIterator

public FilteredIterator(Iterator delegate,
                        org.apache.commons.collections.Predicate predicate)
Creates a new FilteredIterator.

Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator

next

public Object next()
Specified by:
next in interface Iterator

remove

public void remove()
Removes from the last object returned by next. Because the underlying Iterator must be advanced to correctly implement hasNext(), 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

Specified by:
remove in interface Iterator

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.


Plexus v0.13.1

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