Struct SList

Singly-linked list.

struct SList(T) ;

Constructors

NameDescription
this (init, allocator) Creates a new SList with the elements from a static array.
this (init, allocator) Creates a new SList with the elements from an input range.
this (len, init, allocator) Creates a new SList.
this (init, allocator) Initializes this list from another one.

Properties

NameTypeDescription
empty[get] bool
front[get] inout(T)

Methods

NameDescription
clear () Removes all contents from the list.
insertBefore (r, el) Inserts new elements before r.
insertBefore (r, el) Inserts elements from a static array before r.
insertFront (el) Inserts a new element at the beginning.
opAssign (that) Assigns another list.
opAssign (that) Assigns an input range.
opAssign (that) Assigns another list.
opAssign (that) Assigns a static array.
opEquals (that) Comparison for equality.
opIndex ()
popFirstOf (range) Removes the front element of the range from the list.
remove (r) Removes r from the list.
removeFront () Removes the front element.
removeFront (howMany) Removes howMany elements from the list.

Aliases

NameDescription
ConstRange The range types for SList.
insert Inserts a new element at the beginning.
Range The range types for SList.

Parameters

NameDescription
T Content type.

Example

SList!int l;
size_t i;

l.insertFront(5);
l.insertFront(4);
l.insertFront(9);
foreach (e; l)
{
    assert(i != 0 || e == 9);
    assert(i != 1 || e == 4);
    assert(i != 2 || e == 5);
    ++i;
}
assert(i == 3);