View source code
Display the source code in std/array.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.array.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
Name | Description |
---|---|
array | the array to scan |
from | the starting index |
to | the ending index |
stuff | the items to replace in-between from and to |
Example
int[] a = [1, 4, 5];
replaceInPlace(a, 1u, 2u, [2, 3, 4]);
writeln(a); // [1, 2, 3, 4, 5]
replaceInPlace(a, 1u, 2u, cast(int[])[]);
writeln(a); // [1, 3, 4, 5]
replaceInPlace(a, 1u, 3u, a[2 .. 4]);
writeln(a); // [1, 4, 5, 5]
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.