net.sf.jga.fn

Interface BinaryFunctor<T1,T2,R>

public interface BinaryFunctor<T1,T2,R> extends Serializable, Visitable

A Function Object that takes two arguments and returns a result. The two arguments are of type T1 and T2, and the result is of type R

Copyright © 2002 David A. Hall

Author: David A. Hall

Method Summary
UnaryFunctor<T2,R>bind1st(T1 value)
Factory method that creates a UnaryFunctor that binds a constant value to this' first argument.
UnaryFunctor<T1,R>bind2nd(T2 value)
Factory method that creates a UnaryFunctor that binds a constant value to this' second argument.
<F> UnaryFunctor<F,R>compose(UnaryFunctor<F,T1> g, UnaryFunctor<F,T2> h)
FactoryMethod that creates a UnaryFunctor that passes its argument to each of the given functors, and uses the results as the arguments to this function.
<F1,F2> BinaryFunctor<F1,F2,R>compose(BinaryFunctor<F1,F2,T1> g, BinaryFunctor<F1,F2,T2> h)
FactoryMethod that creates a BinaryFunctor that passes its argument to each of the given functors, and uses the results as the arguments to this function.
<F1,F2> BinaryFunctor<F1,F2,R>distribute(UnaryFunctor<F1,T1> g, UnaryFunctor<F2,T2> h)
FactoryMethod that creates a BinaryFunctor that passes each of its two arguments to a pair of UnaryFunctors, then uses the results as arguments to this function.
Rfn(T1 arg1, T2 arg2)
Executes the function and returns the result.

Method Detail

bind1st

public UnaryFunctor<T2,R> bind1st(T1 value)
Factory method that creates a UnaryFunctor that binds a constant value to this' first argument. Given argument x, the new functor will return fnthis(value, x)

bind2nd

public UnaryFunctor<T1,R> bind2nd(T2 value)
Factory method that creates a UnaryFunctor that binds a constant value to this' second argument. Given argument x, the new functor will return fnthis(x, value)

compose

public <F> UnaryFunctor<F,R> compose(UnaryFunctor<F,T1> g, UnaryFunctor<F,T2> h)
FactoryMethod that creates a UnaryFunctor that passes its argument to each of the given functors, and uses the results as the arguments to this function. Given argument x, the new functor will return fnthis(g(x), h(x))

compose

public <F1,F2> BinaryFunctor<F1,F2,R> compose(BinaryFunctor<F1,F2,T1> g, BinaryFunctor<F1,F2,T2> h)
FactoryMethod that creates a BinaryFunctor that passes its argument to each of the given functors, and uses the results as the arguments to this function. Given arguments x and y, the new functor will return fnthis(g(x,y), h(x,y))

distribute

public <F1,F2> BinaryFunctor<F1,F2,R> distribute(UnaryFunctor<F1,T1> g, UnaryFunctor<F2,T2> h)
FactoryMethod that creates a BinaryFunctor that passes each of its two arguments to a pair of UnaryFunctors, then uses the results as arguments to this function. Given arguments x and y, the new functor will return fnthis(g(x), h(y)). Note: this method cannot be called compose, as it is only distinct from the unary form of compose in its param types and its return type

fn

public R fn(T1 arg1, T2 arg2)
Executes the function and returns the result.