authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-03 21:20:52-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-06 14:23:23-08:00
logbecd16859dbc9d6357099f660408b54d00aa18ef
treebd8fd6f5d24676d1dff315a801d8dc8ba16a3e28
parentf1717777a2ce12905f86e75a11ff6388332d6926

std.hash_map: placeholder for doc comments


1 files changed, 20 insertions(+), 0 deletions(-)

lib/std/hash_map.zig+20
......@@ -413,10 +413,15 @@ pub fn HashMap(
413413 /// If there is an `Entry` with a matching key, it is deleted from
414414 /// the hash map, and this function returns true. Otherwise this
415415 /// function returns false.
416 ///
417 /// TODO: answer the question in these doc comments, does this
418 /// increase the unused capacity by one?
416419 pub fn remove(self: *Self, key: K) bool {
417420 return self.unmanaged.removeContext(key, self.ctx);
418421 }
419422
423 /// TODO: answer the question in these doc comments, does this
424 /// increase the unused capacity by one?
420425 pub fn removeAdapted(self: *Self, key: anytype, ctx: anytype) bool {
421426 return self.unmanaged.removeAdapted(key, ctx);
422427 }
......@@ -424,6 +429,9 @@ pub fn HashMap(
424429 /// Delete the entry with key pointed to by key_ptr from the hash map.
425430 /// key_ptr is assumed to be a valid pointer to a key that is present
426431 /// in the hash map.
432 ///
433 /// TODO: answer the question in these doc comments, does this
434 /// increase the unused capacity by one?
427435 pub fn removeByPtr(self: *Self, key_ptr: *K) void {
428436 self.unmanaged.removeByPtr(key_ptr);
429437 }
......@@ -1225,14 +1233,23 @@ pub fn HashMapUnmanaged(
12251233 /// If there is an `Entry` with a matching key, it is deleted from
12261234 /// the hash map, and this function returns true. Otherwise this
12271235 /// function returns false.
1236 ///
1237 /// TODO: answer the question in these doc comments, does this
1238 /// increase the unused capacity by one?
12281239 pub fn remove(self: *Self, key: K) bool {
12291240 if (@sizeOf(Context) != 0)
12301241 @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call removeContext instead.");
12311242 return self.removeContext(key, undefined);
12321243 }
1244
1245 /// TODO: answer the question in these doc comments, does this
1246 /// increase the unused capacity by one?
12331247 pub fn removeContext(self: *Self, key: K, ctx: Context) bool {
12341248 return self.removeAdapted(key, ctx);
12351249 }
1250
1251 /// TODO: answer the question in these doc comments, does this
1252 /// increase the unused capacity by one?
12361253 pub fn removeAdapted(self: *Self, key: anytype, ctx: anytype) bool {
12371254 if (self.getIndex(key, ctx)) |idx| {
12381255 self.removeByIndex(idx);
......@@ -1245,6 +1262,9 @@ pub fn HashMapUnmanaged(
12451262 /// Delete the entry with key pointed to by key_ptr from the hash map.
12461263 /// key_ptr is assumed to be a valid pointer to a key that is present
12471264 /// in the hash map.
1265 ///
1266 /// TODO: answer the question in these doc comments, does this
1267 /// increase the unused capacity by one?
12481268 pub fn removeByPtr(self: *Self, key_ptr: *K) void {
12491269 // TODO: replace with pointer subtraction once supported by zig
12501270 // if @sizeOf(K) == 0 then there is at most one item in the hash