altoslib/altosuilib: Fix equals methods, add hashCode
[fw/altos] / altoslib / AltosMapPathPoint.java
index 9f82f02acd42d5c3a49f0bda80213a99fdc50437..0d54744ae8b2b5532ea93ff3da64090ff039d629 100644 (file)
@@ -26,10 +26,19 @@ public class AltosMapPathPoint {
        public AltosLatLon      lat_lon;
        public int              state;
 
-       public boolean equals(AltosMapPathPoint other) {
-               if (other == null)
+       public int hashCode() {
+               return lat_lon.hashCode() ^ state;
+       }
+
+       public boolean equals(Object o) {
+               if (o == null)
                        return false;
 
+               if (!(o instanceof AltosMapPathPoint))
+                       return false;
+
+               AltosMapPathPoint other = (AltosMapPathPoint) o;
+
                return lat_lon.equals(other.lat_lon) && state == other.state;
        }