replaceInPlace

Replaces elements from array with indices ranging from from (inclusive) to to (exclusive) with the range stuff. Expands or shrinks the array as needed.

void
replaceInPlace
(
T
Range
)
(
ref T[] array
,
size_t from
,
size_t to
,
Range stuff
)
if (
is(typeof(replace(array, from, to, stuff)))
)

Parameters

array T[]

the array to scan

from size_t

the starting index

to size_t

the ending index

stuff Range

the items to replace in-between from and to

Examples

int[] a = [1, 4, 5];
replaceInPlace(a, 1u, 2u, [2, 3, 4]);
assert(a == [1, 2, 3, 4, 5]);
replaceInPlace(a, 1u, 2u, cast(int[])[]);
assert(a == [1, 3, 4, 5]);
replaceInPlace(a, 1u, 3u, a[2 .. 4]);
assert(a == [1, 4, 5, 5]);

Meta