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

Assigns value to each element of input range range.

Prototype

void fill(Range, Value)(
  Range range,
  Value value
)
if (isInputRange!Range && is(typeof(range.front = value)));

Parameters

NameDescription
range An input range that exposes references to its elements and has assignable elements
value Assigned to each element of range

See Also

uninitializedFill initializeAll

Example

int[] a = [ 1, 2, 3, 4 ];
fill(a, 5);
assert(a == [ 5, 5, 5, 5 ]);

Function fill

Fills range with a pattern copied from filler. The length of range does not have to be a multiple of the length of filler. If filler is empty, an exception is thrown.

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

NameDescription
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 ]);

Authors

Andrei Alexandrescu

License

Boost License 1.0.

Comments