DynamicArray

Dynamic array container.

TODO: Move members dealing with Allocator, such as DynamicArrray.reserve, and others to private members of ArrayStore and then rerun container benchmark for DynamicArray. Also include a benchmark of calls to ArrayStore.reserve().

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: Add OutputRange.writer support as https://github.com/burner/StringBuffer/blob/master/source/stringbuffer.d#L45

TODO: Use std.traits.areCopyCompatibleArrays

TODO: Check if using the std::vector-compatible store is faster: struct Store { T* begin; T* endData; T* endCapacity; }

See: http://forum.dlang.org/thread/wswbtzakdvpgaebuhbom@forum.dlang.org See also https://github.com/izabera/s

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

Constructors

this
this(U value)

Construct from 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

Get length.

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()

Clear.

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(Capacity 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
inout(T)[] opSliceAssign(U value)
inout(T)[] opSliceAssign(U value, size_t i, size_t j)

Slice assignment support.

popAt
void popAt(Capacity index)

Pop element at index.

popBack
void popBack()

Remove last value from the end of the array.

popBackN
void popBackN(Capacity n)

Rmove n last values from the end of the array.

reserve
Capacity reserve(Capacity 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
Capacity capacity [@property getter]

Get capacity.

front
inout(T) front [@property getter]

Get reference to front element.

length
Capacity length [@property getter]

Get length.

length
Capacity length [@property setter]

Set length to newLength.

ptr
inout(T)* ptr [@property getter]

Unsafe access to store pointer.

Static functions

withElementsOfRange_untested
typeof(this) withElementsOfRange_untested(R values)

Construct from the elements values.

Meta