std: fix HashMap.clearRetainingCapacity
parent
f70160f89c
commit
ae6f3291c0
|
@ -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…
Reference in New Issue