Class NumericTermComparator

    • Field Detail

      • NUMERIC_TERM_COMPARATOR

        public static final NumericTermComparator NUMERIC_TERM_COMPARATOR
        Singleton instance
    • Constructor Detail

      • NumericTermComparator

        private NumericTermComparator()
        Private constructor to force use of NUMERIC_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. a Structure 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(Numeric, Numeric), ArithmeticOperators.getNumeric(Term)
      • 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:
        compare(Term, Term, ArithmeticOperators)