DynamicArray

Array type with deterministic control of memory. The memory allocated for the array is reclaimed as soon as possible; there is no reliance on the garbage collector.

A null Allocator means to qcmeman functions. TODO use Mallocator by default.

TODO: Use Allocator in place of import nxt.qcmeman : malloc, realloc, free, gc_addRange, gc_removeRange;

TODO: Replace withCapacity with void capacity(size_t) like D arrays.

TODO: Generalize to bucket array either via specialized allocator to by extra Storage class given as template type parameter. Integrate nxt.bucket_array for details.

TODO: Use std.bitmanip.BitArray for array container storing boolean values.

TODO: Add OutputRange.writer support as https://github.com/burner/StringBuffer/blob/master/source/stringbuffer.d#L45

TODO: Use std.traits.areCopyCompatibleArrays

See also https://github.com/izabera/s

@safe
struct DynamicArray (
T
Allocator = Mallocator
Capacity = size_t
) if (
!is(immutable T == immutable bool) &&
(
is(Capacity == ulong) ||
is(Capacity == uint)
)
&&
isAllocator!Allocator
) {}

Constructors

this
this(T value)

Construct from uncopyable element value.

this
this(U value)

Construct from copyable element value.

this
this(U[] values)

Construct from the element(s) of the dynamic array values.

this
this(U[n] values)
this(R values)

Construct from the n number of element(s) in the static array values.

Destructor

~this
~this()

Destruct.

Postblit

this(this)
this(this)

No default copying.

Members

Aliases

opDollar
alias opDollar = length
Undocumented in source.
put
alias put = insertBack
Undocumented in source.
put
alias put = insertBack

Insert the elements elements into the end of the array.

Enums

isElementAssignable
eponymoustemplate isElementAssignable(U)

Is true if U can be assigned to the elements of this.

Functions

clear
void clear()

Empty.

empty
bool empty()

Check if empty.

insertBack
void insertBack(T value)

Insert value into the end of the array.

insertBack
void insertBack(U[] values)

Insert the elements values into the end of the array.

insertBack
void insertBack(R elements)

Insert the elements elements into the end of the array.

insertBackMove
void insertBackMove(T value)

Move value into the end of the array.

moveAt
T moveAt(size_t index)

Move element at index to return.

opEquals
bool opEquals(typeof(this) rhs)
bool opEquals(U[] rhs)

Comparison for equality.

opIndex
inout(T) opIndex(size_t i)

Index support.

opIndexAssign
T opIndexAssign(U value, size_t i)

Index assignment support.

opOpAssign
void opOpAssign(T value)
void opOpAssign(U[] values)
void opOpAssign(R values)

Forwards to insertBack(values).

opOpAssign
void opOpAssign(typeof(this) values)
Undocumented in source. Be warned that the author may not have intended to support it.
opSlice
inout(T)[] opSlice(size_t i, size_t j)
inout(T)[] opSlice()

Slice support.

opSliceAssign
T[] opSliceAssign(U value)
T[] opSliceAssign(U value, size_t i, size_t j)

Slice assignment support.

popAt
void popAt(size_t index)

Pop element at index.

popBack
void popBack()

Remove last value fromm the end of the array.

popBackN
void popBackN(size_t n)

Rmove n last values from the end of the array.

ptr
inout(T)* ptr()

Unsafe access to pointer.

reserve
size_t reserve(size_t minimumCapacity)

Ensures sufficient capacity to accommodate for minimumCapacity number of elements. If minimumCapacity < capacity, this method does nothing.

takeBack
T takeBack()

Pop back element and return it.

takeFront
T takeFront()

Move element at front.

toHash
hash_t toHash()

Calculate D associative array (AA) key hash.

toString
void toString(Sink sink)

Construct a string representation of this at sink.

Manifest constants

_growthP
enum _growthP;
_growthQ
enum _growthQ;

Growth factor P/Q. https://github.com/facebook/folly/blob/master/folly/docs/FBVector.md#memory-handling

Use 1.5 like Facebook's fbvector does.

Properties

back
inout(T) back [@property getter]

Get reference to back element.

capacity
size_t capacity [@property getter]

Get capacity.

dup
DynamicArray!(MT, Allocator, Capacity) dup [@property getter]
front
inout(T) front [@property getter]

Get reference to front element.

length
size_t length [@property getter]

Get length.

length
size_t length [@property setter]

Set length to newLength.

Static functions

emplaceWithCopiedElements
typeof(this) emplaceWithCopiedElements(typeof(this)* thatPtr, const(T)[] elements)

Emplace thatPtr with elements copied from elements.

emplaceWithMovedElements
typeof(this) emplaceWithMovedElements(typeof(this)* thatPtr, T[] elements)

Emplace thatPtr with elements moved from elements.

withCapacity
typeof(this) withCapacity(size_t initialCapacity)
withElements
typeof(this) withElements(T[] elements)
Undocumented in source. Be warned that the author may not have intended to support it.
withElementsOfRange_untested
typeof(this) withElementsOfRange_untested(R values)

Construct from the elements values.

withLength
typeof(this) withLength(size_t initialLength)
withLengthElementValue
typeof(this) withLengthElementValue(size_t length, T elementValue)

Construct using - initial length length, - and value of all elements elementValue.

Meta