net.sf.molae.pipe.binop
Class PermutedFunction<S1,S2,T>

java.lang.Object
  extended by net.sf.molae.pipe.binop.AbstractBinaryFunction<S1,S2,T>
      extended by net.sf.molae.pipe.binop.PermutedFunction<S1,S2,T>
All Implemented Interfaces:
BinaryFunction<S1,S2,T>

public class PermutedFunction<S1,S2,T>
extends AbstractBinaryFunction<S1,S2,T>

A binary function, that performs the same calculation as the base operation after exchanging the two operands.


Constructor Summary
PermutedFunction(AbstractBinaryFunction<S2,S1,T> base)
          Constructs a new PermutedFunction object.
PermutedFunction(AbstractBinaryFunction<S2,S1,T> base, String name, boolean hasRightIdentityElements, boolean hasLeftSinks)
          Constructs a new PermutedFunction object.
 
Method Summary
 T compute(S1 arg1, S2 arg2)
          Performs a computation on the specified arguments and returns the result of that computation.
protected  boolean isAnIdentityElement(Object obj)
          Tests if the specified object is an identity element in at least one function of the circle.
protected  boolean isASink(Object obj)
          Tests if the specified object is a sink in at least one function of the circle.
 
Methods inherited from class net.sf.molae.pipe.binop.AbstractBinaryFunction
getFirstInverse, getPermuted, isAssociative, isLeftSink, isRightIdentityElement, setFirstInverse, setPermuted, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PermutedFunction

public PermutedFunction(AbstractBinaryFunction<S2,S1,T> base,
                        String name,
                        boolean hasRightIdentityElements,
                        boolean hasLeftSinks)
Constructs a new PermutedFunction object.

Parameters:
base - the base function
name - the result of the AbstractBinaryFunction.toString() method
hasRightIdentityElements - specifies if this method has one or more right identity elements.
hasLeftSinks - specifies if this method has one or more left sinks.
Throws:
NullPointerException - base is null

PermutedFunction

public PermutedFunction(AbstractBinaryFunction<S2,S1,T> base)
Constructs a new PermutedFunction object.

Parameters:
base - the base function
Method Detail

compute

public T compute(S1 arg1,
                 S2 arg2)
Description copied from interface: BinaryFunction
Performs a computation on the specified arguments and returns the result of that computation.

Specified by:
compute in interface BinaryFunction<S1,S2,T>
Specified by:
compute in class AbstractBinaryFunction<S1,S2,T>
Parameters:
arg1 - the first argument
arg2 - the second argument
Returns:
the result of the computation

isAnIdentityElement

protected boolean isAnIdentityElement(Object obj)
Description copied from class: AbstractBinaryFunction
Tests if the specified object is an identity element in at least one function of the circle.

Overrides:
isAnIdentityElement in class AbstractBinaryFunction<S1,S2,T>
Parameters:
obj - the candidate for an identity element
Returns:
true if the specified object is an identity element in at least one function of the circle.

isASink

protected boolean isASink(Object obj)
Description copied from class: AbstractBinaryFunction
Tests if the specified object is a sink in at least one function of the circle.

Overrides:
isASink in class AbstractBinaryFunction<S1,S2,T>
Parameters:
obj - the candidate for a sink
Returns:
true if the specified object is a sink in at least one function of the circle.