shiftIntoRightwards

Rightwards shifting into

T[]
shiftIntoRightwards
(
T
)
(
T[] array
,
size_t position
,
bool shrink = false
)

Examples

Tests the rightwards shifting

int[] numbas = [1, 5, 2];
numbas = numbas.shiftIntoRightwards(1);

// should now be [0, 1, 2]
writeln(numbas);
assert(numbas == [0, 1, 2]);

numbas = [1, 5, 2];
numbas = numbas.shiftIntoRightwards(0);

// should now be [1, 5, 2]
writeln(numbas);
assert(numbas == [1, 5, 2]);

numbas = [1, 5, 2];
numbas = numbas.shiftIntoRightwards(2);

// should now be [0, 1, 5]
writeln(numbas);
assert(numbas == [0, 1, 5]);

numbas = [1, 2];
numbas = numbas.shiftIntoRightwards(1);

// should now be [0, 1]
writeln(numbas);
assert(numbas == [0, 1]);

numbas = [1, 2];
numbas = numbas.shiftIntoRightwards(0);

// should now be [1, 2]
writeln(numbas);
assert(numbas == [1, 2]);

numbas = [];
numbas = numbas.shiftIntoRightwards(0);

// should now be []
writeln(numbas);
assert(numbas == []);

numbas = [1, 5, 2];
numbas = numbas.shiftIntoRightwards(1, true);

// should now be [1, 2]
writeln(numbas);
assert(numbas == [1, 2]);

See Also

shiftInto

Meta