View source code
Display the source code in std/algorithm/mutation.d from which this page was generated on
github.
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.
Page wiki
View or edit the community-maintained wiki page associated with this page.
std.algorithm.mutation.fill
- multiple declarations
- Function fill
- Function fill
Function fill
Assigns
to each element of input range value
.
range
Prototype
void fill(Range, Value)( Range range, Value value ) if (isInputRange!Range && is(typeof(range.front = value)));
Parameters
Name | Description |
---|---|
range | An input range that exposes references to its elements and has assignable elements |
value | Assigned to each element of range |
See Also
Example
int[] a = [ 1, 2, 3, 4 ]; fill(a, 5); assert(a == [ 5, 5, 5, 5 ]);
Function fill
Fills
with a pattern copied from range
. The length of
filler
does not have to be a multiple of the length of range
. If filler
is empty, an exception is thrown.
filler
Prototype
void fill(Range1, Range2)( Range1 range, Range2 filler ) if (isInputRange!Range1 && (isForwardRange!Range2 || isInputRange!Range2 && isInfinite!Range2) && is(typeof(Range1.init.front = Range2.init.front)));
Parameters
Name | Description |
---|---|
range | An input range that exposes references to its elements and has assignable elements. |
filler | The forward range representing the fill pattern. |
Example
int[] a = [ 1, 2, 3, 4, 5 ]; int[] b = [ 8, 9 ]; fill(a, b); assert(a == [ 8, 9, 8, 9, 8 ]);