SList.insertFront

Inserts a new element at the beginning.

  1. size_t insertFront(R el)
  2. size_t insertFront(R el)
    struct SList(T)
    @trusted
    size_t
    insertFront
    (
    R
    )
    (
    ref R el
    )
  3. size_t insertFront(R el)
  4. size_t insertFront(T[R] el)
  5. alias insert = insertFront

Parameters

R

Type of the inserted value(s).

el R

New element(s).

Return Value

Type: size_t

The number of elements inserted.

Examples

SList!int l;
int value = 5;

l.insertFront(value);
assert(l.front == value);

value = 8;
l.insertFront(value);
assert(l.front == 8);
SList!int l1;

assert(l1.insertFront(8) == 1);
assert(l1.front == 8);
assert(l1.insertFront(9) == 1);
assert(l1.front == 9);

SList!int l2;
assert(l2.insertFront([25, 30, 15]) == 3);
assert(l2.front == 25);

l2.insertFront(l1[]);
assert(l2.front == 9);

Meta