altoslib/altosuilib: Fix equals methods, add hashCode
[fw/altos] / altoslib / AltosPointDouble.java
index 4a94067646ff29c0c2fbb1d60bf36b8fe7c504cf..45e7785e4c36eca6af585b7b4a354a229e6c61f5 100644 (file)
@@ -20,7 +20,19 @@ package org.altusmetrum.altoslib_7;
 public class AltosPointDouble {
        public double   x, y;
 
-       public boolean equals(AltosPointDouble n) {
+       public int hashCode() {
+               return new Double(x).hashCode() ^ new Double(y).hashCode();
+       }
+
+       public boolean equals(Object o) {
+               if (o == null)
+                       return false;
+
+               if (!(o instanceof AltosPointDouble))
+                       return false;
+
+               AltosPointDouble n = (AltosPointDouble) o;
+
                return n.x == x && n.y == y;
        }