FastLED 3.9.15
Loading...
Searching...
No Matches

◆ insert_move_impl()

void fl::vector_basic::insert_move_impl ( fl::size index,
void * element )

Insert element at index by move. Shifts subsequent elements right.

Definition at line 269 of file basic_vector.cpp.hpp.

269 {
270 if (index > mSize) index = mSize;
272 if (mSize >= mCapacity) return; // allocation failed
273
274 if (mOps) {
275 // Shift elements right, starting from the end
276 if (mSize > index) {
277 mOps->move_construct(element_ptr(mSize), element_ptr(mSize - 1));
278 for (fl::size i = mSize - 1; i > index; --i) {
279 mOps->destroy(element_ptr(i));
280 mOps->move_construct(element_ptr(i), element_ptr(i - 1));
281 }
282 mOps->destroy(element_ptr(index));
283 }
284 mOps->move_construct(element_ptr(index), element);
285 } else {
286 if (mSize > index) {
287 trivial_move_left(element_ptr(index + 1), element_ptr(index),
288 mSize - index);
289 }
290 fl::memcpy(element_ptr(index), element, mElementSize);
291 }
292 ++mSize;
293}
const vector_element_ops * mOps
fl::size mElementSize
void ensure_capacity(fl::size n) FL_NOEXCEPT
Ensure capacity for at least n elements. Grows if needed.
void * element_ptr(fl::size index) FL_NOEXCEPT
Pointer to element at index (byte arithmetic).
void trivial_move_left(void *dst, const void *src, fl::size count) const FL_NOEXCEPT
void * memcpy(void *dest, const void *src, size_t n) FL_NOEXCEPT

References element_ptr(), ensure_capacity(), mCapacity, mElementSize, fl::memcpy(), mOps, mSize, and trivial_move_left().

Referenced by fl::vector< fl::i16 >::insert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: