Array.remove

Remove all elements beloning to r.

struct Array(T)
remove
(
scope Range r
)

Parameters

r Range

Range originally obtained from this array.

Return Value

Type: Range

A range spanning the remaining elements in the array that initially were right after r.

Precondition: r refers to a region of $(D_KEYWORD this).

Examples

auto v = Array!int([5, 18, 17, 2, 4, 6, 1]);

assert(v.remove(v[1 .. 3]).length == 4);
assert(v[0] == 5 && v[1] == 2 && v[2] == 4 && v[3] == 6 && v[4] == 1);
assert(v.length == 5);

assert(v.remove(v[4 .. 4]).length == 1);
assert(v[0] == 5 && v[1] == 2 && v[2] == 4 && v[3] == 6 && v[4] == 1);
assert(v.length == 5);

assert(v.remove(v[4 .. 5]).length == 0);
assert(v[0] == 5 && v[1] == 2 && v[2] == 4 && v[3] == 6);
assert(v.length == 4);

assert(v.remove(v[]).length == 0);

Meta