Xar module

xar_unordered_remove

procedure · 1 overloadSource

Removes element index by copying the last element over it and shrinking the count. The order changes and no memory is freed.

An out-of-range index fails an assert. Pointers to the last element and to index now name different values.

ExampleOpen in playground ↗
array: Xar(int, 2, 4);
for 1..4 xar_add(*array, it);
xar_unordered_remove(*array, 0);
assert(array.count == 3 && array[0] == 4);
xar_reset(*array);
xar_unordered_remove :: (array: *Xar, index: int)

Parameters

array: *Xar
index: int

See also