public class MinMaxExpression extends Expression
| Constructor and Description |
|---|
MinMaxExpression(boolean ismin)
Constructs a min/max expression with the specified operator description.
|
MinMaxExpression(boolean ismin,
Expression lhs,
Expression rhs)
Consructs a min/max expression with the specified operator flag and the
two operand expressions.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Expression e)
Adds an operand at the end of the operand list.
|
int |
compareTo(Expression e)
Compares the min/max expression to the specified expression for order.
|
java.lang.Integer |
compareTo(int num)
Compares MinMaxExpression to an integer value.
|
static void |
defaultPrint(MinMaxExpression m,
java.io.PrintWriter o)
Prints out MIN/MAX expressions on the specified print writer.
|
boolean |
equals(java.lang.Object o)
Checks if the given object is has the same type with this expression and
its children is same with this expression's.
|
int |
hashCode(int h)
Returns cumulative hash code with the given initial value,
h. |
boolean |
isMin()
Returns true if this is a MIN expression.
|
boolean |
isNegMin()
Checks if this expression is a MIN expression having at least one operand
with negative value.
|
boolean |
isPosMax()
Checks if this expression is a MIN expression having at least one operand
with positive value.
|
Expression |
negate()
Negates the expression by switching the operator and the signs of the
operands.
|
void |
setMin(boolean ismin)
Sets the operator with the specified flag.
|
Expression |
simplify()
Simplifies a MinMaxExpression as much as possible by removing duplicates
and by matching special cases.
|
Expression |
toConditionalExpression()
Converts MinMaxExpression to an equivalent conditional expression.
|
java.lang.String |
toString()
Returns a string representation of the expression
|
clone, findExpression, getChildren, getParent, getStatement, hashCode, needsParens, print, printSelf, removeChild, setChild, setParens, setParent, setPrintMethod, swapWith, verifypublic MinMaxExpression(boolean ismin)
ismin - true for MIN, false for MAX.public MinMaxExpression(boolean ismin,
Expression lhs,
Expression rhs)
ismin - true if the operator is MIN, false otherwiselhs - the first operandrhs - the second operandjava.lang.IllegalArgumentException - if lhs or rhs is invalid.NotAnOrphanException - if lhs or rhs has a parent.public static void defaultPrint(MinMaxExpression m, java.io.PrintWriter o)
public java.lang.String toString()
ExpressiontoString in class Expressionpublic int hashCode(int h)
Expressionh.
This is intended for optimizing memory usage when computing hash code of
an expression object. Previous approach constructs a string representation
of the expression to get the hash code while this approach uses the same
algorithm as String.hashCode() without creating a string. All sub
classes of Expression have there specific implementations of this
method and Expression.hashCode() simply returns hashCode(0).public boolean isMin()
public void setMin(boolean ismin)
ismin - true for MIN, false for MAXpublic void add(Expression e)
e - the new operand to be appended.java.lang.IllegalArgumentException - if e is invalid.NotAnOrphanException - if e has a parent.public Expression negate()
public boolean isPosMax()
public boolean isNegMin()
public Expression simplify()
public int compareTo(Expression e)
compareTo in interface java.lang.Comparable<Expression>compareTo in class Expressionpublic java.lang.Integer compareTo(int num)
num - an integer valuepublic Expression toConditionalExpression()
public boolean equals(java.lang.Object o)
Expressionequals in class Expressiono - the object to be compared with.o!=null, this.getClass()==o.getClass(),
and this.children.equals(o.children) ||
this.children==o.children==null