DoxigAlpha

insertAssumeCapacity

Insert item at index i. Moves list[i .. list.len] to higher indices to make room. If i is equal to the length of the list this operation is equivalent to appendAssumeCapacity. This operation is O(N). Asserts that there is enough capacity for the new item. Asserts that the index is in bounds or equal to the length.

Function parameters

Parameters

#
self:*Self
i:usize
item:T

Deprecated.

Functions

#
Managed
Deprecated.
AlignedManaged
Deprecated.
Aligned
A contiguous, growable list of arbitrarily aligned items in memory.

Source

Implementation

#
pub fn insertAssumeCapacity(self: *Self, i: usize, item: T) void {
    assert(self.items.len < self.capacity);
    self.items.len += 1;

    @memmove(self.items[i + 1 .. self.items.len], self.items[i .. self.items.len - 1]);
    self.items[i] = item;
}