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(...@@ -413,10 +413,15 @@ pub fn HashMap(
413 /// If there is an `Entry` with a matching key, it is deleted from413 /// If there is an `Entry` with a matching key, it is deleted from
414 /// the hash map, and this function returns true. Otherwise this414 /// the hash map, and this function returns true. Otherwise this
415 /// function returns false.415 /// function returns false.
416 ///
417 /// TODO: answer the question in these doc comments, does this
418 /// increase the unused capacity by one?
416 pub fn remove(self: *Self, key: K) bool {419 pub fn remove(self: *Self, key: K) bool {
417 return self.unmanaged.removeContext(key, self.ctx);420 return self.unmanaged.removeContext(key, self.ctx);
418 }421 }
419422
423 /// TODO: answer the question in these doc comments, does this
424 /// increase the unused capacity by one?
420 pub fn removeAdapted(self: *Self, key: anytype, ctx: anytype) bool {425 pub fn removeAdapted(self: *Self, key: anytype, ctx: anytype) bool {
421 return self.unmanaged.removeAdapted(key, ctx);426 return self.unmanaged.removeAdapted(key, ctx);
422 }427 }
...@@ -424,6 +429,9 @@ pub fn HashMap(...@@ -424,6 +429,9 @@ pub fn HashMap(
424 /// Delete the entry with key pointed to by key_ptr from the hash map.429 /// Delete the entry with key pointed to by key_ptr from the hash map.
425 /// key_ptr is assumed to be a valid pointer to a key that is present430 /// key_ptr is assumed to be a valid pointer to a key that is present
426 /// in the hash map.431 /// in the hash map.
432 ///
433 /// TODO: answer the question in these doc comments, does this
434 /// increase the unused capacity by one?
427 pub fn removeByPtr(self: *Self, key_ptr: *K) void {435 pub fn removeByPtr(self: *Self, key_ptr: *K) void {
428 self.unmanaged.removeByPtr(key_ptr);436 self.unmanaged.removeByPtr(key_ptr);
429 }437 }
...@@ -1225,14 +1233,23 @@ pub fn HashMapUnmanaged(...@@ -1225,14 +1233,23 @@ pub fn HashMapUnmanaged(
1225 /// If there is an `Entry` with a matching key, it is deleted from1233 /// If there is an `Entry` with a matching key, it is deleted from
1226 /// the hash map, and this function returns true. Otherwise this1234 /// the hash map, and this function returns true. Otherwise this
1227 /// function returns false.1235 /// function returns false.
1236 ///
1237 /// TODO: answer the question in these doc comments, does this
1238 /// increase the unused capacity by one?
1228 pub fn remove(self: *Self, key: K) bool {1239 pub fn remove(self: *Self, key: K) bool {
1229 if (@sizeOf(Context) != 0)1240 if (@sizeOf(Context) != 0)
1230 @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call removeContext instead.");1241 @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call removeContext instead.");
1231 return self.removeContext(key, undefined);1242 return self.removeContext(key, undefined);
1232 }1243 }
1244
1245 /// TODO: answer the question in these doc comments, does this
1246 /// increase the unused capacity by one?
1233 pub fn removeContext(self: *Self, key: K, ctx: Context) bool {1247 pub fn removeContext(self: *Self, key: K, ctx: Context) bool {
1234 return self.removeAdapted(key, ctx);1248 return self.removeAdapted(key, ctx);
1235 }1249 }
1250
1251 /// TODO: answer the question in these doc comments, does this
1252 /// increase the unused capacity by one?
1236 pub fn removeAdapted(self: *Self, key: anytype, ctx: anytype) bool {1253 pub fn removeAdapted(self: *Self, key: anytype, ctx: anytype) bool {
1237 if (self.getIndex(key, ctx)) |idx| {1254 if (self.getIndex(key, ctx)) |idx| {
1238 self.removeByIndex(idx);1255 self.removeByIndex(idx);
...@@ -1245,6 +1262,9 @@ pub fn HashMapUnmanaged(...@@ -1245,6 +1262,9 @@ pub fn HashMapUnmanaged(
1245 /// Delete the entry with key pointed to by key_ptr from the hash map.1262 /// Delete the entry with key pointed to by key_ptr from the hash map.
1246 /// key_ptr is assumed to be a valid pointer to a key that is present1263 /// key_ptr is assumed to be a valid pointer to a key that is present
1247 /// in the hash map.1264 /// in the hash map.
1265 ///
1266 /// TODO: answer the question in these doc comments, does this
1267 /// increase the unused capacity by one?
1248 pub fn removeByPtr(self: *Self, key_ptr: *K) void {1268 pub fn removeByPtr(self: *Self, key_ptr: *K) void {
1249 // TODO: replace with pointer subtraction once supported by zig1269 // TODO: replace with pointer subtraction once supported by zig
1250 // if @sizeOf(K) == 0 then there is at most one item in the hash1270 // if @sizeOf(K) == 0 then there is at most one item in the hash