Class NumericTermComparator

java.lang.Object
org.projog.core.math.NumericTermComparator

public final class NumericTermComparator extends Object
Provides methods for comparing instances of Numeric.
See Also:
  • Field Details

    • NUMERIC_TERM_COMPARATOR

      public static final NumericTermComparator NUMERIC_TERM_COMPARATOR
      Singleton instance
  • Method Details

    • 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. a compound term of the form +(1,2)) as well as Numeric terms.

      Parameters:
      t1 - the first term to be compared
      t2 - 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

      public int compare(Numeric n1, Numeric n2)
      Compares two arguments, representing Numeric terms, 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 compared
      n2 - 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: