License:
tango license, apache 2.0Authors:
Tomasz Stachowiak (h3r3tic)Params:
array | the array which will be resized |
numItems | number of items to be allocated in the array |
init | whether to init the allocated items to their default values or not |
Examples:
int[] foo; foo.alloc(20);Remarks:
The array must be null and empty for this function to succeed. The rationale behind this is that the coder should state his decision clearly. This will help and has already helped to spot many intricate bugs.Examples:
int[] foo; foo.alloc(20); foo.realloc(10); // <--Params:
array | the array to append the item to |
elem | the new item to be appended |
realLength | 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:
1 2 3 4 5 6 7 8 | 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); |