diff options
author | qunyanm <unknown> | 2015-04-16 11:09:24 -0700 |
---|---|---|
committer | qunyanm <unknown> | 2015-04-16 11:09:24 -0700 |
commit | cfb9f6a3c00d4943a3bc7248a873b643746e0d24 (patch) | |
tree | 3cbb25ca94f8678c35d6a916c3647ee7e8beefcf /Binaries | |
parent | d95b2c8dd46bb52c6c84f2b764d3e6211b403346 (diff) |
Change GetHashCode for Set, MultiSet and Map
Diffstat (limited to 'Binaries')
-rw-r--r-- | Binaries/DafnyRuntime.cs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/Binaries/DafnyRuntime.cs b/Binaries/DafnyRuntime.cs index a682422a..2a553c81 100644 --- a/Binaries/DafnyRuntime.cs +++ b/Binaries/DafnyRuntime.cs @@ -75,7 +75,11 @@ namespace Dafny return other is Set<T> && Equals((Set<T>)other);
}
public override int GetHashCode() {
- return dict.GetHashCode();
+ var hashCode = 0;
+ foreach (var t in dict.Keys) {
+ hashCode = (hashCode << 3) | (hashCode >> 29) ^ t.GetHashCode();
+ }
+ return hashCode;
}
public override string ToString() {
var s = "{";
@@ -228,7 +232,12 @@ namespace Dafny return other is MultiSet<T> && Equals((MultiSet<T>)other);
}
public override int GetHashCode() {
- return dict.GetHashCode();
+ var hashCode = 0;
+ foreach (var kv in dict) {
+ hashCode = (hashCode << 3) | (hashCode >> 29) ^ kv.Key.GetHashCode();
+ hashCode = (hashCode << 3) | (hashCode >> 29) ^ kv.Value.GetHashCode();
+ }
+ return hashCode;
}
public override string ToString() {
var s = "multiset{";
@@ -392,7 +401,12 @@ namespace Dafny return other is Map<U, V> && Equals((Map<U, V>)other);
}
public override int GetHashCode() {
- return dict.GetHashCode();
+ var hashCode = 0;
+ foreach (var kv in dict) {
+ hashCode = (hashCode << 3) | (hashCode >> 29) ^ kv.Key.GetHashCode();
+ hashCode = (hashCode << 3) | (hashCode >> 29) ^ kv.Value.GetHashCode();
+ }
+ return hashCode;
}
public override string ToString() {
var s = "map[";
|