shiftInto

Shifts a subset of the elements of the given array to a given position either from the left or right.

Optionally allowing the shrinking of the array after the process, otherwise the last element shifted's previous value will be set to the value specified.

T[]
shiftInto
(
T
)
(
T[] array
,
size_t position
,
bool rightwards = false
,
bool shrink = false
,
T filler = T.init
)

Parameters

array T[]

the input array

position size_t

the position to shift onto

rightwards bool

if true then shift elements into the position rightwards, else leftwards (which is also the default)

shrink bool

if set to true then the array will be resized to exclude the now "empty" element

filler T

the value to place in the space where the last element shifted no longer occupies, by default this is T.init

Return Value

Type: T[]

the shifted array

Meta