containers.slist
Singly-linked list.
License
-
Declaration
struct
SList
(T, Allocator = Mallocator, bool supportGC = shouldAddGCRange!T);Single-linked allocator-backed list.
Parameters
T
the element type
Allocator
the allocator to use. Defaults to
Mallocator
.supportGC
true
if the container should support holding references to GC-allocated memory.-
Declaration
this();
No default construction if an allocator must be provided.
-
Declaration
this(Allocator
allocator
);Use the given
for allocations.allocator
-
Declaration
inout @property auto
front
(this This)();Complexity: O(1)
Return Value
the most recently inserted item
-
Declaration
inout @property auto
back
(this This)();Complexity: O(length)
Return Value
the least recently inserted item.
-
Declaration
T
moveFront
();Removes the first item in the list.
Complexity: O(1)
Return Value
the first item in the list.
-
Declaration
void
popFront
();Removes the first item in the list.
Complexity: O(1)
-
Declaration
inout pure nothrow @nogc @property @safe bool
empty
();Complexity: O(1)
Return Value
true
if this list isempty
-
Declaration
inout pure nothrow @nogc @property @safe size_t
length
();Complexity: O(1)
Return Value
the number of items in the list
-
Declaration
@trusted void
insertFront
(Tt
);
aliasinsert
= insertFront;
aliasinsertAnywhere
= insertFront;
aliasput
= insertFront;Inserts an item at the front of the list.
Complexity: O(1)
Parameters
T
t
the item to
insert
into the list -
Declaration
void
opOpAssign
(string op)(Tt
) if (op == "~");Supports
list ~= item
syntaxComplexity: O(1)
-
Declaration
@trusted bool
remove
(V)(Vvalue
);Removes the first instance of
value
found in the list.Complexity: O(length)
Return Value
true
if avalue
was removed. -
Declaration
inout auto
opSlice
(this This)();Forward range interface
-
Declaration
void
clear
();Removes all elements from the range
Complexity: O(length)
-