aboutsummaryrefslogtreecommitdiff
path: root/lib/std/hash_map.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-02-07 06:21:51 -0800
committerGitHub <noreply@github.com>2025-02-07 06:21:51 -0800
commit6a6e72fff820fb641aa1b00700f6835430dae72e (patch)
treeea70863e08ba9167cfe954287691cce98716d918 /lib/std/hash_map.zig
parent8ad0732954df80f0f9a0248525c2bded7e82ba27 (diff)
parentb8f5cfed457726a77082b7ffe6672b6066c0a66e (diff)
downloadzig-6a6e72fff820fb641aa1b00700f6835430dae72e.tar.gz
zig-6a6e72fff820fb641aa1b00700f6835430dae72e.zip
Merge pull request #20511 from archbirdplus
runtime page size detection rework GeneralPurposeAllocator to reduce active mapping count Allocator VTable API update
Diffstat (limited to 'lib/std/hash_map.zig')
-rw-r--r--lib/std/hash_map.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig
index 270cd1b273..1cb4bfe010 100644
--- a/lib/std/hash_map.zig
+++ b/lib/std/hash_map.zig
@@ -413,10 +413,15 @@ pub fn HashMap(
/// If there is an `Entry` with a matching key, it is deleted from
/// the hash map, and this function returns true. Otherwise this
/// function returns false.
+ ///
+ /// TODO: answer the question in these doc comments, does this
+ /// increase the unused capacity by one?
pub fn remove(self: *Self, key: K) bool {
return self.unmanaged.removeContext(key, self.ctx);
}
+ /// TODO: answer the question in these doc comments, does this
+ /// increase the unused capacity by one?
pub fn removeAdapted(self: *Self, key: anytype, ctx: anytype) bool {
return self.unmanaged.removeAdapted(key, ctx);
}
@@ -424,6 +429,9 @@ pub fn HashMap(
/// Delete the entry with key pointed to by key_ptr from the hash map.
/// key_ptr is assumed to be a valid pointer to a key that is present
/// in the hash map.
+ ///
+ /// TODO: answer the question in these doc comments, does this
+ /// increase the unused capacity by one?
pub fn removeByPtr(self: *Self, key_ptr: *K) void {
self.unmanaged.removeByPtr(key_ptr);
}
@@ -1225,14 +1233,23 @@ pub fn HashMapUnmanaged(
/// If there is an `Entry` with a matching key, it is deleted from
/// the hash map, and this function returns true. Otherwise this
/// function returns false.
+ ///
+ /// TODO: answer the question in these doc comments, does this
+ /// increase the unused capacity by one?
pub fn remove(self: *Self, key: K) bool {
if (@sizeOf(Context) != 0)
@compileError("Cannot infer context " ++ @typeName(Context) ++ ", call removeContext instead.");
return self.removeContext(key, undefined);
}
+
+ /// TODO: answer the question in these doc comments, does this
+ /// increase the unused capacity by one?
pub fn removeContext(self: *Self, key: K, ctx: Context) bool {
return self.removeAdapted(key, ctx);
}
+
+ /// TODO: answer the question in these doc comments, does this
+ /// increase the unused capacity by one?
pub fn removeAdapted(self: *Self, key: anytype, ctx: anytype) bool {
if (self.getIndex(key, ctx)) |idx| {
self.removeByIndex(idx);
@@ -1245,6 +1262,9 @@ pub fn HashMapUnmanaged(
/// Delete the entry with key pointed to by key_ptr from the hash map.
/// key_ptr is assumed to be a valid pointer to a key that is present
/// in the hash map.
+ ///
+ /// TODO: answer the question in these doc comments, does this
+ /// increase the unused capacity by one?
pub fn removeByPtr(self: *Self, key_ptr: *K) void {
// TODO: replace with pointer subtraction once supported by zig
// if @sizeOf(K) == 0 then there is at most one item in the hash