Remove an element from the array at a given index and replace it by the last one of the array (if any) Append another array at the end of the current one
| 385 | /// Remove an element from the array at a given index and replace it by the last one of the array (if any) |
| 386 | /// Append another array at the end of the current one |
| 387 | void addRange(const Array<T>& array, uint64 startIndex = 0) { |
| 388 | |
| 389 | assert(startIndex <= array.size()); |
| 390 | |
| 391 | // If we need to allocate more memory |
| 392 | if (mSize + (array.size() - startIndex) > mCapacity) { |
| 393 | |
| 394 | // Allocate memory |
| 395 | reserve(mSize + array.size() - startIndex); |
| 396 | } |
| 397 | |
| 398 | // Add the elements of the array to the current one |
| 399 | for(uint64 i=startIndex; i<array.size(); i++) { |
| 400 | |
| 401 | new (reinterpret_cast<void*>(mBuffer + mSize)) T(array[i]); |
| 402 | mSize++; |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | /// Clear the array |
| 407 | void clear(bool releaseMemory = false) { |