DList.insertBack

Inserts the elements of an input range, or a variable number of items, at the end of the list.

If no allocator was provided when the list was created, the GCAllocator.std.experimental.allocator. will be used.

  1. size_t insertBack(Stuff stuff)
    struct DList(T)
    size_t
    insertBack
    (
    Stuff
    )
    (
    Stuff stuff
    )
    if (
    isInputRange!Stuff &&
    isImplicitlyConvertible!(ElementType!Stuff, T)
    )
  2. size_t insertBack(Stuff[] stuff)

Parameters

stuff Stuff

an input range of elements that are implitictly convertible to T; a variable number of items either in the form of a list or as a built-in array

Return Value

Type: size_t

the number of elements inserted

Complexity: O(pos + m), where m is the number of elements in the range.

Examples

import std.algorithm.comparison : equal;

auto d = DList!int(4, 5);
DList!int dl;
assert(dl.empty);

dl.insertBack(1);
dl.insertBack([2, 3]);
assert(equal(dl, [1, 2, 3]));

// insert from an input range
dl.insertBack(d);
assert(equal(dl, [1, 2, 3, 4, 5]));
d.front = 0;
assert(equal(dl, [1, 2, 3, 4, 5]));

Meta