mirror of
https://github.com/ziglang/zig.git
synced 2026-01-04 12:33:19 +00:00
std: fix HashMap.clearRetainingCapacity
This commit is contained in:
parent
b6350a2b3f
commit
1aec406311
@ -428,7 +428,7 @@ pub fn HashMapUnmanaged(
|
||||
if (self.metadata) |_| {
|
||||
self.initMetadatas();
|
||||
self.size = 0;
|
||||
self.available = 0;
|
||||
self.available = @truncate(u32, (self.capacity() * MaxLoadPercentage) / 100);
|
||||
}
|
||||
}
|
||||
|
||||
@ -864,6 +864,11 @@ test "std.hash_map clearRetainingCapacity" {
|
||||
expectEqual(map.get(1).?, 1);
|
||||
expectEqual(map.count(), 1);
|
||||
|
||||
map.clearRetainingCapacity();
|
||||
map.putAssumeCapacity(1, 1);
|
||||
expectEqual(map.get(1).?, 1);
|
||||
expectEqual(map.count(), 1);
|
||||
|
||||
const cap = map.capacity();
|
||||
expect(cap > 0);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user