clarified signature: proper equals/hashCode;
authorwenzelm
Sat, 01 Jul 2023 16:27:34 +0200
changeset 78235 aece9a063271
parent 78234 13863eaf372a
child 78236 f3a6140fa3b1
clarified signature: proper equals/hashCode;
src/Pure/General/graph.scala
--- a/src/Pure/General/graph.scala	Fri Jun 30 16:26:03 2023 +0200
+++ b/src/Pure/General/graph.scala	Sat Jul 01 16:27:34 2023 +0200
@@ -66,7 +66,16 @@
 }
 
 
-final class Graph[Key, A] private(rep: SortedMap[Key, (A, (SortedSet[Key], SortedSet[Key]))]) {
+final class Graph[Key, A] private(
+  protected val rep: SortedMap[Key, (A, (SortedSet[Key], SortedSet[Key]))]
+) {
+  override def hashCode: Int = rep.hashCode
+  override def equals(that: Any): Boolean =
+    that match {
+      case other: Graph[_, _] => rep == other.rep
+      case _ => false
+    }
+
   type Keys = SortedSet[Key]
   type Entry = (A, (Keys, Keys))