DoxigAlpha

insert

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 append. This operation is O(N). Invalidates element pointers if additional memory is needed. 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 insert(self: *Self, gpa: Allocator, i: usize, item: T) Allocator.Error!void {
    const dst = try self.addManyAt(gpa, i, 1);
    dst[0] = item;
}