net.sf.jga.util
Class FindIterator<T>

java.lang.Object
  extended by net.sf.jga.util.FindIterator<T>
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Iterator<T>

public class FindIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>, java.lang.Iterable<T>

Iterator that provides the ability to skip to the first/next element that meets a particular criteria.

Copyright © 2003-2005 David A. Hall

Author:
David A. Hall

Constructor Summary
FindIterator(java.util.Iterator<? extends T> iter)
          Builds a FindIterator for the given iterator.
 
Method Summary
 boolean findNext(UnaryFunctor<T,java.lang.Boolean> filter)
          Returns true if at least one instance remaining in the iteration yields true when passed to the filter.
 boolean hasNext()
          Returns true if there is at least one instance remaining in the iteration.
 java.util.Iterator<T> iterator()
           
 T next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FindIterator

public FindIterator(java.util.Iterator<? extends T> iter)
Builds a FindIterator for the given iterator.

Method Detail

findNext

public boolean findNext(UnaryFunctor<T,java.lang.Boolean> filter)
Returns true if at least one instance remaining in the iteration yields true when passed to the filter. This operation can advance the base iterator. It will not, however, advance the base iterator if it is called multiple times in succession without having retrieved the value.


iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>

hasNext

public boolean hasNext()
Returns true if there is at least one instance remaining in the iteration. This operation can advance the base iterator. It will not, however, advance the base iterator if it is called multiple times in succession without having retrieved the value.

Specified by:
hasNext in interface java.util.Iterator<T>

next

public T next()
Specified by:
next in interface java.util.Iterator<T>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<T>


Copyright © 2002-2006 David A. Hall. All Rights Reserved.