| ... | ... | @@ -639,11 +639,11 @@ pub fn HashMap( |
| 639 | 639 | return self.unmanaged.removeAdapted(key, ctx); |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | | /// Delete the entry with key pointed to by keyPtr from the hash map. |
| 643 | | /// keyPtr is assumed to be a valid pointer to a key that is present |
| 642 | /// Delete the entry with key pointed to by key_ptr from the hash map. |
| 643 | /// key_ptr is assumed to be a valid pointer to a key that is present |
| 644 | 644 | /// in the hash map. |
| 645 | | pub fn removeByPtr(self: *Self, keyPtr: *K) void { |
| 646 | | self.unmanaged.removeByPtr(keyPtr); |
| 645 | pub fn removeByPtr(self: *Self, key_ptr: *K) void { |
| 646 | self.unmanaged.removeByPtr(key_ptr); |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | /// Creates a copy of this map, using the same allocator |
| ... | ... | @@ -1433,16 +1433,16 @@ pub fn HashMapUnmanaged( |
| 1433 | 1433 | return false; |
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | | /// Delete the entry with key pointed to by keyPtr from the hash map. |
| 1437 | | /// keyPtr is assumed to be a valid pointer to a key that is present |
| 1436 | /// Delete the entry with key pointed to by key_ptr from the hash map. |
| 1437 | /// key_ptr is assumed to be a valid pointer to a key that is present |
| 1438 | 1438 | /// in the hash map. |
| 1439 | | pub fn removeByPtr(self: *Self, keyPtr: *K) void { |
| 1439 | pub fn removeByPtr(self: *Self, key_ptr: *K) void { |
| 1440 | 1440 | // TODO: replace with pointer subtraction once supported by zig |
| 1441 | 1441 | // if @sizeOf(K) == 0 then there is at most one item in the hash |
| 1442 | | // map, which is assumed to exist as keyPtr must be valid. This |
| 1442 | // map, which is assumed to exist as key_ptr must be valid. This |
| 1443 | 1443 | // item must be at index 0. |
| 1444 | 1444 | const idx = if (@sizeOf(K) > 0) |
| 1445 | | (@intFromPtr(keyPtr) - @intFromPtr(self.keys())) / @sizeOf(K) |
| 1445 | (@intFromPtr(key_ptr) - @intFromPtr(self.keys())) / @sizeOf(K) |
| 1446 | 1446 | else |
| 1447 | 1447 | 0; |
| 1448 | 1448 | |
| ... | ... | @@ -2166,10 +2166,10 @@ test "std.hash_map removeByPtr" { |
| 2166 | 2166 | |
| 2167 | 2167 | i = 0; |
| 2168 | 2168 | while (i < 10) : (i += 1) { |
| 2169 | | const keyPtr = map.getKeyPtr(i); |
| 2170 | | try testing.expect(keyPtr != null); |
| 2169 | const key_ptr = map.getKeyPtr(i); |
| 2170 | try testing.expect(key_ptr != null); |
| 2171 | 2171 | |
| 2172 | | if (keyPtr) |ptr| { |
| 2172 | if (key_ptr) |ptr| { |
| 2173 | 2173 | map.removeByPtr(ptr); |
| 2174 | 2174 | } |
| 2175 | 2175 | } |
| ... | ... | @@ -2185,10 +2185,10 @@ test "std.hash_map removeByPtr 0 sized key" { |
| 2185 | 2185 | |
| 2186 | 2186 | try testing.expect(map.count() == 1); |
| 2187 | 2187 | |
| 2188 | | const keyPtr = map.getKeyPtr(0); |
| 2189 | | try testing.expect(keyPtr != null); |
| 2188 | const key_ptr = map.getKeyPtr(0); |
| 2189 | try testing.expect(key_ptr != null); |
| 2190 | 2190 | |
| 2191 | | if (keyPtr) |ptr| { |
| 2191 | if (key_ptr) |ptr| { |
| 2192 | 2192 | map.removeByPtr(ptr); |
| 2193 | 2193 | } |
| 2194 | 2194 | |