Interface JxnCloneableAlgebra

  • All Known Implementing Classes:
    MyFractionAlgebra

    public interface JxnCloneableAlgebra
    Indicates that the algebra requires cloning of the left side operand and implements a cloneThis() method.
    Note: The following is relevant only if you want to implement your own algebra class.

    If the algebra implements the operation opndLeft op opndRght as opndLeft.op(opndRght) and the implemented instance method op modifies the instance opndLeft, the left side operand opndLeft in the expression opndLeft op opndRght is cloned internally using opndLeft.cloneThis() before calling the operator method to avoid an unintended modification of opndLeft. The operator method is not necessarily required by JXN to modify the instance (it is sufficient, that the operator method returns the result) but saves memory and processing time, if the algebra objects are large. If the operator methods of a class like e.g. → java.math.BigInteger or Commons MathBigFraction do not modify the left side operand the class can be used in JXN arithmetic expressions without the implementation of this interface.
    See Also:
    user defined algebra
    • Method Detail

      • cloneThis

        JxnCloneableAlgebra cloneThis()
        Called internally. Required to avoid overwriting the left side operand opndLeft in opndLeft op opndRght, if op is implemented as opndLeft.op(opndRght) and the instance method op modifies the instance.
        Returns:
        copy of this instance