SList.this

Constructs a qualified singly linked list out of a number of items. Because no allocator was provided, the list will use the GCAllocator.std.experimental.allocator..

  1. this(A allocator)
  2. this(U[] values)
    struct SList(T)
    this
    (
    U
    this Q
    )
    ()
    if (
    isImplicitlyConvertible!(U, T)
    )
  3. this(A allocator, U[] values)
  4. this(Stuff stuff)
  5. this(A allocator, Stuff stuff)

Parameters

values U[]

a variable number of items, either in the form of a list or as a built-in array

Complexity: O(m), where m is the number of items.

Examples

import std.algorithm.comparison : equal;

// Create a list from a list of ints
{
    auto sl = SList!int(1, 2, 3);
    assert(equal(sl, [1, 2, 3]));
}
// Create a list from an array of ints
{
    auto sl = SList!int([1, 2, 3]);
    assert(equal(sl, [1, 2, 3]));
}
// Create a list from a list from an input range
{
    auto sl = SList!int(1, 2, 3);
    auto sl2 = SList!int(sl);
    assert(equal(sl2, [1, 2, 3]));
}

Meta