SList

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

SList uses reference semantics.

Constructors

this
this(U[] values)

Constructor taking a number of nodes

this
this(Stuff stuff)

Constructor taking an input range

Members

Aliases

insert
alias insert = insertFront
stableInsert
alias stableInsert = insert

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 iterating over the container are never invalidated.

stableInsertAfter
alias stableInsertAfter = insertAfter

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, use insertAfter(take(r, 1), stuff). The complexity of that operation only depends on the number of elements in stuff.

stableInsertFront
alias stableInsertFront = insertFront

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 iterating over the container are never invalidated.

stableLinearRemove
alias stableLinearRemove = linearRemove

Removes a Take!Range from the list in linear time.

stableRemoveAny
alias stableRemoveAny = 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 container are never invalidated.

stableRemoveFront
alias stableRemoveFront = 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.

stableRemoveFront
alias stableRemoveFront = removeFront

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 howMany > n, all elements are removed. The returned value is the effective number of elements removed. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

Functions

clear
void clear()

Removes all contents from the SList.

insertAfter
size_t insertAfter(Range r, Stuff stuff)

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 the list and uses r as a potentially fast way to reach the last node in the list. Ideally r is positioned near or at the last element of the list.

insertAfter
size_t insertAfter(Take!Range r, Stuff stuff)

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, use insertAfter(take(r, 1), stuff). The complexity of that operation only depends on the number of elements in stuff.

insertFront
size_t insertFront(Stuff stuff)

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 iterating over the container are never invalidated.

linearRemove
Range linearRemove(Range r)

Removes a range from the list in linear time.

linearRemove
Range linearRemove(Take!Range r)

Removes a Take!Range from the list in linear time.

linearRemoveElement
bool linearRemoveElement(T value)

Removes the first occurence of an element from the list in linear time.

opBinary
SList opBinary(Stuff rhs)
opBinaryRight
SList opBinaryRight(Stuff lhs)

Returns a new SList that's the concatenation of this and its argument. opBinaryRight is only defined if Stuff does not define opBinary.

opEquals
bool opEquals(SList rhs)

Comparison for equality.

opSlice
Range opSlice()

Returns a range that iterates over all elements of the container, in forward order.

removeAny
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 container are never invalidated.

removeFront
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.

removeFront
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 howMany > n, all elements are removed. The returned value is the effective number of elements removed. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

reverse
void reverse()

Reverses SList in-place. Performs no memory allocation.

Properties

dup
SList dup [@property getter]

Duplicates the container. The elements themselves are not transitively duplicated.

empty
bool empty [@property getter]

Property returning true if and only if the container has no elements.

front
T front [@property getter]

Forward to opSlice().front.

Structs

Range
struct Range

Defines the container's primary range, which embodies a forward range.

Meta