Package org.projog.core.math
Class NumericTermComparator
- java.lang.Object
-
- org.projog.core.math.NumericTermComparator
-
public final class NumericTermComparator extends java.lang.ObjectProvides methods for comparing instances ofNumeric.
-
-
Field Summary
Fields Modifier and Type Field Description static NumericTermComparatorNUMERIC_TERM_COMPARATORSingleton instance
-
Constructor Summary
Constructors Modifier Constructor Description privateNumericTermComparator()Private constructor to force use ofNUMERIC_TERM_COMPARATOR
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(Numeric n1, Numeric n2)Compares two arguments, representingNumericterms, for order.intcompare(Term t1, Term t2, ArithmeticOperators operators)Compares the two arguments, representing arithmetic expressions, for order.
-
-
-
Field Detail
-
NUMERIC_TERM_COMPARATOR
public static final NumericTermComparator NUMERIC_TERM_COMPARATOR
Singleton instance
-
-
Constructor Detail
-
NumericTermComparator
private NumericTermComparator()
Private constructor to force use ofNUMERIC_TERM_COMPARATOR
-
-
Method Detail
-
compare
public int compare(Term t1, Term t2, ArithmeticOperators operators)
Compares the two arguments, representing arithmetic expressions, for order.Returns a negative integer, zero, or a positive integer as the numeric value represented by the first argument is less than, equal to, or greater than the second.
Unlike
compare(Numeric, Numeric)this method will work for arguments that represent arithmetic expressions (e.g. aStructureof the form+(1,2)) as well asNumericterms.- Parameters:
t1- the first term to be comparedt2- the second term to be compared- Returns:
- a negative integer, zero, or a positive integer as the first term is less than, equal to, or greater than the second
- Throws:
ProjogException- if either argument does not represent an arithmetic expression- See Also:
compare(Numeric, Numeric),ArithmeticOperators.getNumeric(Term)
-
compare
public int compare(Numeric n1, Numeric n2)
Compares two arguments, representingNumericterms, for order.Returns a negative integer, zero, or a positive integer as the numeric value represented by the first argument is less than, equal to, or greater than the second.
- Parameters:
n1- the first term to be comparedn2- the second term to be compared- Returns:
- a negative integer, zero, or a positive integer as the first term is less than, equal to, or greater than the second
- See Also:
compare(Term, Term, ArithmeticOperators)
-
-