pub fn addManyAtAssumeCapacity(self: *Self, index: usize, count: usize) []T self: *Selfindex: usizecount: usize239
240
241
242
243
244
245
246
247
248
249 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 there is enough capacity for the new elements. Asserts that the index is in bounds or equal to the length.