FastLED 3.10.8
Loading...
Searching...
No Matches

◆ erase_range_impl()

void fl::vector_basic::erase_range_impl ( fl::size first_index,
fl::size count )

Erase range [first_index, first_index + count).

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

218 {
219 if (count == 0 || first_index >= mSize) return;
220 if (first_index + count > mSize) {
221 count = mSize - first_index;
222 }
223
224 fl::size remaining = mSize - first_index - count;
225
226 if (mOps) {
227 // Destroy erased elements
228 mOps->destroy_n(element_ptr(first_index), count);
229 // Shift remaining elements left one at a time
230 for (fl::size i = 0; i < remaining; ++i) {
231 void* dst = element_ptr(first_index + i);
232 void* src = element_ptr(first_index + count + i);
233 mOps->move_construct(dst, src);
234 mOps->destroy_n(src, 1);
235 }
236 } else {
237 // Trivial: memmove the remaining elements left
238 if (remaining > 0) {
239 trivial_move_left(element_ptr(first_index),
240 element_ptr(first_index + count),
241 remaining);
242 }
243 }
244 mSize -= count;
245}
const vector_element_ops * mOps
void * element_ptr(fl::size index) FL_NO_EXCEPT
Pointer to element at index (byte arithmetic).
void trivial_move_left(void *dst, const void *src, fl::size count) const FL_NO_EXCEPT

References element_ptr(), fl::FL_NO_EXCEPT, mOps, mSize, and trivial_move_left().

Referenced by erase_impl(), and fl::vector< fl::i16 >::erase_range().

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