MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / addRange

Method addRange

include/reactphysics3d/containers/Array.h:387–404  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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) {

Callers 5

testAddRemoveClearMethod · 0.80
deleteVisibleFacesMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by 1

testAddRemoveClearMethod · 0.64