diff options
| author | Rocknest <35231115+Rocknest@users.noreply.github.com> | 2019-10-17 01:57:29 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-17 01:57:29 +0300 |
| commit | 40d53a7bc5ef18607266790e99fa693ba4344645 (patch) | |
| tree | 7e124a713889646e4e55c77e5d70d621fc572e6e /lib/std/hash_map.zig | |
| parent | c95a9e978582ca96bf5462c6bfdd40b934e9ba92 (diff) | |
| parent | 700bb19a9053e236df6a9f15d435c427391e3ecf (diff) | |
| download | zig-40d53a7bc5ef18607266790e99fa693ba4344645.tar.gz zig-40d53a7bc5ef18607266790e99fa693ba4344645.zip | |
Merge branch 'master' into docs-local
Diffstat (limited to 'lib/std/hash_map.zig')
| -rw-r--r-- | lib/std/hash_map.zig | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 4ffe88067b..7c872de5ca 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -36,7 +36,8 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3 size: usize, max_distance_from_start_index: usize, allocator: *Allocator, - // this is used to detect bugs where a hashtable is edited while an iterator is running. + + /// This is used to detect bugs where a hashtable is edited while an iterator is running. modification_count: debug_u32, const Self = @This(); @@ -550,3 +551,13 @@ pub fn getAutoEqlFn(comptime K: type) (fn (K, K) bool) { } }.eql; } + +pub fn getAutoHashStratFn(comptime K: type, comptime strategy: std.hash.Strategy) (fn (K) u32) { + return struct { + fn hash(key: K) u32 { + var hasher = Wyhash.init(0); + std.hash.autoHashStrat(&hasher, key, strategy); + return @truncate(u32, hasher.final()); + } + }.hash; +} |
