DoxigAlpha

setCapacity

Grows or shrinks capacity to match usage. TODO update this and related methods to match the conventions set by ArrayList

Function parameters

Parameters

#
self:*Self
new_capacity:usize

This is a stack data structure where pointers to indexes have the same lifetime as the data structure

Functions

#
SegmentedList
This is a stack data structure where pointers to indexes have the same lifetime as the data structure

Source

Implementation

#
pub fn setCapacity(self: *Self, allocator: Allocator, new_capacity: usize) Allocator.Error!void {
    if (prealloc_item_count != 0) {
        if (new_capacity <= @as(usize, 1) << (prealloc_exp + @as(ShelfIndex, @intCast(self.dynamic_segments.len)))) {
            return self.shrinkCapacity(allocator, new_capacity);
        }
    }
    return self.growCapacity(allocator, new_capacity);
}