View source code
Display the source code in std/algorithm/mutation.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.algorithm.mutation.fill
Assigns value
to each element of input range range
.
void fill(Range, Value)
(
auto ref Range range,
auto ref Value value
)
if (isInputRange!Range && is(typeof(range .front = value)) || isSomeChar!Value && is(typeof(range[] = value)));
void fill(InputRange, ForwardRange)
(
InputRange range,
ForwardRange filler
)
if (isInputRange!InputRange && (isForwardRange!ForwardRange || isInputRange!ForwardRange && isInfinite!ForwardRange) && is(typeof(InputRange .init .front = ForwardRange .init .front)));
Alternatively, instead of using a single value
to fill the range
,
a filter
forward range
can be provided. The length of filler
and range
do not need to match, but
filler
must not be empty.
Parameters
Name | Description |
---|---|
range | An input range that exposes references to its elements and has assignable elements |
value | Assigned to each element of range |
filler | A forward range representing the fill pattern. |
Throws
If filler
is empty.
See Also
Example
int[] a = [ 1, 2, 3, 4 ];
fill(a, 5);
writeln(a); // [5, 5, 5, 5]
Example
int[] a = [ 1, 2, 3, 4, 5 ];
int[] b = [ 8, 9 ];
fill(a, b);
writeln(a); // [8, 9, 8, 9, 8]
Authors
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.