/**
  * Flatten an expression with respect to an associative operator: for example the expression (a+b)
  * + (c+d) becomes list(a,b,c,d), with the list in canonical order (sorted by hashCode)
  *
  * @param list a list provided by the caller to contain the result
  * @return the list of expressions
  */
 private List flattenExpression(List list) {
   if (operand0 instanceof BinaryExpression
       && ((BinaryExpression) operand0).operator == operator) {
     ((BinaryExpression) operand0).flattenExpression(list);
   } else {
     int h = operand0.hashCode();
     list.add(operand0);
     int i = list.size() - 1;
     while (i > 0 && h > list.get(i - 1).hashCode()) {
       list.set(i, list.get(i - 1));
       list.set(i - 1, operand0);
       i--;
     }
   }
   if (operand1 instanceof BinaryExpression
       && ((BinaryExpression) operand1).operator == operator) {
     ((BinaryExpression) operand1).flattenExpression(list);
   } else {
     int h = operand1.hashCode();
     list.add(operand1);
     int i = list.size() - 1;
     while (i > 0 && h > list.get(i - 1).hashCode()) {
       list.set(i, list.get(i - 1));
       list.set(i - 1, operand1);
       i--;
     }
   }
   return list;
 }
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((lhs == null) ? 0 : lhs.hashCode());
   result = prime * result + ((op == null) ? 0 : op.hashCode());
   result = prime * result + ((rhs == null) ? 0 : rhs.hashCode());
   return result;
 }
Beispiel #3
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + expression.hashCode();
   return result;
 }
 @Override
 public int hashCode() {
   int result = owner != null ? owner.hashCode() : 0;
   result = 31 * result + (methodName != null ? methodName.hashCode() : 0);
   result = 31 * result + (arguments != null ? arguments.hashCode() : 0);
   return result;
 }
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((expression == null) ? 0 : expression.hashCode());
   result = prime * result + (increment ? 1231 : 1237);
   return result;
 }
Beispiel #6
0
 /**
  * Returns a hash code value for java hash structures.
  *
  * @return A hash code for this object.
  */
 public int hashCode() {
   return object.hashCode() + name.hashCode();
 }
Beispiel #7
0
 protected final int calcHashCode() {
   return exp.hashCode();
 }
Beispiel #8
0
 protected UnaryExp(Expression exp) {
   super(exp.hashCode());
   this.exp = exp;
 }
 @Override
 public int hashCode() {
   return value.hashCode();
 }
Beispiel #10
0
 @Override
 public int hashCode() {
   int result = operand.hashCode();
   result = 31 * result + operator.hashCode();
   return result;
 }
Beispiel #11
0
 @Override
 public int hashCode() {
   return expression.hashCode();
 }
 /**
  * Get a hashCode for comparing two expressions. Note that this hashcode gives the same result for
  * (A op B) and for (B op A), whether or not the operator is commutative.
  */
 public int hashCode() {
   // Ensure that an operator and its inverse get the same hash code,
   // so that (A lt B) has the same hash code as (B gt A)
   int op = Math.min(operator, Token.inverse(operator));
   return ("BinaryExpression " + op).hashCode() ^ operand0.hashCode() ^ operand1.hashCode();
 }