ddash.algorithm.fill

Assigns value to each element of input range range

Members

Functions

fill
void fill(ref Range range, auto ref T value, size_t startIndex = 0, size_t endIndex = size_t.max)

Fills a range with a value from startIndex to endIndex

Examples

1 int[] a = [1, 2, 3];
2 a.fill(5);
3 assert(a == [5, 5, 5]);
4 
5 int[] b = [1, 2, 3, 4, 5];
6 b.fill(9, 2, 4);
7 assert(b == [1, 2, 9, 9, 5]);
8 
9 int[] c = [1, 2, 3, 4, 5];
10 c.fill(9, 1, 100);
11 assert(c == [1, 9, 9, 9, 9]);

Meta