From 7ba58388c2456e6b8c0d584352d468694791be2f Mon Sep 17 00:00:00 2001 From: mdb Date: Sat, 30 Nov 2002 04:09:13 +0000 Subject: [PATCH] Implemented hashCode() and equals() appropriately. git-svn-id: https://samskivert.googlecode.com/svn/trunk@954 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/util/IntTuple.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/IntTuple.java b/projects/samskivert/src/java/com/samskivert/util/IntTuple.java index 01a5e4a7..006200c5 100644 --- a/projects/samskivert/src/java/com/samskivert/util/IntTuple.java +++ b/projects/samskivert/src/java/com/samskivert/util/IntTuple.java @@ -1,5 +1,5 @@ // -// $Id: IntTuple.java,v 1.1 2001/10/15 18:08:47 mdb Exp $ +// $Id: IntTuple.java,v 1.2 2002/11/30 04:09:13 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -43,6 +43,29 @@ public class IntTuple { } + /** + * Returns the combined hashcode of the two elements. + */ + public int hashCode () + { + return left ^ right; + } + + /** + * A tuple is equal to another tuple if the left and right elements + * are equal to the left and right elements (respectively) of the + * other tuple. + */ + public boolean equals (Object other) + { + if (other instanceof IntTuple) { + IntTuple to = (IntTuple)other; + return (left == to.left && right == to.right); + } else { + return false; + } + } + public String toString () { return "[left=" + left + ", right=" + right + "]";