DoxigAlpha

ensureTotalCapacity

Ensure that the dequeue can fit at least new_capacity items.

Function parameters

Parameters

#
self:*Self
new_capacity:usize

Priority Dequeue for storing generic data.

Functions

#
PriorityDequeue
Priority Dequeue for storing generic data.

Source

Implementation

#
pub fn ensureTotalCapacity(self: *Self, new_capacity: usize) !void {
    var better_capacity = self.capacity();
    if (better_capacity >= new_capacity) return;
    while (true) {
        better_capacity += better_capacity / 2 + 8;
        if (better_capacity >= new_capacity) break;
    }
    self.items = try self.allocator.realloc(self.items, better_capacity);
}