containers.unrolledlist
Unrolled Linked List.
License
-
Declaration
structUnrolledList(T, Allocator = Mallocator, bool supportGC = shouldAddGCRange!T, size_t cacheLineSize = 64);Unrolled Linked List.
Discussion
Nodes are (by default) sized to fit within a 64-byte cache line. The number of items stored per node can be read from the nodeCapacity field.
Parameters
Tthe element type
Allocatorthe allocator to use. Defaults to
Mallocator.supportGCtrueto ensure that the GC scans the nodes of the unrolled list,falseif you are sure that no references to GC-managed memory will be stored in this container.cacheLineSizeNodes will be sized to fit within this number of bytes.
-
Declaration
this();No default construction if an allocator must be provided.
-
Declaration
this(Allocatorallocator);Use the given
for allocations.allocator -
Declaration
voidclear();Removes all items from the list
-
Declaration
T*insertBack(Titem);Inserts the given
iteminto the end of the list.Return Value
a pointer to the inserted
item. -
Declaration
voidinsertBack(R)(auto ref Rrange);
T*opOpAssign(string op)(Titem) if (op == "~");
aliasput= insertBack;
aliasinsert= insertBack;Inserts the given
rangeinto the end of the list -
Declaration
@trusted T*insertAnywhere(Titem);Inserts the given
itemin the frontmost available cell, which may put theitemanywhere in the list as removal may leave gaps in list nodes. Use this only if the order of elements is not important.Return Value
a pointer to the inserted
item. -
Declaration
const pure nothrow @nogc @property @safe size_tlength();Return Value
the
lengthof the list -
Declaration
const pure nothrow @nogc @property @safe boolempty();Return Value
trueif the list isempty -
Declaration
boolremove(Titem);Removes the first instance of the given
itemfrom the list.Return Value
trueif something was removed. -
Declaration
voidpopFront();Pops the front item off of the list
-
Declaration
TmoveFront();Pops the front item off of the list and returns it
-
Declaration
inout nothrow @property ref inout(T)front();Time complexity is O(1)
Return Value
the item at the
frontof the list -
Declaration
inout nothrow @property ref inout(T)back();Time complexity is O(nodeCapacity), where the nodeCapacity is the number of items in a single list node. It is a constant related to the cache line size.
Return Value
the item at the
backof the list -
Declaration
voidpopBack();Pops the back item off of the list.
-
Declaration
TmoveBack();Removes an item from the back of the list and returns it.
-
Declaration
const pure nothrow @nogc @trusted autoopSlice(this This)();Return Value
a range over the list
-