/** * 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()); }