DList.insertFront

Inserts a new element at the beginning.

  1. size_t insertFront(R el)
  2. size_t insertFront(R el)
    struct DList(T)
    @trusted
    size_t
    insertFront
    (
    R
    )
    (
    ref R el
    )
  3. size_t insertFront(R el)
  4. size_t insertFront(T[R] el)

Parameters

R

Type of the inserted value(s).

el R

New element(s).

Return Value

Type: size_t

The number of elements inserted.

Examples

DList!int l;
int value = 5;

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

value = 8;
l.insertFront(value);
assert(l.front == 8);
assert(l.back == 5);
DList!int l1;

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

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

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

Meta