DArray

An array implementation that uses D's Garbage Collector functions.

Constructors

this
this(size_t n = 0)

Constructs a DArray and reserves space for n elements.

Members

Aliases

array
alias array = opSlice

Returns a slice.

Functions

cap
size_t cap()

Returns the total capacity of the array.

cap
void cap(size_t n)

Sets the capacity to exactly n elements.

dup
E[] dup()

Returns a copy.

ensureOrGrow
void ensureOrGrow(size_t ne)

Ensure space for 'ne' number of elements or grow by 1.5.

free
void free()

Calls the GC to free the memory and clears this DArray.

growP2
void growP2()

Sets: cap = next_pow_of_2(cap)

growX1_5
void growX1_5()

Sets: cap *= 1.5

growX2
void growX2()

Sets: cap *= 2

indexPtr
inout(E)* indexPtr(T x)

Adds x to ptr or subtracts from end.

len
size_t len()

Returns the size of the array.

len
void len(size_t n)

Sets the size of the array. Resizes space if necessary. Does not deallocate if n is zero.

opIndex
inout(E) opIndex(T x)

Returns the character at position x.

opIndexAssign
DArray opIndexAssign(E e, T x)

Assigns e at position x.

opOpAssign
void opOpAssign(const X x)

Appends x to the array. Appends the elements if X itself is an array.

opSlice
inout(E)[] opSlice()

Returns a slice.

opSlice
inout(E)[] opSlice(X x, Y y)

Returns a slice from x to y.

put
void put(Xs xs)

Appends several items to the array.

putUnsafe
void putUnsafe(Xs xs)

Appends several items to the array, without checking for sufficient space.

rem
size_t rem()

Returns the remaining space before a reallocation is needed.

rem
void rem(size_t n)

Sets the capacity so that space for n elements remain.

reserve
void reserve(size_t n)

Reserves memory for at least n elements.

take
E[] take()

Returns the contents and clears this DArray.

Manifest constants

scanIfPtrs
enum scanIfPtrs;

A block needs to be scanned by the GC, if E as pointers.

Meta