shiftIntoLeftwards

Leftwards shifting into

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

Examples

Tests the leftwards shifting

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

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

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

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

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

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

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

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

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

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

See Also

shiftInto

Meta