| ... | ... | @@ -238,10 +238,8 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { |
| 238 | 238 | @memcpy(dst, items); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | | /// Replace range of elements `list[start..][0..len]` with `new_items`. |
| 242 | | /// Grows list if `len < new_items.len`. |
| 243 | | /// Shrinks list if `len > new_items.len`. |
| 244 | | /// Invalidates element pointers if this ArrayList is resized. |
| 241 | /// Grows or shrinks the list as necessary. |
| 242 | /// Invalidates element pointers if additional capacity is allocated. |
| 245 | 243 | /// Asserts that the range is in bounds. |
| 246 | 244 | pub fn replaceRange(self: *Self, start: usize, len: usize, new_items: []const T) Allocator.Error!void { |
| 247 | 245 | var unmanaged = self.moveToUnmanaged(); |
| ... | ... | @@ -249,14 +247,13 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { |
| 249 | 247 | return unmanaged.replaceRange(self.allocator, start, len, new_items); |
| 250 | 248 | } |
| 251 | 249 | |
| 252 | | /// Replace range of elements `list[start..][0..len]` with `new_items`. |
| 253 | | /// If `len < new_items.len` then it asserts that `.capacity` is |
| 254 | | /// large enough for the increase in items. |
| 255 | | /// Invalidates pointers if this ArrayList is resized. |
| 250 | /// Grows or shrinks the list as necessary. |
| 251 | /// Never invalidates element pointers. |
| 252 | /// Asserts the capacity is enough for additional items. |
| 256 | 253 | pub fn replaceRangeAssumeCapacity(self: *Self, start: usize, len: usize, new_items: []const T) void { |
| 257 | 254 | var unmanaged = self.moveToUnmanaged(); |
| 258 | | unmanaged.replaceRangeAssumeCapacity(start, len, new_items); |
| 259 | | self.* = unmanaged.toManaged(self.allocator); |
| 255 | defer self.* = unmanaged.toManaged(self.allocator); |
| 256 | return unmanaged.replaceRangeAssumeCapacity(start, len, new_items); |
| 260 | 257 | } |
| 261 | 258 | |
| 262 | 259 | /// Extends the list by 1 element. Allocates more memory as necessary. |
| ... | ... | @@ -795,11 +792,9 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ |
| 795 | 792 | @memcpy(dst, items); |
| 796 | 793 | } |
| 797 | 794 | |
| 798 | | /// Replace range of elements `list[start..][0..len]` with `new_items` |
| 799 | | /// Grows list if `len < new_items.len`. |
| 800 | | /// Shrinks list if `len > new_items.len` |
| 801 | | /// Invalidates element pointers if this ArrayList is resized. |
| 802 | | /// Asserts that the start index is in bounds or equal to the length. |
| 795 | /// Grows or shrinks the list as necessary. |
| 796 | /// Invalidates element pointers if additional capacity is allocated. |
| 797 | /// Asserts that the range is in bounds. |
| 803 | 798 | pub fn replaceRange( |
| 804 | 799 | self: *Self, |
| 805 | 800 | allocator: Allocator, |
| ... | ... | @@ -819,10 +814,9 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ |
| 819 | 814 | } |
| 820 | 815 | } |
| 821 | 816 | |
| 822 | | /// Replace range of elements `list[start..][0..len]` with `new_items`. |
| 823 | | /// Grows list if `len < new_items.len`. |
| 824 | | /// Shrinks list if `len > new_items.len`. |
| 825 | | /// Invalidates pointers if this ArrayList is resized. |
| 817 | /// Grows or shrinks the list as necessary. |
| 818 | /// Never invalidates element pointers. |
| 819 | /// Asserts the capacity is enough for additional items. |
| 826 | 820 | pub fn replaceRangeAssumeCapacity(self: *Self, start: usize, len: usize, new_items: []const T) void { |
| 827 | 821 | const after_range = start + len; |
| 828 | 822 | const range = self.items[start..after_range]; |