append

Append an item to an array. Optionally keep track of an external 'real length', while doing squared reallocation of the array

version(Windows)
void
append
(
T
I
)
(
ref T array
,,
uint* realLength = null
)

Parameters

array T

the array to append the item to

elem I

the new item to be appended

realLength uint*

the optional external 'real length'

Remarks: if realLength isn't null, the array is not resized by one, but allocated in a std::vector manner. The array's length becomes it's capacity, while 'realLength' is the number of items in the array.

Examples

uint barLen = 0;
int[] bar;
append(bar, 10, &barLen);
append(bar, 20, &barLen);
append(bar, 30, &barLen);
append(bar, 40, &barLen);
assert (bar.length == 16);
assert (barLen == 4);

Meta