net.sf.jga.util

Class FindIterator<T>

public class FindIterator<T> extends Object implements Iterator<T>

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

Copyright © 2003 David A. Hall

Author: David A. Hall

Constructor Summary
FindIterator(Iterator<? extends T> iter)
Method Summary
booleanfindNext(UnaryFunctor<T,Boolean> filter)
Returns true if at least one instance remaining in the iteration yields true when passed to the filter.
booleanhasNext()
Returns true if there is at least one instance remaining in the iteration.
Tnext()
voidremove()
static <T> FindIterator<T>wrapIfNecessary(Iterator<? extends T> base)
Creates a FindIterator to wrap the given iterator, if the given iterator isn't already a FindIterator

Constructor Detail

FindIterator

public FindIterator(Iterator<? extends T> iter)

Method Detail

findNext

public boolean findNext(UnaryFunctor<T,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.

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.

next

public T next()

remove

public void remove()

wrapIfNecessary

public static <T> FindIterator<T> wrapIfNecessary(Iterator<? extends T> base)
Creates a FindIterator to wrap the given iterator, if the given iterator isn't already a FindIterator