insertShift

Inserts elements into the middle of a buffer, maintaining the order of the existing elements by shifting them right using memmove.

Template params: T = type of buffer element

  1. T[] insertShift(Buffer!(T) buffer, size_t index, size_t insert_elems)
    T[]
    insertShift
    (
    T
    )
    (
    ref Buffer!(T) buffer
    ,
    size_t index
    ,
    size_t insert_elems = 1
    )
  2. T[] insertShift(T[] buffer, size_t index, size_t insert_elems)

Parameters

buffer Buffer!(T)

buffer to insert into

index size_t

position in buffer at which to insert new elements

insert_elems size_t

number of elements to insert, defaults to one

Return Value

Type: T[]

slice of buffer

Examples

auto arr = createBuffer("something");
insertShift(arr, 2, 2);
test!("==")(arr[], "somemething");

Meta