DoxigAlpha

appendNTimesBounded

Append a value to the list n times.

Never invalidates element pointers.

The function is inline so that a comptime-known value parameter will have better memset codegen in case it has a repeated byte pattern.

If the list lacks unused capacity for the additional items, returns error.OutOfMemory.

Function parameters

Parameters

#
self:*Self
value:T
n:usize

Deprecated.

Functions

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

Source

Implementation

#
pub inline fn appendNTimesBounded(self: *Self, value: T, n: usize) error{OutOfMemory}!void {
    const new_len = self.items.len + n;
    if (self.capacity < new_len) return error.OutOfMemory;
    @memset(self.items.ptr[self.items.len..new_len], value);
    self.items.len = new_len;
}