DoxigAlpha

swapRemove

Remove the specified item from the list, swapping the last item in the list into its position. Fast, but does not retain list ordering.

Function parameters

Parameters

#
self:*Self
index:usize

A MultiArrayList stores a list of a struct or tagged union type.

Functions

#
MultiArrayList
A MultiArrayList stores a list of a struct or tagged union type.

Source

Implementation

#
pub fn swapRemove(self: *Self, index: usize) void {
    const slices = self.slice();
    inline for (fields, 0..) |_, i| {
        const field_slice = slices.items(@as(Field, @enumFromInt(i)));
        field_slice[index] = field_slice[self.len - 1];
        field_slice[self.len - 1] = undefined;
    }
    self.len -= 1;
}