/** * Compares this expression with the specified expression for order. Returns a * negative integer, zero, or a positive integer as this expression is * canonical less than, equal to, or greater than the specified expression. */ @Override public int compareTo(final IExpr obj) { if (obj instanceof MethodSymbol) { return fMethod.toString().compareTo(((MethodSymbol) obj).fMethod.toString()); } return super.compareTo(obj); }
cp = 1; } else { cp = fSymbol.compareTo(((PatternSequence) obj).fSymbol);
/** * Compares this expression with the specified expression for order. Returns a negative integer, zero, or a positive integer as this * expression is canonical less than, equal to, or greater than the specified expression. */ @Override public int compareTo(final IExpr expr) { if (expr instanceof ISymbol) { // O-2 if (this == expr) { // Symbols are unique objects // Makes no sense to compare the symbol names, if they are equal return 0; } // sort lexicographically return StringX.US_COLLATOR.compare(fSymbolName, ((ISymbol) expr).getSymbolName()); } if (expr.isNot() && expr.first().isSymbol()) { int cp = compareTo(expr.first()); return cp != 0 ? cp : -1; } return ISymbol.super.compareTo(expr); }
/** * Compares this expression with the specified expression for canonical order. * Returns a negative integer, zero, or a positive integer as this expression * is canonical less than, equal to, or greater than the specified expression. */ public int compareTo(final IExpr expr) { if (expr instanceof AST) { final AST ast = (AST) expr; if ((size() > 2) && (ast.size() > 2)) { // special comparison for Times? if (head() == F.Times) { return compareToTimes((AST) expr); } else { if (ast.head() == F.Times) { return -1 * ast.compareToTimes(this); } } } return compareToAST(ast); } if (expr instanceof Symbol) { return -1 * ((Symbol) expr).compareTo(this); } return (hierarchy() - (expr).hierarchy()); }