Basic module

array_ordered_remove_by_value

procedure · 1 overloadSource

Removes the first element equal to item (by ==), keeping the order of the rest.

Returns whether one was found and removed; later duplicates stay.

ExampleOpen in playground ↗
values: [..] int;
array_add(*values, 7, 8, 7);
assert(array_ordered_remove_by_value(*values, 7));
assert(values.count == 2 && values[0] == 8 && values[1] == 7);
assert(!array_ordered_remove_by_value(*values, 99));
array_free(values);
array_ordered_remove_by_value :: (array_pointer: *[] $T, item: T) -> bool

Removes the first element equal to item (by ==), keeping the order of the rest.

Returns whether one was found and removed; later duplicates stay.

Parameters

array_pointer: *[] $T
item: T

Returns

bool
ExampleOpen in playground ↗
values: [..] int;
array_add(*values, 7, 8, 7);
assert(array_ordered_remove_by_value(*values, 7));
assert(values.count == 2 && values[0] == 8 && values[1] == 7);
assert(!array_ordered_remove_by_value(*values, 99));
array_free(values);

See also