authorgravatar for nico.b.elbers@gmail.comNico Elbers <nico.b.elbers@gmail.com> 2024-12-11 17:11:45+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-11 15:21:56-05:00
log4a3800d78f8e341f90cfdd7f7038ed657952a9b1
tree1fab1891b20adbbbc462446d9973be7ff109f336
parent3670910f20b56eda41a27ed7c4bb887f870cfc5d

std.ArrayHashMap fix `eql` documentation

In cf88cf2657d721c68055a284e8c498a18639f74c the eql function provided in The context of ArrayHashMap was changed to also include the key index, but this wasn't properly updated in the documentation. Since a flat `usize` is unintuitive, I've tried to explain the function of the parameter as best I can based on the original commit. Finally, I didn't do an extensive search if this eql definition is incorrectly stated anywhere outside of these 2 spots. But I somewhat doubt an file outside of `array_hash_map` would

1 files changed, 7 insertions(+), 2 deletions(-)

lib/std/array_hash_map.zig+7-2
...@@ -80,8 +80,10 @@ pub fn ArrayHashMapWithAllocator(...@@ -80,8 +80,10 @@ pub fn ArrayHashMapWithAllocator(
80 comptime V: type,80 comptime V: type,
81 /// A namespace that provides these two functions:81 /// A namespace that provides these two functions:
82 /// * `pub fn hash(self, K) u32`82 /// * `pub fn hash(self, K) u32`
83 /// * `pub fn eql(self, K, K) bool`83 /// * `pub fn eql(self, K, K, usize) bool`
84 ///84 ///
85 /// The final `usize` in the `eql` function represents the index of the key
86 /// that's already inside the map.
85 comptime Context: type,87 comptime Context: type,
86 /// When `false`, this data structure is biased towards cheap `eql`88 /// When `false`, this data structure is biased towards cheap `eql`
87 /// functions and avoids storing each key's hash in the table. Setting89 /// functions and avoids storing each key's hash in the table. Setting
...@@ -525,7 +527,10 @@ pub fn ArrayHashMapUnmanaged(...@@ -525,7 +527,10 @@ pub fn ArrayHashMapUnmanaged(
525 comptime V: type,527 comptime V: type,
526 /// A namespace that provides these two functions:528 /// A namespace that provides these two functions:
527 /// * `pub fn hash(self, K) u32`529 /// * `pub fn hash(self, K) u32`
528 /// * `pub fn eql(self, K, K) bool`530 /// * `pub fn eql(self, K, K, usize) bool`
531 ///
532 /// The final `usize` in the `eql` function represents the index of the key
533 /// that's already inside the map.
529 comptime Context: type,534 comptime Context: type,
530 /// When `false`, this data structure is biased towards cheap `eql`535 /// When `false`, this data structure is biased towards cheap `eql`
531 /// functions and avoids storing each key's hash in the table. Setting536 /// functions and avoids storing each key's hash in the table. Setting