Struct SList

Singly-linked list.

struct SList(T) ;

Constructors

NameDescription
this Creates a new SList with the elements from a static array.
this Creates a new SList with the elements from an input range.
this Creates a new SList.
this 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 Inserts new elements before r.
insertBefore Inserts elements from a static array before r.
insertFront Inserts a new element at the beginning.
opAssign Assigns another list.
opAssign Assigns an input range.
opAssign Assigns another list.
opAssign Assigns a static array.
opEquals Comparison for equality.
opIndex
popFirstOf Removes the front element of the range from the list.
remove Removes r from the list.
removeFront Removes the front element.
removeFront 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);