9#include "platforms/assert_defs.h"
18 FASTLED_ASSERT(
mOps->move_construct !=
nullptr,
19 "vector: element type is not move-constructible");
22 for (fl::size i = 0; i < count; ++i) {
45 bool heap_allocated =
false;
50 heap_allocated =
true;
64 fl::size new_capacity = (3 *
mCapacity) / 2;
65 if (new_capacity < n) {
84 FASTLED_ASSERT(
mResource !=
nullptr,
"memory_resource is null");
86 FASTLED_ASSERT(alloc_bytes > 0,
"zero allocation in grow_to");
87 void* new_buf =
mResource->allocate(alloc_bytes);
170 mOps->copy_construct(dst, element);
180 FASTLED_ASSERT(
mArray !=
nullptr,
"mArray null after ensure_capacity in push_back_move");
183 mOps->move_construct(dst, element);
191 if (
mSize == 0)
return;
214 if (index >=
mSize)
return;
219 if (count == 0 || first_index >=
mSize)
return;
220 if (first_index + count >
mSize) {
221 count =
mSize - first_index;
224 fl::size remaining =
mSize - first_index - count;
230 for (fl::size i = 0; i < remaining; ++i) {
233 mOps->move_construct(dst, src);
234 mOps->destroy_n(src, 1);
260 for (fl::size i =
mSize - 1; i > index; --i) {
289 for (fl::size i =
mSize - 1; i > index; --i) {
309 if (n ==
mSize)
return;
325 if (
mOps->default_construct) {
326 for (fl::size i =
mSize; i < n; ++i) {
340 if (n ==
mSize)
return;
354 for (fl::size i =
mSize; i < n; ++i) {
358 for (fl::size i =
mSize; i < n; ++i) {
374 bool other_inline = other.isInline();
376 if (!this_inline && !other_inline) {
380 other.mArray = tmp_array;
384 other.mCapacity = tmp_cap;
385 }
else if (this_inline && other_inline) {
388 for (fl::size i = 0; i <
max_size; ++i) {
389 if (i <
mSize && i < other.mSize) {
395 }
else if (i <
mSize) {
407 mOps->destroy_n(other.element_ptr(i), 1);
413 }
else if (this_inline) {
417 void* other_array = other.mArray;
418 fl::size other_cap = other.mCapacity;
421 if (other.hasInlineBuffer() &&
mSize <= other.mInlineCapacity) {
422 other.mArray = other.inlineBufferPtr();
423 other.mCapacity = other.mInlineCapacity;
433 other.mCapacity =
mSize;
447 other.swap_impl(*
this);
452 fl::size tmp_size =
mSize;
454 other.mSize = tmp_size;
459 other.mResource = tmp_res;
466 if (other.mSize == 0)
return;
472 for (fl::size i = 0; i < other.mSize; ++i) {
482 if (other.isInline()) {
488 if (other.mSize > 0) {
503 if (other.hasInlineBuffer()) {
504 other.mArray = other.inlineBufferPtr();
505 other.mCapacity = other.mInlineCapacity;
507 other.mArray =
nullptr;
515 if (
this == &other)
return;
Type-erased base class for fl::vector<T>.
Polymorphic memory resource base class (PMR-style).
~vector_basic() FL_NO_EXCEPT
void move_assign(vector_basic &other) FL_NO_EXCEPT
Move-assign from another vector_basic (clears this first).
bool hasInlineBuffer() const FL_NO_EXCEPT
Does this vector have an inline buffer at all?
const vector_element_ops * mOps
void trivial_swap(void *a, void *b) const FL_NO_EXCEPT
void trivial_copy(void *dst, const void *src, fl::size count) const FL_NO_EXCEPT
void ensure_capacity(fl::size n) FL_NO_EXCEPT
Ensure capacity for at least n elements. Grows if needed.
void * element_ptr(fl::size index) FL_NO_EXCEPT
Pointer to element at index (byte arithmetic).
void * inlineBufferPtr() FL_NO_EXCEPT
Compute inline buffer pointer from offset.
void resize_impl(fl::size n) FL_NO_EXCEPT
Resize to n elements. New elements are default-constructed (zeroed for trivial).
void resize_value_impl(fl::size n, const void *value) FL_NO_EXCEPT
Resize to n elements. New elements are copy-constructed from value.
void push_back_move_impl(void *element) FL_NO_EXCEPT
bool isInline() const FL_NO_EXCEPT
Is data currently in the inline buffer?
void shrink_to_fit_impl() FL_NO_EXCEPT
void push_back_copy_impl(const void *element) FL_NO_EXCEPT
void grow_to(fl::size new_capacity) FL_NO_EXCEPT
Grow to new_capacity. Moves existing elements.
void insert_move_impl(fl::size index, void *element) FL_NO_EXCEPT
Insert element at index by move. Shifts subsequent elements right.
void copy_from(const vector_basic &other) FL_NO_EXCEPT
Copy all elements from another vector_basic.
memory_resource * mResource
void trivial_default_construct(void *ptr, fl::size count) const FL_NO_EXCEPT
void swap_impl(vector_basic &other) FL_NO_EXCEPT
Swap contents with another vector_basic.
void uninitialized_move_n_impl(void *dst, void *src, fl::size count) const FL_NO_EXCEPT
void trivial_move_left(void *dst, const void *src, fl::size count) const FL_NO_EXCEPT
vector_basic(fl::size elementSize, memory_resource *resource, const vector_element_ops *ops) FL_NO_EXCEPT
Heap-only vector (no inline buffer).
void clear_impl() FL_NO_EXCEPT
void reserve_impl(fl::size n) FL_NO_EXCEPT
void erase_impl(fl::size index) FL_NO_EXCEPT
Erase element at index. Shifts subsequent elements left.
void erase_range_impl(fl::size first_index, fl::size count) FL_NO_EXCEPT
Erase range [first_index, first_index + count).
void move_from(vector_basic &other) FL_NO_EXCEPT
Move-steal contents from another vector_basic.
void pop_back_impl() FL_NO_EXCEPT
void insert_copy_impl(fl::size index, const void *element) FL_NO_EXCEPT
Insert element at index by copy. Shifts subsequent elements right.
u8 u8 fract8 blur_amount FL_NO_EXCEPT
constexpr int type_rank< T >::value
FASTLED_FORCE_INLINE void * memset(void *s, int c, size_t n) FL_NO_EXCEPT
FASTLED_FORCE_INLINE void * memmove(void *dest, const void *src, size_t n) FL_NO_EXCEPT
FASTLED_FORCE_INLINE void * memcpy(void *dest, const void *src, size_t n) FL_NO_EXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
Base definition for an LED controller.