containers.dynamicarray
Dynamic Array
License
-
Declaration
structDynamicArray(T, Allocator = Mallocator, bool supportGC = shouldAddGCRange!T);Array that is able to grow itself when items are appended to it. Uses malloc/free/realloc to manage its storage.
Parameters
Tthe array element type
Allocatorthe allocator to use. Defaults to
Mallocator.supportGCtrueif the container should support holding references to GC-allocated memory.-
Declaration
aliasAppendT= const(T);Either
const(T)orT. -
Declaration
aliasAppendTypeOfThis= const(typeof(this));Either
const(typeof(this))ortypeof(this). -
Declaration
this();No default construction if an allocator must be provided.
-
Declaration
this(Allocatorallocator);Use the given
for allocations.allocator -
Declaration
@nogc autoopSlice(this This)();
@nogc autoopSlice(this This)(size_ta, size_tb);Slice operator overload
-
Declaration
@nogc autoopIndex(this This)(size_ti);Index operator overload
-
Declaration
voidinsertBack(Tvalue);
aliasinsert= insertBack;
aliasinsertAnywhere= insertBack;
aliasput= insertBack;Inserts the given
valueinto the end of the array. -
Declaration
ref scope typeof(this)opOpAssign(string op)(Tvalue) if (op == "~");~= operator overload
-
Declaration
ref scope typeof(this)opOpAssign(string op, bool checkForOverlap = true)(AppendT[]rhs) if (op == "~" && !is(T == AppendT[]));
ref scope typeof(this)opOpAssign(string op)(ref AppendTypeOfThisrhs) if (op == "~");~= operator overload for an array of items
-
Declaration
typeof(this)opBinary(string op)(ref AppendTypeOfThisother) if (op == "~");
typeof(this)opBinary(string op)(AppendT[]values) if (op == "~");~ operator overload
-
Declaration
voidreserve(size_tn);Ensures sufficient capacity to accommodate
elements.n -
Declaration
voidresize(size_tn);Change the array length. When growing, initialize new elements to the default value.
-
Declaration
voidresize(size_tn, Tvalue);Change the array length. When growing, initialize new elements to the given
value. -
Declaration
voidremove(const size_ti);Remove the item at the given index from the array.
-
Declaration
voidremoveBack();Removes the last element from the array.
-
Declaration
@nogc voidopIndexAssign(Tvalue, size_ti);Index assignment support
-
Declaration
@nogc voidopSliceAssign(Tvalue);
@nogc voidopSliceAssign(Tvalue, size_ti, size_tj);Slice assignment support
-
Declaration
const pure nothrow @nogc @property @safe size_tlength();
aliasopDollar= length;Return Value
the number of items in the array
-
Declaration
const pure nothrow @nogc @property @safe boolempty();Return Value
whether or not the DynamicArray is
empty. -
Declaration
@nogc @property autoptr(this This)();Return Value
a slice to the underlying array.
As the memory of the array may be freed, access to this array is highly unsafe. -
Declaration
pure @property ref Tfront();Return Value
the
frontelement of the DynamicArray. -
Declaration
pure @property ref Tback();Return Value
the
backelement of the DynamicArray.
-