tip.util
Class ExpressionEqualitor

java.lang.Object
  extended by tip.util.ExpressionEqualitor
All Implemented Interfaces:
Equalitor<ABinopExp>

public class ExpressionEqualitor
extends Object
implements Equalitor<ABinopExp>

ExpressionEqualitor define an equality on binary expressions, such that for instance two different occurences of the binary expression a-b are regarded the same expression.

The class uses two inner classes ExpressionEquality, an instance of the QuestionAnswer interface, and ExpressionHashcode, an instance of the Answer interface, to compute the equals(ABinopExp, ABinopExp) and hashCode(ABinopExp) methods.

Author:
Johnni Winther, jw@brics.dk

Constructor Summary
ExpressionEqualitor()
           
 
Method Summary
 boolean equals(ABinopExp a, ABinopExp b)
          Returns true if the two expressions are regard as the same binary expression.
 boolean equals(Object o)
          Returns true if the object o is an instance ExpressionEqualitor.
 int hashCode()
          Returns the hashcode for this class.
 int hashCode(ABinopExp a)
          Returns a hashcode of the binary expression a consistent with the equals(ABinopExp, ABinopExp) method.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionEqualitor

public ExpressionEqualitor()
Method Detail

equals

public boolean equals(ABinopExp a,
                      ABinopExp b)
Returns true if the two expressions are regard as the same binary expression.

Specified by:
equals in interface Equalitor<ABinopExp>
Parameters:
a - the first binary expression
b - the second binary expression
Returns:
true if the two expressions are regard as the same binary expression

hashCode

public int hashCode(ABinopExp a)
Returns a hashcode of the binary expression a consistent with the equals(ABinopExp, ABinopExp) method.

Specified by:
hashCode in interface Equalitor<ABinopExp>
Parameters:
a - the binary expression in question
Returns:
the hashcode of a according to this equalitor

equals

public boolean equals(Object o)
Returns true if the object o is an instance ExpressionEqualitor. This is an approiate equality on this class as it has no state.

Overrides:
equals in class Object
Parameters:
o - the object in question
Returns:
true if o is an instance of this class

hashCode

public int hashCode()
Returns the hashcode for this class.

Overrides:
hashCode in class Object
Returns:
the hashcode for this class