net.sf.molae.pipe.binop
Interface BinaryFunction<S1,S2,T>

All Known Implementing Classes:
AbstractBinaryFunction, ConstantBinaryFunction, Max, Min, PermutedFunction, SymmetricBinaryFunction

public interface BinaryFunction<S1,S2,T>

A binary function is a function that takes two arguments.


Method Summary
 T compute(S1 arg1, S2 arg2)
          Performs a computation on the specified arguments and returns the result of that computation.
 BinaryFunction<T,S1,S2> getFirstInverse()
          Returns the first inverse of this function.
 BinaryFunction<S2,S1,T> getPermuted()
          Returns the permuted function of this function.
 boolean isAssociative()
          Indicates if this function is associative.
 boolean isLeftSink(Object obj)
          Tests if the specified element is a left sink of this function.
 boolean isRightIdentityElement(Object obj)
          Tests if the specified element is a right identity element of this function.
 

Method Detail

compute

T compute(S1 arg1,
          S2 arg2)
Performs a computation on the specified arguments and returns the result of that computation.

Parameters:
arg1 - the first argument
arg2 - the second argument
Returns:
the result of the computation
Throws:
IllegalArgumentException - Some aspect of either argument prevents it from being computed.
ClassCastException - if the class of either argument is not accepted by this function.
NullPointerException - if one of the or both arguments are null and the computation does not allow null values.

getPermuted

BinaryFunction<S2,S1,T> getPermuted()
Returns the permuted function of this function. The permuted function is a binary function, that performs the same calculation as this function after exchanging the two operands.

Formally, for all a and b where compute is defined:

 compute(a,b).equals(getPermuted().compute(b,a))
 
If the implementing function is commutative, it is expected that equals(getPermuted()) returns true.

Returns:
the permuted function of this function

getFirstInverse

BinaryFunction<T,S1,S2> getFirstInverse()
Returns the first inverse of this function. The first inverse is a binary function, so that the second operand can be recalculated with the first operand and the result of this function.

Formally, for all a and b where the implementing function is defined:

 compute(a,b).equals(c) ⇔ getFirstInverse().compute(c,a).equals(b)
 

Returns:
the first inverse function of this function null if the first inverse function does not exist or is not defined.

isAssociative

boolean isAssociative()
Indicates if this function is associative. More formally: It returns true if for two objects a and b: compute(a,compute(b,c)).equals(compute(compute(a,b),c)

It is not required that this method returns true, if the method is associative, so if no statement about associativity can be made, false is returned.

Returns:
true if this function is associative.

isRightIdentityElement

boolean isRightIdentityElement(Object obj)
Tests if the specified element is a right identity element of this function. A right identitiy element e fulfils for every object a where compute is defined: a.equals(compute(a, e)).

It is not required that this method returns true, if the specified object is a right identity element, so if no statement can be made, false is returned.

Parameters:
obj - the candidate for a right identity element
Returns:
true if the specified object is a right identity element of this function.

isLeftSink

boolean isLeftSink(Object obj)
Tests if the specified element is a left sink of this function. A left sink sfulfils for every object a where compute is defined: s.equals(compute(s, a)).

It is not required that this method returns true, if the specified object is a left sink, so if no statement can be made, false is returned.

Parameters:
obj - the candidate for a left sink
Returns:
true if the specified object is a left sink of this function.