pub fn addManyAtAssumeCapacity(self: *Self, index: usize, count: usize) []T self: *Selfindex: usizecount: usize897
898
899
900
901
902
903
904
905
906
907 pub fn addManyAtAssumeCapacity(self: *Self, index: usize, count: usize) []T {
self.pointer_stability.assertUnlocked();
const new_len = self.items.len + count;
assert(self.capacity >= new_len);
const to_move = self.items[index..];
self.items.len = new_len;
@memmove(self.items[index + count ..][0..to_move.len], to_move);
const result = self.items[index..][0..count];
@memset(result, undefined);
return result;
}
Add
countnew elements at positionindex, which haveundefinedvalues. Returns a slice pointing to the newly allocated elements, which becomes invalid after variousArrayListoperations. Invalidates pre-existing pointers to elements at and afterindex. Asserts that the list has capacity for the additional items. Asserts that the index is in bounds or equal to the length.