pub fn swapRemove(self: *Map, key: []const u8) bool self: *Mapkey: []const u8305
306
307
308
309
310
311
312 pub fn swapRemove(self: *Map, key: []const u8) bool {
assert(validateKeyForFetch(key));
const kv = self.array_hash_map.fetchSwapRemove(key) orelse return false;
const gpa = self.allocator;
gpa.free(kv.key);
gpa.free(kv.value);
return true;
}
If there is an entry with a matching key, it is deleted from the hash map. The entry is removed from the underlying array by swapping it with the last element.
Returns true if an entry was removed, false otherwise.
This invalidates the value returned by get() for this key. On Windows, asserts that
keyis valid WTF-8.