net.sf.jga.fn.algorithm

Class Find<T>

public class Find<T> extends AbstractUnaryFunctor<Iterator<? extends T>,FindIterator<T>> implements Serializable

Locates values in an iteration.

Copyright © 2003 David A. Hall

Author: David A. Hall

Nested Class Summary
interfaceFind.Visitor
Interface for classes that may interpret an Find functor.
Constructor Summary
Find(T value)
Builds a Find functor that looks for the given value, using the value's equals() method.
Find(Equality<T> eq, T value)
Builds a Find functor that looks for the given value, using the given Equality predicate.
Find(UnaryFunctor<T,Boolean> eq)
Builds a Find functor that looks for values for which the given predicate returns TRUE.
Method Summary
voidaccept(Visitor v)
Calls the Visitor's visit(Find) method, if it implements the nested Visitor interface.
FindIterator<T>fn(Iterator<? extends T> iterator)
Locates the first/next element that meets the given criteria.
UnaryFunctor<T,Boolean>getComparisonFn()
Returns the functor used to determine if an element is the one being searched for.
StringtoString()

Constructor Detail

Find

public Find(T value)
Builds a Find functor that looks for the given value, using the value's equals() method.

Find

public Find(Equality<T> eq, T value)
Builds a Find functor that looks for the given value, using the given Equality predicate.

Find

public Find(UnaryFunctor<T,Boolean> eq)
Builds a Find functor that looks for values for which the given predicate returns TRUE.

Method Detail

accept

public void accept(Visitor v)
Calls the Visitor's visit(Find) method, if it implements the nested Visitor interface.

fn

public FindIterator<T> fn(Iterator<? extends T> iterator)
Locates the first/next element that meets the given criteria.

Returns: an Iterator whose next() [if it hasNext()] will return an element that meets the given criteria. If no such element exists, then the returned iterator's hasNext() is false.

getComparisonFn

public UnaryFunctor<T,Boolean> getComparisonFn()
Returns the functor used to determine if an element is the one being searched for.

toString

public String toString()