View source code Display the source code in std/container/slist.d from which this page was generated on github. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

Struct std.container.slist.SList

Implements a simple and fast singly-linked list.

SList uses reference semantics.

Properties

Name Type Description
dup [get] SList Duplicates the container. The elements themselves are not transitively duplicated.
empty [get] bool Property returning true if and only if the container has no elements.
front [get] T Forward to opSlice().front.

Methods

Name Description
clear Removes all contents from the SList.
linearRemove Removes a Take!Range from the list in linear time.
linearRemove Removes a range from the list in linear time.
opEquals Comparison for equality.
opSlice Returns a range that iterates over all elements of the container, in forward order.
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 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 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.

Inner structs

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

Aliases

Name Description
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.
stableInsert 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 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 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 Removes a Take!Range from the list in linear time.
stableRemoveAny 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 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 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.

Templates

Name Description
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.
insertAfter 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.
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.
opBinary Returns a new SList that's the concatenation of this and its argument. opBinaryRight is only defined if Stuff does not define opBinary.
opBinaryRight Returns a new SList that's the concatenation of this and its argument. opBinaryRight is only defined if Stuff does not define opBinary.
this Constructor taking a number of nodes
this Constructor taking an input range

Authors

Steven Schveighoffer, Andrei Alexandrescu

License

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at ).

Comments