Clear the array
| 405 | |
| 406 | /// Clear the array |
| 407 | void clear(bool releaseMemory = false) { |
| 408 | |
| 409 | // Call the destructor of each element |
| 410 | for (uint64 i=0; i < mSize; i++) { |
| 411 | mBuffer[i].~T(); |
| 412 | } |
| 413 | |
| 414 | mSize = 0; |
| 415 | |
| 416 | // If we need to release all the allocated memory |
| 417 | if (releaseMemory && mCapacity > 0) { |
| 418 | |
| 419 | // Release the memory allocated on the heap |
| 420 | mAllocator.release(mBuffer, mCapacity * sizeof(T)); |
| 421 | |
| 422 | mBuffer = nullptr; |
| 423 | mCapacity = 0; |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | /// Return the number of elements in the array |
| 428 | uint64 size() const { |