containers.cyclicbuffer
Cyclic Buffer
License
-
Declaration
structCyclicBuffer(T, Allocator = Mallocator, bool supportGC = shouldAddGCRange!T);Array that provides constant time (amortized) appending and popping at either end, as well as random access to the elements.
Parameters
Tthe array element type
Allocatorthe allocator to use. Defaults to
Mallocator.supportGCtrueif the container should support holding references to GC-allocated memory.-
Declaration
this();No default construction if an allocator must be provided.
-
Declaration
pure nothrow @nogc @safe this(Allocatorallocator);Use the given
for allocations.allocator -
Declaration
voidclear();Removes all contents from the buffer.
-
Declaration
size_treserve(size_tnewCapacity);Ensures capacity is at least as large as specified.
-
Declaration
voidinsertFront(U)(Uvalue) if (isImplicitlyConvertible!(U, T));Inserts the given item into the start of the buffer.
-
Declaration
voidinsertBack(U)(Uvalue) if (isImplicitlyConvertible!(U, T));
aliasinsert= insertBack;
aliasinsertAnywhere= insertBack;
aliasput= insertBack;Inserts the given item into the end of the buffer.
-
Declaration
voidremoveFront();
aliaspopFront= removeFront;Removes the item at the start of the buffer.
-
Declaration
voidremoveBack();
aliaspopBack= removeBack;Removes the item at the end of the buffer.
-
Declaration
pure nothrow @property ref @safe autofront(this This)();Accesses to the item at the start of the buffer.
-
Declaration
pure nothrow @property ref @safe autoback(this This)();Accesses to the item at the end of the buffer.
-
Declaration
pure nothrow ref @safe autoopIndex(this This)(size_ti);buffer[
i] -
Declaration
pure nothrow @nogc @safe Range!ThisopIndex(this This)();buffer[]
-
Declaration
const pure nothrow @nogc @safe size_t[2]opSlice(size_t k : 0)(size_ti, size_tj);
pure nothrow @safe Range!ThisopIndex(this This)(size_t[2]indices);buffer[
i..j] -
Declaration
const pure nothrow @nogc @property @safe size_tlength();
aliasopDollar= length;Return Value
the number of items in the buffer.
-
Declaration
const pure nothrow @nogc @property @safe size_tcapacity();Return Value
maximal number of items the buffer can hold without reallocation.
-
Declaration
const pure nothrow @nogc @property @safe boolempty();Return Value
whether or not the CyclicBuffer is
empty.
-