Remove an element from the array at a given index (all the following items will be moved)
| 349 | |
| 350 | /// Remove an element from the array at a given index (all the following items will be moved) |
| 351 | Iterator removeAt(uint64 index) { |
| 352 | |
| 353 | assert(index < mSize); |
| 354 | |
| 355 | // Call the destructor |
| 356 | mBuffer[index].~T(); |
| 357 | |
| 358 | mSize--; |
| 359 | |
| 360 | if (index != mSize) { |
| 361 | |
| 362 | // Move the elements to fill in the empty slot |
| 363 | void* dest = reinterpret_cast<void*>(mBuffer + index); |
| 364 | std::uintptr_t src = reinterpret_cast<std::uintptr_t>(dest) + sizeof(T); |
| 365 | std::memmove(dest, reinterpret_cast<const void*>(src), (mSize - index) * sizeof(T)); |
| 366 | } |
| 367 | |
| 368 | // Return an iterator pointing to the element after the removed one |
| 369 | return Iterator(mBuffer, index, mSize); |
| 370 | } |
| 371 | |
| 372 | /// Remove an element from the list at a given index and replace it by the last one of the list (if any) |
| 373 | void removeAtAndReplaceByLast(uint64 index) { |