insertInPlace

Inserts stuff (which must be an input range or any number of implicitly convertible items) in array at position pos.

  1. void insertInPlace(T[] array, size_t pos, U stuff)
    void
    insertInPlace
    (
    T
    U...
    )
    (
    ref T[] array
    ,
    size_t pos
    ,)
    if (
    !isSomeString!(T[]) &&
    allSatisfy!(isInputRangeOrConvertible!T, U)
    &&
    U.length > 0
    )
  2. void insertInPlace(T[] array, size_t pos, U stuff)

Parameters

array T[]

The array that stuff will be inserted into.

pos size_t

The position in array to insert the stuff.

stuff U

An input range, or any number of implicitly convertible items to insert into array.

Examples

int[] a = [ 1, 2, 3, 4 ];
a.insertInPlace(2, [ 1, 2 ]);
assert(a == [ 1, 2, 1, 2, 3, 4 ]);
a.insertInPlace(3, 10u, 11);
assert(a == [ 1, 2, 1, 10, 11, 2, 3, 4]);

Meta

Suggestion Box / Bug Report