The OpenD Programming Language

DynamicArray

Array that is able to grow itself when items are appended to it. Uses malloc/free/realloc to manage its storage.

Constructors

this
this()

No default construction if an allocator must be provided.

this
this(Allocator allocator)

Use the given allocator for allocations.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Postblit

A postblit is present on this object, but not explicitly documented in the source.

Members

Aliases

AppendT
alias AppendT = const(T)

Either const(T) or T.

AppendTypeOfThis
alias AppendTypeOfThis = const(typeof(this))

Either const(typeof(this)) or typeof(this).

insert
alias insert = insertBack
insertAnywhere
alias insertAnywhere = insertBack

Inserts the given value into the end of the array.

opDollar
alias opDollar = length
put
alias put = insertBack

Inserts the given value into the end of the array.

Functions

back
T back()
empty
bool empty()
front
T front()
insertBack
void insertBack(T value)

Inserts the given value into the end of the array.

length
size_t length()
opBinary
typeof(this) opBinary(AppendTypeOfThis other)
typeof(this) opBinary(AppendT[] values)

~ operator overload

opIndex
auto ref opIndex(size_t i)

Index operator overload

opIndexAssign
void opIndexAssign(T value, size_t i)

Index assignment support

opOpAssign
typeof(this) opOpAssign(T value)

~= operator overload

opOpAssign
typeof(this) opOpAssign(AppendT[] rhs)
typeof(this) opOpAssign(AppendTypeOfThis rhs)

~= operator overload for an array of items

opSlice
auto opSlice()
auto opSlice(size_t a, size_t b)

Slice operator overload

opSliceAssign
void opSliceAssign(T value)
void opSliceAssign(T value, size_t i, size_t j)
void opSliceAssign(T[] values)
void opSliceAssign(T[] values, size_t i, size_t j)

Slice assignment support

ptr
auto ptr()
remove
void remove(size_t i)

Remove the item at the given index from the array.

removeBack
void removeBack()

Removes the last element from the array.

reserve
void reserve(size_t n)

Ensures sufficient capacity to accommodate n elements.

resize
void resize(size_t n)

Change the array length. When growing, initialize new elements to the default value.

resize
void resize(size_t n, T value)

Change the array length. When growing, initialize new elements to the given value.

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.

Meta