FastLED 3.9.15
Loading...
Searching...
No Matches
vector.h
Go to the documentation of this file.
1#pragma once
2
3// allow-include-after-namespace
4
5#include "fl/stl/stdint.h" // IWYU pragma: keep
6#include "fl/stl/int.h" // IWYU pragma: keep
7
8#include "fl/stl/bit_cast.h"
9#include "fl/stl/functional.h" // IWYU pragma: keep
10#include "fl/stl/initializer_list.h" // IWYU pragma: keep
11#include "fl/math/math.h"
12#include "fl/stl/cstring.h"
13#include "fl/stl/allocator.h"
14#include "fl/stl/scoped_ptr.h" // IWYU pragma: keep
15#include "fl/stl/type_traits.h"
16#include "fl/stl/new.h" // IWYU pragma: keep
17#include "fl/stl/move.h"
18#include "fl/stl/align.h"
20#include "fl/stl/basic_vector.h"
22#include "fl/stl/noexcept.h"
23
24namespace fl {
25
26// Forward declaration for span (defined in fl/stl/span.h)
27template <typename T, fl::size Extent> class span; // IWYU pragma: keep
28
29// Aligned memory block for inlined data structures.
30// Must be aligned to at least the alignment of T, but not less than the natural alignment
31template <typename T, fl::size N>
32struct FL_ALIGNAS(alignof(T) > alignof(fl::uptr) ? alignof(T) : alignof(fl::uptr)) InlinedMemoryBlock {
33 // using MemoryType = uinptr_t;
34 typedef fl::uptr MemoryType;
35 enum {
36 kTotalBytes = N * sizeof(T),
37 kExtraSize =
38 (kTotalBytes % alignof(fl::max_align_t)) ? (alignof(fl::max_align_t) - (kTotalBytes % alignof(fl::max_align_t))) : 0,
39 // Fix: calculate total bytes first, then convert to MemoryType units
40 kTotalBytesAligned = kTotalBytes + kExtraSize,
41 kBlockSize = (kTotalBytesAligned + sizeof(MemoryType) - 1) / sizeof(MemoryType),
42 };
43
44 InlinedMemoryBlock() FL_NOEXCEPT {
45 fl::memset(mMemoryBlock, 0, sizeof(mMemoryBlock));
46#ifdef FASTLED_TESTING
47 __data = memory();
48#endif
49 }
50
51 InlinedMemoryBlock(const InlinedMemoryBlock &other) FL_NOEXCEPT = default;
52 InlinedMemoryBlock(InlinedMemoryBlock &&other) FL_NOEXCEPT = default;
53
54 // u32 mRaw[N * sizeof(T)/sizeof(MemoryType) + kExtraSize];
55 // align this to the size of MemoryType.
56 // u32 mMemoryBlock[kTotalSize] = {0};
57 MemoryType mMemoryBlock[kBlockSize];
58
59 T *memory() FL_NOEXCEPT {
60 MemoryType *begin = &mMemoryBlock[0];
61 fl::uptr shift_up =
62 fl::ptr_to_int(begin) & (sizeof(MemoryType) - 1);
63 MemoryType *raw = begin + shift_up;
64 return fl::bit_cast<T *>(raw);
65 }
66
67 const T *memory() const FL_NOEXCEPT {
68 const MemoryType *begin = &mMemoryBlock[0];
69 const fl::uptr shift_up =
70 fl::ptr_to_int(begin) & (sizeof(MemoryType) - 1);
71 const MemoryType *raw = begin + shift_up;
72 return fl::bit_cast<const T *>(raw);
73 }
74
75#ifdef FASTLED_TESTING
76 T *__data = nullptr;
77#endif
78};
79
80// A fixed sized vector. The user is responsible for making sure that the
81// inserts do not exceed the capacity of the vector, otherwise they will fail.
82// Because of this limitation, this vector is not a drop in replacement for
83// std::vector. However it used for vector_inlined<T, N> which allows spill over
84// to a heap vector when size > N.
85template <typename T, fl::size N>
87 private:
88 InlinedMemoryBlock<T, N> mMemoryBlock;
89
90 T *memory() FL_NOEXCEPT { return mMemoryBlock.memory(); }
91
92 const T *memory() const FL_NOEXCEPT { return mMemoryBlock.memory(); }
93
94 public:
95 typedef T value_type;
96 typedef T *iterator;
97 typedef const T *const_iterator;
98 // Constructor
100
101 FixedVector(const T (&values)[N]) FL_NOEXCEPT : current_size(N) {
102 assign_array(values, N);
103 }
104
106 fl::swap(*this, other);
107 other.clear();
108 }
109
110 FixedVector(const FixedVector &other) FL_NOEXCEPT : current_size(other.current_size) {
111 assign_array(other.memory(), other.current_size);
112 }
113
114 template <fl::size M> FixedVector(T (&values)[M]) FL_NOEXCEPT : current_size(0) {
115 FL_STATIC_ASSERT(M <= N, "Too many elements for FixedVector");
116 assign_array(values, M);
117 }
118
119 // Initializer list constructor (C++11 and later) - uses fl::initializer_list
120 FixedVector(fl::initializer_list<T> init) FL_NOEXCEPT : current_size(0) {
121 if (init.size() > N) {
122 // Only assign the first N elements if the list is too long
123 auto it = init.begin();
124 for (fl::size i = 0; i < N && it != init.end(); ++i, ++it) {
125 push_back(*it);
126 }
127 } else {
128 for (const auto& value : init) {
130 }
131 }
132 }
133
134 // Implicit copy constructor from span (dynamic extent)
135 // Only copies up to N elements from the span
136 FixedVector(fl::span<const T, fl::size(-1)> s) FL_NOEXCEPT : current_size(0) {
137 fl::size count = s.size() < N ? s.size() : N;
138 for (fl::size i = 0; i < count; ++i) {
139 push_back(s[i]);
140 }
141 }
142
143 FixedVector &operator=(const FixedVector &other) FL_NOEXCEPT { // cppcheck-suppress operatorEqVarError
144 if (this != &other) {
145 assign_array(other.memory(), other.current_size);
146 }
147 return *this;
148 }
149
150 FixedVector &operator=(FixedVector &&other) FL_NOEXCEPT { // cppcheck-suppress operatorEqVarError
151 if (this != &other) {
152 fl::swap(*this, other);
153 other.clear();
154 }
155 return *this;
156 }
157
158 // Destructor
160
161 // Array subscript operator
162 T &operator[](fl::size index) FL_NOEXCEPT { return memory()[index]; }
163
164 // Const array subscript operator
165 const T &operator[](fl::size index) const FL_NOEXCEPT {
166 if (index >= current_size) {
167 const T *out = nullptr;
168 return *out; // Cause a nullptr dereference
169 }
170 return memory()[index];
171 }
172
173 void resize(fl::size n) FL_NOEXCEPT {
174 while (current_size < n) {
175 push_back(T());
176 }
177 while (current_size > n) {
178 pop_back();
179 }
180 }
181
182 // Get the current size of the vector
183 constexpr fl::size size() const FL_NOEXCEPT { return current_size; }
184
185 constexpr bool empty() const FL_NOEXCEPT { return current_size == 0; }
186
187 // Get the capacity of the vector
188 constexpr fl::size capacity() const FL_NOEXCEPT { return N; }
189
190 // Add an element to the end of the vector
191 void push_back(const T &value) FL_NOEXCEPT {
192 if (current_size < N) {
193 void *mem = &memory()[current_size];
194 new (mem) T(value);
195 ++current_size;
196 }
197 }
198
199 // Move version of push_back
201 if (current_size < N) {
202 void *mem = &memory()[current_size];
203 new (mem) T(fl::move(value));
204 ++current_size;
205 }
206 }
207
208 // Emplace back - construct in place
209 template<typename... Args>
210 void emplace_back(Args&&... args) FL_NOEXCEPT {
211 if (current_size < N) {
212 void *mem = &memory()[current_size];
213 new (mem) T(fl::forward<Args>(args)...);
214 ++current_size;
215 }
216 }
217
218 void reserve(fl::size n) FL_NOEXCEPT {
219 if (n > N) {
220 // This is a no-op for fixed size vectors
221 return;
222 }
223 }
224
225 void assign_array(const T *values, fl::size count) FL_NOEXCEPT {
226 clear();
227 for (fl::size i = 0; i < count; ++i) {
228 push_back(values[i]);
229 }
230 }
231
233 clear();
234 for (const_iterator it = begin; it != end; ++it) {
235 push_back(*it);
236 }
237 }
238
239 // Remove the last element from the vector
241 if (current_size > 0) {
242 --current_size;
243 memory()[current_size].~T();
244 }
245 }
246
247 // Clear the vector
249 while (current_size > 0) {
250 pop_back();
251 }
252 }
253
254 // Erase the element at the given iterator position
256 if (pos != end()) {
257 pos->~T();
258 // shift all elements to the left
259 for (iterator p = pos; p != end() - 1; ++p) {
260 new (p) T(fl::move(*(p + 1))); // Use move constructor
261 (p + 1)->~T();
262 }
263 --current_size;
264 }
265 return pos;
266 }
267
269 iterator it = find(value);
270 if (it != end()) {
271 erase(it);
272 }
273 return it;
274 }
275
277 for (iterator it = begin(); it != end(); ++it) {
278 if (*it == value) {
279 return it;
280 }
281 }
282 return end();
283 }
284
285 template <typename Predicate> iterator find_if(Predicate pred) FL_NOEXCEPT {
286 for (iterator it = begin(); it != end(); ++it) {
287 if (pred(*it)) {
288 return it;
289 }
290 }
291 return end();
292 }
293
295 if (current_size >= N) {
296 return false;
297 }
298
299 // Construct a new element at end() position using placement new
300 new (end()) T();
301 ++current_size;
302
303 // Shift elements from [pos, end-1) to the right by one position
304 for (iterator p = end() - 1; p > pos; --p) {
305 *p = fl::move(*(p - 1));
306 }
307
308 // Assign the new value to the insertion position
309 *pos = value;
310 return true;
311 }
312
313 // Move version of insert
315 if (current_size >= N) {
316 return false;
317 }
318
319 // Construct a new element at end() position using placement new
320 new (end()) T();
321 ++current_size;
322
323 // Shift elements from [pos, end-1) to the right by one position
324 for (iterator p = end() - 1; p > pos; --p) {
325 *p = fl::move(*(p - 1));
326 }
327
328 // Move-assign the new value to the insertion position
329 *pos = fl::move(value);
330 return true;
331 }
332
334 for (const_iterator it = begin(); it != end(); ++it) {
335 if (*it == value) {
336 return it;
337 }
338 }
339 return end();
340 }
341
343
344 const_iterator data() const FL_NOEXCEPT { return begin(); }
345
346 bool has(const T &value) const FL_NOEXCEPT { return find(value) != end(); }
347
348 // Access to first and last elements
349 T &front() FL_NOEXCEPT { return memory()[0]; }
350
351 const T &front() const FL_NOEXCEPT { return memory()[0]; }
352
353 T &back() FL_NOEXCEPT { return memory()[current_size - 1]; }
354
355 const T &back() const FL_NOEXCEPT { return memory()[current_size - 1]; }
356
357 // Reverse iterator types (same as vector)
361 T &operator*() FL_NOEXCEPT { return *(it - 1); }
362 T *operator->() FL_NOEXCEPT { return (it - 1); }
364 --it;
365 return *this;
366 }
367 bool operator==(const reverse_iterator &other) const FL_NOEXCEPT {
368 return it == other.it;
369 }
370 bool operator!=(const reverse_iterator &other) const FL_NOEXCEPT {
371 return it != other.it;
372 }
373 };
374
378 const T &operator*() const FL_NOEXCEPT { return *(it - 1); }
379 const T *operator->() const FL_NOEXCEPT { return (it - 1); }
381 --it;
382 return *this;
383 }
385 return it == other.it;
386 }
388 return it != other.it;
389 }
390 };
391
392 // Iterator support
393 iterator begin() FL_NOEXCEPT { return &memory()[0]; }
394 const_iterator begin() const FL_NOEXCEPT { return &memory()[0]; }
397
398 // Reverse iterator support
399 reverse_iterator rbegin() FL_NOEXCEPT { return reverse_iterator(end()); }
400 const_reverse_iterator rbegin() const FL_NOEXCEPT { return const_reverse_iterator(end()); }
401 reverse_iterator rend() FL_NOEXCEPT { return reverse_iterator(begin()); }
402 const_reverse_iterator rend() const FL_NOEXCEPT { return const_reverse_iterator(begin()); }
403
404 // Capacity management (no-op for fixed-size vector)
406 // No-op for fixed-size vectors
407 }
408
410 if (this == &other) return;
411 fl::size min_sz = fl::min(current_size, other.current_size);
412 fl::size max_sz = fl::max(current_size, other.current_size);
413 // Swap elements that exist in both vectors
414 for (fl::size i = 0; i < min_sz; ++i) {
415 fl::swap(memory()[i], other.memory()[i]);
416 }
417 // Move remaining elements from the larger to the smaller
418 if (current_size > other.current_size) {
419 for (fl::size i = min_sz; i < max_sz; ++i) {
420 T* src = memory() + i;
421 T* dst = other.memory() + i;
422 new (dst) T(fl::move(*src));
423 src->~T();
424 }
425 } else if (other.current_size > current_size) {
426 for (fl::size i = min_sz; i < max_sz; ++i) {
427 T* src = other.memory() + i;
428 T* dst = memory() + i;
429 new (dst) T(fl::move(*src));
430 src->~T();
431 }
432 }
433 fl::size temp_size = current_size;
434 current_size = other.current_size;
435 other.current_size = temp_size;
436 }
437
438 private:
439 fl::size current_size = 0;
440};
441
443// vector<T> — Thin template wrapper around vector_basic.
444// All memory management and element operations are in vector_basic (compiled once).
445// This class provides type safety, typed iterators, and sets up the ops table.
447
448template <typename T>
450 public:
451 typedef T value_type;
452 typedef T *iterator;
453 typedef const T *const_iterator;
454
458 T &operator*() FL_NOEXCEPT { return *(it - 1); }
459 T *operator->() FL_NOEXCEPT { return (it - 1); }
461 --it;
462 return *this;
463 }
464 bool operator==(const reverse_iterator &other) const FL_NOEXCEPT {
465 return it == other.it;
466 }
467 bool operator!=(const reverse_iterator &other) const FL_NOEXCEPT {
468 return it != other.it;
469 }
470 };
471
475 const T &operator*() const FL_NOEXCEPT { return *(it - 1); }
476 const T *operator->() const FL_NOEXCEPT { return (it - 1); }
478 --it;
479 return *this;
480 }
482 return it == other.it;
483 }
485 return it != other.it;
486 }
487 };
488
489 // ======= CONSTRUCTORS =======
490
491 // Default constructor
495
496 // Constructor with memory resource
498 : vector_basic(sizeof(T), resource, vector_element_ops_for<T>()) {}
499
500 // Constructor with size and value
501 vector(fl::size count, const T &value = T()) FL_NOEXCEPT
504 resize_value_impl(count, &value);
505 }
506
507 // Constructor with size, value, and memory resource
508 vector(fl::size count, const T &value, memory_resource* resource) FL_NOEXCEPT
509 : vector_basic(sizeof(T), resource, vector_element_ops_for<T>()) {
510 resize_value_impl(count, &value);
511 }
512
513 // Copy constructor
515 : vector_basic(sizeof(T), other.mResource,
517 copy_from(other);
518 }
519
520 // Move constructor
522 : vector_basic(sizeof(T), other.mResource,
524 move_from(other);
525 }
526
527 // Array constructor
528 template <fl::size N> vector(T (&values)[N]) FL_NOEXCEPT
531 reserve_impl(N);
532 for (fl::size i = 0; i < N; ++i) {
533 push_back(values[i]);
534 }
535 }
536
537 // Initializer list constructor
538 vector(fl::initializer_list<T> init) FL_NOEXCEPT
541 reserve_impl(init.size());
542 for (const auto& value : init) {
544 }
545 }
546
547 // Iterator-based constructor (SFINAE: exclude integral types to avoid
548 // ambiguity with vector(size, value) when called as vector(int, int))
549 template <typename InputIterator,
551 vector(InputIterator first, InputIterator last) FL_NOEXCEPT
554 for (auto it = first; it != last; ++it) {
555 push_back(*it);
556 }
557 }
558
559 // Span constructor
560 vector(span<const T, fl::size(-1)> s) FL_NOEXCEPT
563 reserve_impl(s.size());
564 for (fl::size i = 0; i < s.size(); ++i) {
565 push_back(s[i]);
566 }
567 }
568
569 // ======= ASSIGNMENT =======
570
572 if (this != &other) {
573 copy_from(other);
574 }
575 return *this;
576 }
577
579 if (this != &other) {
580 move_assign(other);
581 }
582 return *this;
583 }
584
585 // ======= DESTRUCTOR =======
586 // Base class ~vector_basic() handles cleanup via mOps
587
588 // ======= CAPACITY =======
589 // size(), empty(), capacity(), full() inherited from vector_basic
590
591 void reserve(fl::size n) FL_NOEXCEPT { reserve_impl(n); }
592
593 void resize(fl::size n) FL_NOEXCEPT { resize_impl(n); }
594
595 void resize(fl::size n, const T &value) FL_NOEXCEPT { resize_value_impl(n, &value); }
596
598
599 void ensure_size(fl::size n) FL_NOEXCEPT { reserve_impl(n); }
600
602
603 // ======= ELEMENT ACCESS =======
604
605 T &operator[](fl::size index) FL_NOEXCEPT {
606 return static_cast<T*>(mArray)[index];
607 }
608
609 const T &operator[](fl::size index) const FL_NOEXCEPT {
610 return static_cast<const T*>(mArray)[index];
611 }
612
613 T &front() FL_NOEXCEPT { return static_cast<T*>(mArray)[0]; }
614 const T &front() const FL_NOEXCEPT { return static_cast<const T*>(mArray)[0]; }
615
616 T &back() FL_NOEXCEPT { return static_cast<T*>(mArray)[mSize - 1]; }
617 const T &back() const FL_NOEXCEPT { return static_cast<const T*>(mArray)[mSize - 1]; }
618
619 T *data() FL_NOEXCEPT { return static_cast<T*>(mArray); }
620 const T *data() const FL_NOEXCEPT { return static_cast<const T*>(mArray); }
621
622 // ======= MODIFIERS =======
623
626
627 template <typename... Args>
628 void emplace_back(Args&&... args) FL_NOEXCEPT {
629 T tmp(fl::forward<Args>(args)...);
631 }
632
635
636 template <typename InputIt,
638 void assign(InputIt first, InputIt last) FL_NOEXCEPT {
639 clear();
640 for (auto it = first; it != last; ++it) {
641 push_back(*it);
642 }
643 }
644
645 void assign(fl::size new_cap, const T &value) FL_NOEXCEPT {
646 clear();
647 reserve_impl(new_cap);
648 for (fl::size i = 0; i < new_cap; ++i) {
650 }
651 }
652
653 // ======= ITERATORS =======
654
656 return mArray ? static_cast<T*>(mArray) : nullptr;
657 }
659 return mArray ? static_cast<const T*>(mArray) : nullptr;
660 }
662 return mArray ? static_cast<T*>(mArray) + mSize : nullptr;
663 }
665 return mArray ? static_cast<const T*>(mArray) + mSize : nullptr;
666 }
667
668 reverse_iterator rbegin() FL_NOEXCEPT { return reverse_iterator(end()); }
669 const_reverse_iterator rbegin() const FL_NOEXCEPT { return const_reverse_iterator(end()); }
670 reverse_iterator rend() FL_NOEXCEPT { return reverse_iterator(begin()); }
671 const_reverse_iterator rend() const FL_NOEXCEPT { return const_reverse_iterator(begin()); }
672
674 return mArray ? static_cast<const T*>(mArray) : nullptr;
675 }
677 return mArray ? static_cast<const T*>(mArray) + mSize : nullptr;
678 }
679
680 // ======= SEARCH =======
681
683 for (iterator it = begin(); it != end(); ++it) {
684 if (*it == value) return it;
685 }
686 return end();
687 }
688
690 for (const_iterator it = begin(); it != end(); ++it) {
691 if (*it == value) return it;
692 }
693 return end();
694 }
695
696 template <typename Predicate> iterator find_if(Predicate pred) FL_NOEXCEPT {
697 for (iterator it = begin(); it != end(); ++it) {
698 if (pred(*it)) return it;
699 }
700 return end();
701 }
702
703 bool has(const T &value) const FL_NOEXCEPT { return find(value) != end(); }
704
705 // ======= ERASE =======
706
707 // Standard STL-compatible erase that returns iterator to next element
709 if (pos == end() || empty()) return end();
710 fl::size index = pos - begin();
711 erase_impl(index);
712 return begin() + index;
713 }
714
715 // Extended erase with optional output parameter
716 bool erase(iterator pos, T *out_value) FL_NOEXCEPT {
717 if (pos == end() || empty()) return false;
718 if (out_value) {
719 *out_value = fl::move(*pos);
720 }
721 erase(pos);
722 return true;
723 }
724
725 void erase(const T &value) FL_NOEXCEPT {
726 iterator it = find(value);
727 if (it != end()) {
728 erase(it);
729 }
730 }
731
732 // Range erase: remove count elements starting at first
733 void erase_range(iterator first, fl::size count) FL_NOEXCEPT {
734 if (count == 0 || first >= end()) return;
735 fl::size index = first - begin();
736 if (index + count > mSize) count = mSize - index;
737 erase_range_impl(index, count);
738 }
739
740 // ======= INSERT =======
741
743 fl::size index = pos - begin();
744 fl::size old_size = mSize;
745 insert_copy_impl(index, &value);
746 return mSize > old_size;
747 }
748
750 fl::size index = pos - begin();
751 fl::size old_size = mSize;
752 insert_move_impl(index, &value);
753 return mSize > old_size;
754 }
755
756 // Range insert: insert elements from [first, last) before pos
757 template <typename InputIt>
758 iterator insert(iterator pos, InputIt first, InputIt last) FL_NOEXCEPT {
759 fl::size target_idx = pos - begin();
760 fl::size count = 0;
761 for (InputIt it = first; it != last; ++it) {
762 push_back(*it);
763 ++count;
764 }
765 if (count == 0) {
766 return begin() + target_idx;
767 }
768 // Rotate new elements into place via bubble swaps
769 fl::size src_start = mSize - count;
770 for (fl::size i = 0; i < count; ++i) {
771 for (fl::size j = src_start + i; j > target_idx + i; --j) {
772 fl::swap(static_cast<T*>(mArray)[j - 1],
773 static_cast<T*>(mArray)[j]);
774 }
775 }
776 return begin() + target_idx;
777 }
778
779 // ======= SWAP =======
780
781 void swap(vector &other) FL_NOEXCEPT { swap_impl(other); }
782 void swap(vector &&other) FL_NOEXCEPT { swap_impl(other); }
783
785 fl::swap(*a, *b);
786 }
787
788 // ======= COMPARISON =======
789
790 bool operator==(const vector &other) const FL_NOEXCEPT {
791 if (size() != other.size()) return false;
792 const T* a = static_cast<const T*>(mArray);
793 const T* b = static_cast<const T*>(other.mArray);
794 for (fl::size i = 0; i < size(); ++i) {
795 if (a[i] != b[i]) return false;
796 }
797 return true;
798 }
799
800 bool operator!=(const vector &other) const FL_NOEXCEPT { return !(*this == other); }
801
802 bool operator<(const vector &other) const FL_NOEXCEPT {
803 fl::size min_size = mSize < other.mSize ? mSize : other.mSize;
804 const T* a = static_cast<const T*>(mArray);
805 const T* b = static_cast<const T*>(other.mArray);
806 for (fl::size i = 0; i < min_size; ++i) {
807 if (a[i] < b[i]) return true;
808 if (a[i] > b[i]) return false;
809 }
810 return mSize < other.mSize;
811 }
812
813 bool operator<=(const vector &other) const FL_NOEXCEPT {
814 return *this < other || *this == other;
815 }
816
817 bool operator>(const vector &other) const FL_NOEXCEPT { return other < *this; }
818
819 bool operator>=(const vector &other) const FL_NOEXCEPT {
820 return *this > other || *this == other;
821 }
822
823 protected:
824 // For VectorN — constructor with inline buffer
825 vector(void* inlineBuffer, fl::size inlineCapacity) FL_NOEXCEPT
826 : vector_basic(inlineBuffer, inlineCapacity, sizeof(T),
828
829 vector(void* inlineBuffer, fl::size inlineCapacity, memory_resource* resource) FL_NOEXCEPT
830 : vector_basic(inlineBuffer, inlineCapacity, sizeof(T),
831 resource, vector_element_ops_for<T>()) {}
832};
833
835// VectorN<T, N> — Vector with inline buffer (replaces InlinedVector).
836// Same wrapper pattern fl::string uses on top of fl::basic_string:
837// the wrapper co-locates an inline buffer with the type-erased base.
838// When size <= N, data lives inline. When size > N, spills to heap.
839// Uses the offset trick from basic_string for trivial relocatability.
841
842template <typename T, fl::size INLINED_SIZE>
843class FL_ALIGN VectorN : public vector<T> {
844 private:
845 // Raw aligned storage — address is valid even before initialization,
846 // same pattern as fl::string::mInlineBuffer above basic_string.
847 FL_ALIGNAS(alignof(T) > alignof(fl::uptr) ? alignof(T) : alignof(fl::uptr))
848 char mInlineBuffer[INLINED_SIZE * sizeof(T)] = {};
849
850 T* inline_memory() FL_NOEXCEPT { return fl::bit_cast<T*>(mInlineBuffer); }
851
852 public:
853 using typename vector<T>::iterator;
854 using typename vector<T>::const_iterator;
855 using typename vector<T>::value_type;
856
858 : vector<T>(mInlineBuffer, INLINED_SIZE) {}
859
861 : vector<T>(mInlineBuffer, INLINED_SIZE, resource) {}
862
863 VectorN(fl::size count, const T& value = T()) FL_NOEXCEPT
864 : vector<T>(mInlineBuffer, INLINED_SIZE) {
865 this->resize_value_impl(count, &value);
866 }
867
869 : vector<T>(mInlineBuffer, INLINED_SIZE) {
870 this->copy_from(other);
871 }
872
873 template <fl::size M>
875 : vector<T>(mInlineBuffer, INLINED_SIZE) {
876 this->copy_from(other);
877 }
878
880 : vector<T>(mInlineBuffer, INLINED_SIZE) {
881 this->copy_from(other);
882 }
883
885 : vector<T>(mInlineBuffer, INLINED_SIZE) {
886 this->move_from(other);
887 }
888
889 VectorN(fl::initializer_list<T> init) FL_NOEXCEPT
890 : vector<T>(mInlineBuffer, INLINED_SIZE) {
891 this->reserve_impl(init.size());
892 for (const auto& value : init) {
893 this->push_back(value);
894 }
895 }
896
898 if (this != &other) {
899 this->copy_from(other);
900 }
901 return *this;
902 }
903
905 if (this != &other) {
906 this->move_assign(other);
907 }
908 return *this;
909 }
910};
911
913// vector_psram<T> — Vector that allocates from PSRAM by default.
915
916template <typename T>
917class vector_psram : public vector<T> {
918 public:
921
922 vector_psram(fl::size count, const T& value = T()) FL_NOEXCEPT
923 : vector<T>(count, value, psram_memory_resource()) {}
924
925 vector_psram(fl::initializer_list<T> init) FL_NOEXCEPT
927 this->reserve_impl(init.size());
928 for (const auto& value : init) {
929 this->push_back(value);
930 }
931 }
932
933 // Iterator-range constructor
934 template <typename InputIterator,
936 vector_psram(InputIterator first, InputIterator last) FL_NOEXCEPT
938 for (auto it = first; it != last; ++it) {
939 this->push_back(*it);
940 }
941 }
942
945 this->copy_from(other);
946 }
947
952
954 if (this != &other) {
955 this->copy_from(other);
956 }
957 return *this;
958 }
959
961 if (this != &other) {
962 this->move_assign(other);
963 }
964 return *this;
965 }
966};
967
969// SortedHeapVector — sorted wrapper around vector<T>
971
972template <typename T, typename LessThan = fl::less<T>>
974 private:
976 LessThan mLess;
977 fl::size mMaxSize = fl::size(-1);
978
979 public:
980 enum insert_result { inserted = 0, exists = 1, at_capacity = 2 };
981
982 typedef T value_type;
987
988 SortedHeapVector(LessThan less = LessThan()) FL_NOEXCEPT : mLess(less) {}
989
990 // Copy constructor
991 SortedHeapVector(const SortedHeapVector& other) = default;
992
993 // Copy assignment
995
996 // Move constructor
998 : mArray(fl::move(other.mArray))
999 , mLess(fl::move(other.mLess))
1000 , mMaxSize(other.mMaxSize) {
1001 other.mMaxSize = fl::size(-1);
1002 }
1003
1004 // Move assignment operator
1006 if (this != &other) {
1007 mArray = fl::move(other.mArray);
1008 mLess = fl::move(other.mLess);
1009 mMaxSize = other.mMaxSize;
1010 other.mMaxSize = fl::size(-1);
1011 }
1012 return *this;
1013 }
1014
1015 void setMaxSize(fl::size n) FL_NOEXCEPT {
1016 if (mMaxSize == n) return;
1017 mMaxSize = n;
1018 const bool needs_adjustment = mArray.size() > mMaxSize;
1019 if (needs_adjustment) {
1020 mArray.resize(n);
1021 } else {
1022 mArray.reserve(n);
1023 }
1024 }
1025
1027
1028 void reserve(fl::size n) FL_NOEXCEPT { mArray.reserve(n); }
1029
1030 // Insert while maintaining sort order
1031 bool insert(const T &value, insert_result *result = nullptr) FL_NOEXCEPT {
1033 if (pos != end() && !mLess(value, *pos) && !mLess(*pos, value)) {
1034 if (result) *result = exists;
1035 return false;
1036 }
1037 if (mArray.size() >= mMaxSize) {
1038 if (result) *result = at_capacity;
1039 return false;
1040 }
1041 mArray.insert(pos, value);
1042 if (result) *result = inserted;
1043 return true;
1044 }
1045
1047 iterator first = mArray.begin();
1048 iterator last = mArray.end();
1049 while (first != last) {
1050 iterator mid = first + (last - first) / 2;
1051 if (mLess(*mid, value)) {
1052 first = mid + 1;
1053 } else {
1054 last = mid;
1055 }
1056 }
1057 return first;
1058 }
1059
1061 return const_cast<SortedHeapVector *>(this)->lower_bound(value);
1062 }
1063
1066 if (pos != end() && !mLess(value, *pos) && !mLess(*pos, value)) {
1067 return pos;
1068 }
1069 return end();
1070 }
1071
1072 void swap(SortedHeapVector &other) FL_NOEXCEPT { mArray.swap(other.mArray); }
1073
1075 return const_cast<SortedHeapVector *>(this)->find(value);
1076 }
1077
1078 bool has(const T &value) const FL_NOEXCEPT { return find(value) != end(); }
1079
1080 bool erase(const T &value) FL_NOEXCEPT {
1081 iterator it = find(value);
1082 if (it != end()) {
1083 mArray.erase(it);
1084 return true;
1085 }
1086 return false;
1087 }
1088
1090
1091 fl::size size() const FL_NOEXCEPT { return mArray.size(); }
1092 bool empty() const FL_NOEXCEPT { return mArray.empty(); }
1093 fl::size capacity() const FL_NOEXCEPT { return mArray.capacity(); }
1094
1095 void clear() FL_NOEXCEPT { mArray.clear(); }
1096 bool full() const FL_NOEXCEPT {
1097 if (mArray.size() >= mMaxSize) return true;
1098 return mArray.full();
1099 }
1100
1101 T &operator[](fl::size index) FL_NOEXCEPT { return mArray[index]; }
1102 const T &operator[](fl::size index) const FL_NOEXCEPT { return mArray[index]; }
1103
1104 T &front() FL_NOEXCEPT { return mArray.front(); }
1105 const T &front() const FL_NOEXCEPT { return mArray.front(); }
1106
1107 T &back() FL_NOEXCEPT { return mArray.back(); }
1108 const T &back() const FL_NOEXCEPT { return mArray.back(); }
1109
1110 iterator begin() FL_NOEXCEPT { return mArray.begin(); }
1111 const_iterator begin() const FL_NOEXCEPT { return mArray.begin(); }
1112 iterator end() FL_NOEXCEPT { return mArray.end(); }
1113 const_iterator end() const FL_NOEXCEPT { return mArray.end(); }
1114
1119
1120 // Raw data access
1121 T *data() FL_NOEXCEPT { return mArray.data(); }
1122 const T *data() const FL_NOEXCEPT { return mArray.data(); }
1123};
1124
1126// Type aliases
1128
1129template <typename T, fl::size INLINED_SIZE>
1131
1132template <typename T, fl::size INLINED_SIZE = 64>
1134
1135// Backward compat: InlinedVector is now VectorN
1136template <typename T, fl::size INLINED_SIZE>
1138
1139} // namespace fl
uint8_t pos
Definition Blur.ino:11
Alignment macros and utilities for FastLED.
Type-erased base class for fl::vector<T>.
iterator data() FL_NOEXCEPT
Definition vector.h:342
bool insert(iterator pos, const T &value) FL_NOEXCEPT
Definition vector.h:294
bool has(const T &value) const FL_NOEXCEPT
Definition vector.h:346
const T & back() const FL_NOEXCEPT
Definition vector.h:355
void shrink_to_fit() FL_NOEXCEPT
Definition vector.h:405
void emplace_back(Args &&... args) FL_NOEXCEPT
Definition vector.h:210
FixedVector(const FixedVector &other) FL_NOEXCEPT
Definition vector.h:110
const_iterator begin() const FL_NOEXCEPT
Definition vector.h:394
FixedVector(FixedVector &&other) FL_NOEXCEPT
Definition vector.h:105
void assign_array(const fl::u32 *values, fl::size count) FL_NOEXCEPT
Definition vector.h:225
InlinedMemoryBlock< fl::u32, N > mMemoryBlock
Definition vector.h:88
FixedVector(fl::span< const T, fl::size(-1)> s) FL_NOEXCEPT
Definition vector.h:136
FixedVector & operator=(FixedVector &&other) FL_NOEXCEPT
Definition vector.h:150
const T * memory() const FL_NOEXCEPT
Definition vector.h:92
const_iterator data() const FL_NOEXCEPT
Definition vector.h:344
void assign(const_iterator begin, const_iterator end) FL_NOEXCEPT
Definition vector.h:232
FixedVector(T(&values)[M]) FL_NOEXCEPT
Definition vector.h:114
T & front() FL_NOEXCEPT
Definition vector.h:349
void reserve(fl::size n) FL_NOEXCEPT
Definition vector.h:218
void swap(FixedVector< T, N > &other) FL_NOEXCEPT
Definition vector.h:409
const T & front() const FL_NOEXCEPT
Definition vector.h:351
reverse_iterator rend() FL_NOEXCEPT
Definition vector.h:401
void push_back(const fl::u32 &value) FL_NOEXCEPT
Definition vector.h:191
bool insert(iterator pos, T &&value) FL_NOEXCEPT
Definition vector.h:314
iterator find_if(Predicate pred) FL_NOEXCEPT
Definition vector.h:285
void push_back(T &&value) FL_NOEXCEPT
Definition vector.h:200
iterator erase(const T &value) FL_NOEXCEPT
Definition vector.h:268
T * memory() FL_NOEXCEPT
Definition vector.h:90
const_reverse_iterator rend() const FL_NOEXCEPT
Definition vector.h:402
const_reverse_iterator rbegin() const FL_NOEXCEPT
Definition vector.h:400
const_iterator end() const FL_NOEXCEPT
Definition vector.h:396
~FixedVector() FL_NOEXCEPT
Definition vector.h:159
reverse_iterator rbegin() FL_NOEXCEPT
Definition vector.h:399
constexpr bool empty() const FL_NOEXCEPT
Definition vector.h:185
FixedVector & operator=(const FixedVector &other) FL_NOEXCEPT
Definition vector.h:143
T & operator[](fl::size index) FL_NOEXCEPT
Definition vector.h:162
iterator erase(iterator pos) FL_NOEXCEPT
Definition vector.h:255
FixedVector(const T(&values)[N]) FL_NOEXCEPT
Definition vector.h:101
constexpr fl::size capacity() const FL_NOEXCEPT
Definition vector.h:188
const_iterator find(const T &value) const FL_NOEXCEPT
Definition vector.h:333
FixedVector(fl::initializer_list< T > init) FL_NOEXCEPT
Definition vector.h:120
T & back() FL_NOEXCEPT
Definition vector.h:353
constexpr FixedVector() FL_NOEXCEPT
Definition vector.h:99
iterator find(const fl::u32 &value) FL_NOEXCEPT
Definition vector.h:276
constexpr fl::size size() const FL_NOEXCEPT
Definition vector.h:183
void resize(fl::size n) FL_NOEXCEPT
Definition vector.h:173
const T & operator[](fl::size index) const FL_NOEXCEPT
Definition vector.h:165
const_iterator find(const T &value) const FL_NOEXCEPT
Definition vector.h:1074
fl::size size() const FL_NOEXCEPT
Definition vector.h:1091
bool empty() const FL_NOEXCEPT
Definition vector.h:1092
const_reverse_iterator rend() const FL_NOEXCEPT
Definition vector.h:1118
iterator begin() FL_NOEXCEPT
Definition vector.h:1110
void clear() FL_NOEXCEPT
Definition vector.h:1095
SortedHeapVector & operator=(SortedHeapVector &&other) FL_NOEXCEPT
Definition vector.h:1005
const_reverse_iterator rbegin() const FL_NOEXCEPT
Definition vector.h:1116
iterator erase(iterator pos) FL_NOEXCEPT
Definition vector.h:1089
vector< T >::iterator iterator
Definition vector.h:983
vector< T > mArray
Definition vector.h:975
iterator lower_bound(const T &value) FL_NOEXCEPT
Definition vector.h:1046
bool full() const FL_NOEXCEPT
Definition vector.h:1096
bool erase(const T &value) FL_NOEXCEPT
Definition vector.h:1080
reverse_iterator rend() FL_NOEXCEPT
Definition vector.h:1117
vector< T >::const_iterator const_iterator
Definition vector.h:984
const T & front() const FL_NOEXCEPT
Definition vector.h:1105
void setMaxSize(fl::size n) FL_NOEXCEPT
Definition vector.h:1015
T & back() FL_NOEXCEPT
Definition vector.h:1107
T * data() FL_NOEXCEPT
Definition vector.h:1121
T & front() FL_NOEXCEPT
Definition vector.h:1104
const T & back() const FL_NOEXCEPT
Definition vector.h:1108
SortedHeapVector & operator=(const SortedHeapVector &other)=default
void swap(SortedHeapVector &other) FL_NOEXCEPT
Definition vector.h:1072
const_iterator lower_bound(const T &value) const FL_NOEXCEPT
Definition vector.h:1060
iterator find(const T &value) FL_NOEXCEPT
Definition vector.h:1064
vector< T >::const_reverse_iterator const_reverse_iterator
Definition vector.h:986
vector< T >::reverse_iterator reverse_iterator
Definition vector.h:985
~SortedHeapVector() FL_NOEXCEPT
Definition vector.h:1026
const T & operator[](fl::size index) const FL_NOEXCEPT
Definition vector.h:1102
const_iterator begin() const FL_NOEXCEPT
Definition vector.h:1111
SortedHeapVector(const SortedHeapVector &other)=default
const T * data() const FL_NOEXCEPT
Definition vector.h:1122
fl::size mMaxSize
Definition vector.h:977
iterator end() FL_NOEXCEPT
Definition vector.h:1112
bool insert(const T &value, insert_result *result=nullptr) FL_NOEXCEPT
Definition vector.h:1031
T & operator[](fl::size index) FL_NOEXCEPT
Definition vector.h:1101
SortedHeapVector(LessThan less=LessThan()) FL_NOEXCEPT
Definition vector.h:988
bool has(const T &value) const FL_NOEXCEPT
Definition vector.h:1078
const_iterator end() const FL_NOEXCEPT
Definition vector.h:1113
SortedHeapVector(SortedHeapVector &&other) FL_NOEXCEPT
Definition vector.h:997
reverse_iterator rbegin() FL_NOEXCEPT
Definition vector.h:1115
void reserve(fl::size n) FL_NOEXCEPT
Definition vector.h:1028
fl::size capacity() const FL_NOEXCEPT
Definition vector.h:1093
VectorN(const VectorN< T, M > &other) FL_NOEXCEPT
Definition vector.h:874
VectorN(const VectorN &other) FL_NOEXCEPT
Definition vector.h:868
VectorN & operator=(const VectorN &other) FL_NOEXCEPT
Definition vector.h:897
VectorN(fl::initializer_list< T > init) FL_NOEXCEPT
Definition vector.h:889
VectorN & operator=(VectorN &&other) FL_NOEXCEPT
Definition vector.h:904
VectorN(memory_resource *resource) FL_NOEXCEPT
Definition vector.h:860
VectorN(const vector< T > &other) FL_NOEXCEPT
Definition vector.h:879
VectorN() FL_NOEXCEPT
Definition vector.h:857
FL_ALIGNAS(alignof(T) > alignof(fl::uptr) ? alignof(T) :alignof(fl::uptr)) char mInlineBuffer[INLINED_SIZE *sizeof(T)]
VectorN(VectorN &&other) FL_NOEXCEPT
Definition vector.h:884
VectorN(fl::size count, const T &value=T()) FL_NOEXCEPT
Definition vector.h:863
T * inline_memory() FL_NOEXCEPT
Definition vector.h:850
Polymorphic memory resource base class (PMR-style).
void resize_value_impl(fl::size n, const void *value) FL_NOEXCEPT
Resize to n elements. New elements are copy-constructed from value.
void resize_impl(fl::size n) FL_NOEXCEPT
Resize to n elements. New elements are default-constructed (zeroed for trivial).
void erase_impl(fl::size index) FL_NOEXCEPT
Erase element at index. Shifts subsequent elements left.
void reserve_impl(fl::size n) FL_NOEXCEPT
void push_back_move_impl(void *element) FL_NOEXCEPT
void shrink_to_fit_impl() FL_NOEXCEPT
void insert_move_impl(fl::size index, void *element) FL_NOEXCEPT
Insert element at index by move. Shifts subsequent elements right.
memory_resource * mResource
void move_from(vector_basic &other) FL_NOEXCEPT
Move-steal contents from another vector_basic.
vector_basic(fl::size elementSize, memory_resource *resource, const vector_element_ops *ops) FL_NOEXCEPT
Heap-only vector (no inline buffer).
fl::size size() const FL_NOEXCEPT
void insert_copy_impl(fl::size index, const void *element) FL_NOEXCEPT
Insert element at index by copy. Shifts subsequent elements right.
void move_assign(vector_basic &other) FL_NOEXCEPT
Move-assign from another vector_basic (clears this first).
void copy_from(const vector_basic &other) FL_NOEXCEPT
Copy all elements from another vector_basic.
void clear_impl() FL_NOEXCEPT
bool empty() const FL_NOEXCEPT
void swap_impl(vector_basic &other) FL_NOEXCEPT
Swap contents with another vector_basic.
void pop_back_impl() FL_NOEXCEPT
void push_back_copy_impl(const void *element) FL_NOEXCEPT
void erase_range_impl(fl::size first_index, fl::size count) FL_NOEXCEPT
Erase range [first_index, first_index + count).
vector_psram(fl::size count, const T &value=T()) FL_NOEXCEPT
Definition vector.h:922
vector_psram & operator=(vector_psram &&other) FL_NOEXCEPT
Definition vector.h:960
vector_psram(fl::initializer_list< T > init) FL_NOEXCEPT
Definition vector.h:925
vector_psram & operator=(const vector_psram &other) FL_NOEXCEPT
Definition vector.h:953
vector_psram(vector_psram &&other) FL_NOEXCEPT
Definition vector.h:948
vector_psram() FL_NOEXCEPT
Definition vector.h:919
vector_psram(const vector_psram &other) FL_NOEXCEPT
Definition vector.h:943
vector_psram(InputIterator first, InputIterator last) FL_NOEXCEPT
Definition vector.h:936
bool operator>(const vector &other) const FL_NOEXCEPT
Definition vector.h:817
iterator erase(iterator pos) FL_NOEXCEPT
Definition vector.h:708
iterator begin() FL_NOEXCEPT
Definition vector.h:655
const fl::i16 * const_iterator
Definition vector.h:453
const_iterator end() const FL_NOEXCEPT
Definition vector.h:664
bool operator<=(const vector &other) const FL_NOEXCEPT
Definition vector.h:813
T * data() FL_NOEXCEPT
Definition vector.h:619
T & back() FL_NOEXCEPT
Definition vector.h:616
iterator find(const T &value) FL_NOEXCEPT
Definition vector.h:682
bool insert(iterator pos, const T &value) FL_NOEXCEPT
Definition vector.h:742
vector(void *inlineBuffer, fl::size inlineCapacity) FL_NOEXCEPT
Definition vector.h:825
bool has(const T &value) const FL_NOEXCEPT
Definition vector.h:703
iterator insert(iterator pos, InputIt first, InputIt last) FL_NOEXCEPT
Definition vector.h:758
void emplace_back(Args &&... args) FL_NOEXCEPT
Definition vector.h:628
vector(vector &&other) FL_NOEXCEPT
Definition vector.h:521
vector(fl::initializer_list< T > init) FL_NOEXCEPT
Definition vector.h:538
void reserve(fl::size n) FL_NOEXCEPT
Definition vector.h:591
vector(const vector &other) FL_NOEXCEPT
Definition vector.h:514
bool operator>=(const vector &other) const FL_NOEXCEPT
Definition vector.h:819
iterator end() FL_NOEXCEPT
Definition vector.h:661
const_iterator cbegin() const FL_NOEXCEPT
Definition vector.h:673
bool operator!=(const vector &other) const FL_NOEXCEPT
Definition vector.h:800
const T * data() const FL_NOEXCEPT
Definition vector.h:620
vector(memory_resource *resource) FL_NOEXCEPT
Definition vector.h:497
void swap(iterator a, iterator b) FL_NOEXCEPT
Definition vector.h:784
void clear() FL_NOEXCEPT
Definition vector.h:634
fl::i16 * iterator
Definition vector.h:452
bool operator<(const vector &other) const FL_NOEXCEPT
Definition vector.h:802
void assign(fl::size new_cap, const T &value) FL_NOEXCEPT
Definition vector.h:645
vector(InputIterator first, InputIterator last) FL_NOEXCEPT
Definition vector.h:551
const T & operator[](fl::size index) const FL_NOEXCEPT
Definition vector.h:609
const_iterator begin() const FL_NOEXCEPT
Definition vector.h:658
void push_back(T &&value) FL_NOEXCEPT
Definition vector.h:625
void erase(const T &value) FL_NOEXCEPT
Definition vector.h:725
vector(fl::size count, const T &value, memory_resource *resource) FL_NOEXCEPT
Definition vector.h:508
void assign(InputIt first, InputIt last) FL_NOEXCEPT
Definition vector.h:638
T & front() FL_NOEXCEPT
Definition vector.h:613
void ensure_size(fl::size n) FL_NOEXCEPT
Definition vector.h:599
const T & back() const FL_NOEXCEPT
Definition vector.h:617
void swap(vector &other) FL_NOEXCEPT
Definition vector.h:781
vector & operator=(const vector &other) FL_NOEXCEPT
Definition vector.h:571
bool insert(iterator pos, T &&value) FL_NOEXCEPT
Definition vector.h:749
const_reverse_iterator rbegin() const FL_NOEXCEPT
Definition vector.h:669
const_reverse_iterator rend() const FL_NOEXCEPT
Definition vector.h:671
T & operator[](fl::size index) FL_NOEXCEPT
Definition vector.h:605
reverse_iterator rbegin() FL_NOEXCEPT
Definition vector.h:668
void pop_back() FL_NOEXCEPT
Definition vector.h:633
void shrink_to_fit() FL_NOEXCEPT
Definition vector.h:597
void swap(vector &&other) FL_NOEXCEPT
Definition vector.h:782
vector(T(&values)[N]) FL_NOEXCEPT
Definition vector.h:528
vector(fl::size count, const T &value=T()) FL_NOEXCEPT
Definition vector.h:501
memory_resource * get_resource() const FL_NOEXCEPT
Definition vector.h:601
void resize(fl::size n, const T &value) FL_NOEXCEPT
Definition vector.h:595
iterator find_if(Predicate pred) FL_NOEXCEPT
Definition vector.h:696
reverse_iterator rend() FL_NOEXCEPT
Definition vector.h:670
vector & operator=(vector &&other) FL_NOEXCEPT
Definition vector.h:578
vector() FL_NOEXCEPT
Definition vector.h:492
const_iterator cend() const FL_NOEXCEPT
Definition vector.h:676
void erase_range(iterator first, fl::size count) FL_NOEXCEPT
Definition vector.h:733
const_iterator find(const T &value) const FL_NOEXCEPT
Definition vector.h:689
vector(void *inlineBuffer, fl::size inlineCapacity, memory_resource *resource) FL_NOEXCEPT
Definition vector.h:829
void push_back(const fl::i16 &value) FL_NOEXCEPT
Definition vector.h:624
vector(span< const T, fl::size(-1)> s) FL_NOEXCEPT
Definition vector.h:560
bool operator==(const vector &other) const FL_NOEXCEPT
Definition vector.h:790
const T & front() const FL_NOEXCEPT
Definition vector.h:614
void resize(fl::size n) FL_NOEXCEPT
Definition vector.h:593
bool erase(iterator pos, T *out_value) FL_NOEXCEPT
Definition vector.h:716
constexpr T && forward(typename remove_reference< T >::type &t) FL_NOEXCEPT
Definition s16x16x4.h:234
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
Definition s16x16x4.h:28
max_align_selector<(sizeof(longdouble)>sizeof(double))>::type max_align_t
Definition s16x16x4.h:56
typename enable_if< Condition, T >::type enable_if_t
Definition s16x16x4.h:66
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Definition math.h:71
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
Definition move.h:28
constexpr int type_rank< T >::value
VectorN< T, INLINED_SIZE > InlinedVector
Definition span.h:21
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75
void init(Context &ctx, int w, int h)
Definition engine.h:133
constexpr T * begin(T(&array)[N]) FL_NOEXCEPT
uptr ptr_to_int(T *ptr) FL_NOEXCEPT
Definition bit_cast.h:71
void * memset(void *s, int c, size_t n) FL_NOEXCEPT
memory_resource * default_memory_resource() FL_NOEXCEPT
Get the default memory resource (wraps fl::Malloc / fl::Free / fl::realloc).
void swap(array< T, N > &lhs, array< T, N > &rhs) FL_NOEXCEPT
Definition array.h:209
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
struct FL_ALIGNAS(4) Wave3BitExpansionLut
Lookup table for nibble-to-waveform expansion in wave3 format (32 bytes)
Definition wave3.h:31
const vector_element_ops * vector_element_ops_for() FL_NOEXCEPT
Generate a static ops table for type T.
memory_resource * psram_memory_resource()
Get the PSRAM memory resource (wraps PSRamAllocate / PSRamDeallocate).
VectorN< T, INLINED_SIZE > vector_inlined
Definition vector.h:1133
To bit_cast(const From &from) FL_NOEXCEPT
Definition bit_cast.h:48
FixedVector< T, INLINED_SIZE > vector_fixed
Definition vector.h:1130
Base definition for an LED controller.
Definition crgb.hpp:179
corkscrew_args args
Definition old.h:149
#define FL_STATIC_ASSERT(...)
#define FL_NOEXCEPT
#define FL_ALIGN
Portable compile-time assertion wrapper.
bool operator!=(const const_reverse_iterator &other) const FL_NOEXCEPT
Definition vector.h:387
bool operator==(const const_reverse_iterator &other) const FL_NOEXCEPT
Definition vector.h:384
const T * operator->() const FL_NOEXCEPT
Definition vector.h:379
const_reverse_iterator(const_iterator i) FL_NOEXCEPT
Definition vector.h:377
const_reverse_iterator & operator++() FL_NOEXCEPT
Definition vector.h:380
const T & operator*() const FL_NOEXCEPT
Definition vector.h:378
reverse_iterator(iterator i) FL_NOEXCEPT
Definition vector.h:360
reverse_iterator & operator++() FL_NOEXCEPT
Definition vector.h:363
T & operator*() FL_NOEXCEPT
Definition vector.h:361
bool operator==(const reverse_iterator &other) const FL_NOEXCEPT
Definition vector.h:367
T * operator->() FL_NOEXCEPT
Definition vector.h:362
bool operator!=(const reverse_iterator &other) const FL_NOEXCEPT
Definition vector.h:370
Binary function object that returns whether the first argument is less than the second.
Definition utility.h:15
const T & operator*() const FL_NOEXCEPT
Definition vector.h:475
const_reverse_iterator(const_iterator i) FL_NOEXCEPT
Definition vector.h:474
const_reverse_iterator & operator++() FL_NOEXCEPT
Definition vector.h:477
bool operator!=(const const_reverse_iterator &other) const FL_NOEXCEPT
Definition vector.h:484
bool operator==(const const_reverse_iterator &other) const FL_NOEXCEPT
Definition vector.h:481
const T * operator->() const FL_NOEXCEPT
Definition vector.h:476
reverse_iterator & operator++() FL_NOEXCEPT
Definition vector.h:460
T & operator*() FL_NOEXCEPT
Definition vector.h:458
T * operator->() FL_NOEXCEPT
Definition vector.h:459
reverse_iterator(iterator i) FL_NOEXCEPT
Definition vector.h:457
bool operator==(const reverse_iterator &other) const FL_NOEXCEPT
Definition vector.h:464
bool operator!=(const reverse_iterator &other) const FL_NOEXCEPT
Definition vector.h:467