pub fn shrinkRetainingCapacityContext(self: *Self, new_len: usize, ctx: Context) void self: *Selfnew_len: usizectx: Context986
987
988
989
990
991
992
993
994
995
996
997
998
999 pub fn shrinkRetainingCapacityContext(self: *Self, new_len: usize, ctx: Context) void {
self.pointer_stability.lock();
defer self.pointer_stability.unlock();
// Remove index entries from the new length onwards.
// Explicitly choose to ONLY remove index entries and not the underlying array list
// entries as we're going to remove them in the subsequent shrink call.
if (self.index_header) |header| {
var i: usize = new_len;
while (i < self.entries.len) : (i += 1)
self.removeFromIndexByIndex(i, if (store_hash) {} else ctx, header);
}
self.entries.shrinkRetainingCapacity(new_len);
}
Shrinks the underlying
Entryarray tonew_lenelements and discards any associated index entries. Keeps capacity the same.Asserts the discarded entries remain initialized and capable of performing hash and equality checks. Any deinitialization of discarded entries must take place after calling this function.