net.sf.jga.fn.algorithm
Class Find<T>

java.lang.Object
  extended by net.sf.jga.fn.UnaryFunctor<java.util.Iterator<? extends T>,FindIterator<T>>
      extended by net.sf.jga.fn.algorithm.FindIteratorFunctor<T>
          extended by net.sf.jga.fn.algorithm.Find<T>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class Find<T>
extends FindIteratorFunctor<T>

Locates values in an iteration.

Copyright © 2003 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface Find.Visitor
          Interface for classes that may interpret an Find functor.
 
Constructor Summary
Find(Equality<T> eq, T value)
          Builds a Find functor that looks for the given value, using the given Equality predicate.
Find(T value)
          Builds a Find functor that looks for the given value, using the value's equals() method.
Find(UnaryFunctor<T,java.lang.Boolean> eq)
          Builds a Find functor that looks for values for which the given predicate returns TRUE.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(Find) method, if it implements the nested Visitor interface.
 FindIterator<T> fn(java.util.Iterator<? extends T> iterator)
          Locates the first/next element that meets the given criteria.
 UnaryFunctor<T,java.lang.Boolean> getComparisonFn()
          Returns the functor used to determine if an element is the one being searched for.
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.algorithm.FindIteratorFunctor
wrap
 
Methods inherited from class net.sf.jga.fn.UnaryFunctor
bind, compose, compose, generate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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,java.lang.Boolean> eq)
Builds a Find functor that looks for values for which the given predicate returns TRUE.

Method Detail

getComparisonFn

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


fn

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

Specified by:
fn in class UnaryFunctor<java.util.Iterator<? extends T>,FindIterator<T>>
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.

accept

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

Specified by:
accept in interface Visitable
Overrides:
accept in class UnaryFunctor<java.util.Iterator<? extends T>,FindIterator<T>>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


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