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

Method removeAt

include/reactphysics3d/containers/Array.h:351–370  ·  view source on GitHub ↗

Remove an element from the array at a given index (all the following items will be moved)

Source from the content-addressed store, hash-verified

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

Callers 3

testAddRemoveClearMethod · 0.80
removeUnusedVerticesMethod · 0.80

Calls 1

IteratorClass · 0.70

Tested by 1

testAddRemoveClearMethod · 0.64