net.sf.jga.fn.arithmetic |
Provides simple arithmetic Functors for Number classes.
Implementation is provided by a set of adaptor objects that implement the
Arithmatic interface. Adaptors are provided for all standard Number classes:
the six Reference classes in the java.lang package (Byte, Short, Integer,
Long, Float, and Double) and the two classes defined in the java.math package
(BigInteger and BigDecimal).
To apply the Functors found in this package with user-defined Number
implementations, it is necessary to create and register an implementation of
Arithmetic or IntegerArithmetic. For example, assuming that a
Fraction class has been defined, support for arithmetic operations
could be provided by
public class FractionMath implements Arithmetic<Fraction> {
public Fraction plus (Fraction x, Fraction y) {
// implementation omitted
}
...
}
Before any Functors can be built using the Fraction class, it is necessary to
register the FractionMath implementation with the ArithmeticFactory.
ArithmeticFactory.register(Fraction.class, new FractionMath());
|
Java Source File Name | Type | Comment |
Arithmetic.java | Interface | Defines arithmetic operations for classes derived from Number.
An implementation of Arithmetic for classes (such as BigDecimal and
BigInteger) that provide the appropriate operations can simply map these
methods to the methods provided by the Number. |
ArithmeticFactory.java | Class | Builds and distributes implementations of the Arithmetic and
IntegerArithmetic interfaces that are available for supported Number
classes.
Copyright © 2003-2005 David A. |
ArithmeticFunctors.java | Class | Static factory methods for the functors in the Comparison package.
Copyright © 2006 David A. |
Average.java | Class | Averages numeric values in an iteration.
Copyright © 2005 David A. |
BigIntMath.java | Class | Provides Arithmetic implementation for BigIntegers
Copyright © 2003-2005 David A. |
BitwiseAnd.java | Class | Binary Functor that returns the bitwise and of its two arguments
Copyright © 2005 David A. |
BitwiseNot.java | Class | Unary Functor that returns the bitwise not of its argument
Copyright © 2005 David A. |
BitwiseOr.java | Class | Binary Functor that returns the bitwise or of its two arguments
Copyright © 2005 David A. |
BitwiseXor.java | Class | Binary Functor that returns the bitwise xor of its two arguments
Copyright © 2005 David A. |
ByteMath.java | Class | Provides Arithmetic implementation for Bytes
Copyright © 2003-2005 David A. |
DecimalMath.java | Class | Provides Arithmetic implementation for BigDecimals
Copyright © 2003-2005 David A. |
Divides.java | Class | Returns the quotient of two numeric arguments.
Copyright © 2003-2005 David A. |
DoubleMath.java | Class | |
FloatMath.java | Class | |
IntegerArithmetic.java | Interface | Defines arithmetic operations appropriate for Integral Numbers.
An implementation of IntegerArithmetic for classes (such as
BigInteger) that provide the appropriate operations can simply map these
methods to the methods provided by the Number. |
IntegerMath.java | Class | |
LongMath.java | Class | Provides an implementation if IntegerArithmetic for Longs
Copyright © 2003-2005 David A. |
Minus.java | Class | Returns the difference of two numeric arguments.
Copyright © 2003-2005 David A. |
Modulus.java | Class | Returns the remainder of the division of two integral arguments.
Copyright © 2003-2005 David A. |
Multiplies.java | Class | Returns the product of two numeric arguments.
Copyright © 2003-2005 David A. |
Negate.java | Class | Returns the negative of its numeric argument.
Copyright © 2003-2005 David A. |
Plus.java | Class | Returns the sum of two numeric arguments.
Copyright © 2003-2005 David A. |
ShiftLeft.java | Class | Returns the first argument shifted left by the number of places given in the
second argument.
Copyright © 2003-2005 David A. |
ShiftRight.java | Class | Returns the first argument shifted right by the number of places given in the
second argument.
Copyright © 2003-2005 David A. |
ShortMath.java | Class | Provides Arithmetic implementation for Shorts
Copyright © 2003-2005 David A. |
UnsignedShiftRight.java | Class | Returns the first argument shifted right by the number of places given in the
second argument.
Copyright © 2003-2005 David A. |
ValueOf.java | Class | Returns the value of its numeric argument, converted to the approprate
class.
Copyright © 2004-2005 David A. |