diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-01-17 00:16:10 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-01-17 00:16:10 -0700 |
| commit | 44135ea84e562ae67a5eeced99566be58bffc6fc (patch) | |
| tree | fdf5e11589187137b7189e5fda128c725259e659 /lib | |
| parent | 1f65828ec6caa7697b26d9e919112aa1715b57bc (diff) | |
| parent | 8deb21c58a4e5f9f8805f6b1a2c9a1774c4a4df5 (diff) | |
| download | zig-44135ea84e562ae67a5eeced99566be58bffc6fc.tar.gz zig-44135ea84e562ae67a5eeced99566be58bffc6fc.zip | |
Merge branch 'stage2 error notes'
Closes #7555
There was still some extra work @Vexu did in that PR having to do with
adding more compile errors and notes for switch expressions, but that
can be added in a follow-up commit.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/array_hash_map.zig | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index b6478d4094..5008b3a4af 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -239,12 +239,23 @@ pub fn ArrayHashMap( return self.unmanaged.orderedRemove(key); } - /// Asserts there is an `Entry` with matching key, deletes it from the hash map, - /// and discards it. + /// TODO: deprecated: call swapRemoveAssertDiscard instead. pub fn removeAssertDiscard(self: *Self, key: K) void { return self.unmanaged.removeAssertDiscard(key); } + /// Asserts there is an `Entry` with matching key, deletes it from the hash map + /// by swapping it with the last element, and discards it. + pub fn swapRemoveAssertDiscard(self: *Self, key: K) void { + return self.unmanaged.swapRemoveAssertDiscard(key); + } + + /// Asserts there is an `Entry` with matching key, deletes it from the hash map + /// by by shifting all elements forward thereby maintaining the current ordering. + pub fn orderedRemoveAssertDiscard(self: *Self, key: K) void { + return self.unmanaged.orderedRemoveAssertDiscard(key); + } + pub fn items(self: Self) []Entry { return self.unmanaged.items(); } @@ -602,12 +613,23 @@ pub fn ArrayHashMapUnmanaged( return self.removeInternal(key, .ordered); } - /// Asserts there is an `Entry` with matching key, deletes it from the hash map, - /// and discards it. + /// TODO deprecated: call swapRemoveAssertDiscard instead. pub fn removeAssertDiscard(self: *Self, key: K) void { + return self.swapRemoveAssertDiscard(key); + } + + /// Asserts there is an `Entry` with matching key, deletes it from the hash map + /// by swapping it with the last element, and discards it. + pub fn swapRemoveAssertDiscard(self: *Self, key: K) void { assert(self.swapRemove(key) != null); } + /// Asserts there is an `Entry` with matching key, deletes it from the hash map + /// by by shifting all elements forward thereby maintaining the current ordering. + pub fn orderedRemoveAssertDiscard(self: *Self, key: K) void { + assert(self.orderedRemove(key) != null); + } + pub fn items(self: Self) []Entry { return self.entries.items; } |
