From 5e3a64fc790fae0709c20e4df840f7cdaffe20a5 Mon Sep 17 00:00:00 2001
From: 3541 <alex@emobrien.com>
Date: Mon, 28 Sep 2020 14:24:30 +1000
Subject: [PATCH] Point: Implement hashCode

This makes Point's hashCode implementation consistent with its equals
method, and allows the use of Point as a HashMap key.
---
 src/main/java/bagel/util/Point.java | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/main/java/bagel/util/Point.java b/src/main/java/bagel/util/Point.java
index bbed007..d417837 100644
--- a/src/main/java/bagel/util/Point.java
+++ b/src/main/java/bagel/util/Point.java
@@ -1,5 +1,7 @@
 package bagel.util;
 
+import java.util.Objects;
+
 /**
  * Immutable class that represents a 2D point in space.
  */
@@ -42,6 +44,11 @@ public class Point {
         }
     }
 
+    @Override
+    public int hashCode() {
+        return Objects.hash(x, y);
+    }
+
     public double distanceTo(Point b) {
         return asVector().sub(b.asVector()).length();
     }
-- 
GitLab