Array.shiftRight

Shift contents of array to the right. It inreases the size of array by 1. The first element becomes default initialized.

struct Array(T, size_t chunkSize = 32)
void
shiftRight
()

Examples

Array!int arr;
scope(exit) arr.free();

arr.shiftRight();
assert(arr.length == 1);
assert(arr[0] == int.init);

arr[0] = 1;
arr.insertBack([2,3]);

arr.shiftRight();
assert(arr.length == 4);
assert(arr[0] == 1);
assert(arr[1] == 1);
assert(arr[2] == 2);
assert(arr[3] == 3);

Meta