SList.insertBefore

Inserts new elements before r.

  1. size_t insertBefore(Range r, R el)
  2. size_t insertBefore(Range r, R el)
  3. size_t insertBefore(Range r, T el)
    struct SList(T)
    @trusted
    size_t
    insertBefore
    ()
    (,
    ref T el
    )
  4. size_t insertBefore(Range r, T[R] el)

Parameters

r Range

Range extracted from this list.

el T

New element(s).

Return Value

Type: size_t

The number of elements inserted.

Precondition: r is extracted from this list.

Examples

auto l1 = SList!int([234, 5, 1]);
auto l2 = SList!int([5, 1]);
l2.insertBefore(l2[], 234);
assert(l1 == l2);
auto l1 = SList!int([5, 234, 30, 1]);
auto l2 = SList!int([5, 1]);
auto l3 = SList!int([234, 30]);
auto r = l2[];
r.popFront();
l2.insertBefore(r, l3[]);
assert(l1 == l2);
auto l1 = SList!int([234, 5, 1]);
auto l2 = SList!int([5, 1]);
int var = 234;
l2.insertBefore(l2[], var);
assert(l1 == l2);

Meta