FastLED 3.9.15
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 205 of file basic_vector.cpp.hpp.

205 {
206 if (count == 0 || first_index >= mSize) return;
207 if (first_index + count > mSize) {
208 count = mSize - first_index;
209 }
210
211 fl::size remaining = mSize - first_index - count;
212
213 if (mOps) {
214 // Destroy erased elements
215 for (fl::size i = 0; i < count; ++i) {
216 mOps->destroy(element_ptr(first_index + i));
217 }
218 // Shift remaining elements left one at a time
219 for (fl::size i = 0; i < remaining; ++i) {
220 void* dst = element_ptr(first_index + i);
221 void* src = element_ptr(first_index + count + i);
222 mOps->move_construct(dst, src);
223 mOps->destroy(src);
224 }
225 } else {
226 // Trivial: memmove the remaining elements left
227 if (remaining > 0) {
228 trivial_move_left(element_ptr(first_index),
229 element_ptr(first_index + count),
230 remaining);
231 }
232 }
233 mSize -= count;
234}
const vector_element_ops * mOps
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

References element_ptr(), 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: