Straightened out TokenTuple equality and hash codes so token sets
[IRC.git] / Robust / src / Analysis / OwnershipAnalysis / TokenTuple.java
index 2185f273f5aca9d44e37e19918f6a980548ac516..e9d3b400f1d2ba95d2b4c0bc4b039a5470d8ed9a 100644 (file)
@@ -41,9 +41,19 @@ public class TokenTuple
        }
     }
 
-    public boolean equals( TokenTuple tt ) {
+    public boolean equals( Object o ) {
+       if( !(o instanceof TokenTuple) ) {
+           return false;
+       }
+
+       TokenTuple tt = (TokenTuple) o;
+
        return token.equals( tt.getToken() ) &&
-              arity ==      tt.getArity();
+              arity ==      tt.getArity();
+    }
+
+    public int hashCode() {
+       return token.intValue();
     }
 
     public TokenTuple copy() {
@@ -51,4 +61,18 @@ public class TokenTuple
                               isNewSummary,
                               arity );
     }
+
+    public String toString() {
+       String s = "";
+       if( isNewSummary ) {
+           s = "sum";
+       }
+
+       String t = "1";
+       if( arity == ARITY_MANY ) {
+           t = "many";
+       }
+
+       return new String( "<"+token+s+", "+t+">" );
+    }
 }