containers.cyclicbuffer
Cyclic Buffer
License
-
Declaration
struct
CyclicBuffer
(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
T
the array 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
pure nothrow @nogc @safe this(Allocator
allocator
);Use the given
for allocations.allocator
-
Declaration
void
clear
();Removes all contents from the buffer.
-
Declaration
size_t
reserve
(size_tnewCapacity
);Ensures capacity is at least as large as specified.
-
Declaration
void
insertFront
(U)(Uvalue
) if (isImplicitlyConvertible!(U, T));Inserts the given item into the start of the buffer.
-
Declaration
void
insertBack
(U)(Uvalue
) if (isImplicitlyConvertible!(U, T));
aliasinsert
= insertBack;
aliasinsertAnywhere
= insertBack;
aliasput
= insertBack;Inserts the given item into the end of the buffer.
-
Declaration
void
removeFront
();
aliaspopFront
= removeFront;Removes the item at the start of the buffer.
-
Declaration
void
removeBack
();
aliaspopBack
= removeBack;Removes the item at the end of the buffer.
-
Declaration
pure nothrow @property ref @safe auto
front
(this This)();Accesses to the item at the start of the buffer.
-
Declaration
pure nothrow @property ref @safe auto
back
(this This)();Accesses to the item at the end of the buffer.
-
Declaration
pure nothrow ref @safe auto
opIndex
(this This)(size_ti
);buffer[
i
] -
Declaration
pure nothrow @nogc @safe Range!This
opIndex
(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_t
length
();
aliasopDollar
= length;Return Value
the number of items in the buffer.
-
Declaration
const pure nothrow @nogc @property @safe size_t
capacity
();Return Value
maximal number of items the buffer can hold without reallocation.
-
Declaration
const pure nothrow @nogc @property @safe bool
empty
();Return Value
whether or not the CyclicBuffer is
empty
.
-