std.container.slist

This module implements a singly-linked list container. It can be used as a stack.

This module is a submodule of std.container.

Source: std/container/slist.d

struct SList

Types 1

structSList(T) if (!is(T == shared))

Implements a simple and fast singly-linked list. It can be used as a stack.

SList uses reference semantics.

Fields
private Node * _root
Methods
private void initialize() @trusted nothrow pure
private inout(Node *) _first() ref @property @safe nothrow pure inout
private Node * findLastNode(Node * n)
private Node * findLastNode(Node * n, size_t limit)
private Node * findNode(Node * n, Node * findMe)
private Node * findNodeByValue(Node * n, T value)
private static auto createNodeChain(Stuff)(Stuff stuff) if (isImplicitlyConvertible!(Stuff, T))
private static auto createNodeChain(Stuff)(Stuff stuff) if (isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, T))
private size_t insertAfterNode(Stuff)(Node * n, Stuff stuff)
bool opEquals(const SList rhs) constComparison for equality.
bool opEquals(ref const SList rhs) constditto
bool empty() @property constProperty returning `true` if and only if the container has no elements.
SList dup() @propertyDuplicates the container. The elements themselves are not transitively duplicated.
Range opSlice()Returns a range that iterates over all elements of the container, in forward order.
T front() @property refForward to `opSlice().front`.
SList opBinary(string op, Stuff)(Stuff rhs) if (op == "~" && is(typeof(SList(rhs))))Returns a new `SList` that's the concatenation of `this` and its argument. `opBinaryRight` is only defined if `Stuff` does not define `opBinary`.
SList opBinaryRight(string op, Stuff)(Stuff lhs) if (op == "~" && !is(typeof(lhs.opBinary!"~"(this))) && is(typeof(SList(lhs))))ditto
void clear()Removes all contents from the `SList`.
void reverse()Reverses SList in-place. Performs no memory allocation.
size_t insertFront(Stuff)(Stuff stuff) if (isInputRange!Stuff || isImplicitlyConvertible!(Stuff, T))Inserts `stuff` to the front of the container. `stuff` can be a value convertible to `T` or a range of objects convertible to T. The stable version behaves the same, but guarantees that ranges iter...
T removeAny()Picks one value in an unspecified position in the container, removes it from the container, and returns it. The stable version behaves the same, but guarantees that ranges iterating over the contai...
void removeFront()Removes the value at the front of the container. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.
size_t removeFront(size_t howMany)Removes `howMany` values at the front or back of the container. Unlike the unparameterized versions above, these functions do not throw if they could not remove `howMany` elements. Instead, if howM...
size_t insertAfter(Stuff)(Range r, Stuff stuff) if (isInputRange!Stuff || isImplicitlyConvertible!(Stuff, T))Inserts `stuff` after range `r`, which must be a range previously extracted from this container. Given that all ranges for a list end at the end of the list, this function essentially appends to th...
size_t insertAfter(Stuff)(Take!Range r, Stuff stuff) if (isInputRange!Stuff || isImplicitlyConvertible!(Stuff, T))Similar to `insertAfter` above, but accepts a range bounded in count. This is important for ensuring fast insertions in the middle of the list. For fast insertions after a specified position `r`, ...
Range linearRemove(Range r)Removes a range from the list in linear time.
Range linearRemove(Take!Range r)Removes a `Take!Range` from the list in linear time.
bool linearRemoveElement(T value)Removes the first occurence of an element from the list in linear time.
Constructors
this(U[] values...)Constructor taking a number of nodes
this(Stuff stuff)Constructor taking an input range
Nested Templates
Node
NodeWithoutPayload
RangeDefines the container's primary range, which embodies a forward range.