FastLED 3.10.8
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_NO_EXCEPT {
45 fl::memset(mMemoryBlock, 0, sizeof(mMemoryBlock));
46#ifdef FASTLED_TESTING
47 __data = memory();
48#endif
49 }
50
51 InlinedMemoryBlock(const InlinedMemoryBlock &other) FL_NO_EXCEPT = default;
52 InlinedMemoryBlock(InlinedMemoryBlock &&other) FL_NO_EXCEPT = 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_NO_EXCEPT {
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_NO_EXCEPT {
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_NO_EXCEPT { return mMemoryBlock.memory(); }
91
92 const T *memory() const FL_NO_EXCEPT { 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_NO_EXCEPT : 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_NO_EXCEPT : 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_NO_EXCEPT : 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_NO_EXCEPT : 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_NO_EXCEPT : 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_NO_EXCEPT { // 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_NO_EXCEPT { // 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_NO_EXCEPT { return memory()[index]; }
163
164 // Const array subscript operator
165 const T &operator[](fl::size index) const FL_NO_EXCEPT {
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_NO_EXCEPT {
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_NO_EXCEPT { return current_size; }
184
185 constexpr bool empty() const FL_NO_EXCEPT { return current_size == 0; }
186
187 // Get the capacity of the vector
188 constexpr fl::size capacity() const FL_NO_EXCEPT { return N; }
189
190 // Add an element to the end of the vector
191 void push_back(const T &value) FL_NO_EXCEPT {
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>
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_NO_EXCEPT {
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_NO_EXCEPT {
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_NO_EXCEPT {
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_NO_EXCEPT { return begin(); }
345
346 bool has(const T &value) const FL_NO_EXCEPT { return find(value) != end(); }
347
348 // Access to first and last elements
349 T &front() FL_NO_EXCEPT { return memory()[0]; }
350
351 const T &front() const FL_NO_EXCEPT { return memory()[0]; }
352
353 T &back() FL_NO_EXCEPT { return memory()[current_size - 1]; }
354
355 const T &back() const FL_NO_EXCEPT { return memory()[current_size - 1]; }
356
357 // Reverse iterator types (same as vector)
361 T &operator*() FL_NO_EXCEPT { return *(it - 1); }
362 T *operator->() FL_NO_EXCEPT { return (it - 1); }
364 --it;
365 return *this;
366 }
367 bool operator==(const reverse_iterator &other) const FL_NO_EXCEPT {
368 return it == other.it;
369 }
370 bool operator!=(const reverse_iterator &other) const FL_NO_EXCEPT {
371 return it != other.it;
372 }
373 };
374
378 const T &operator*() const FL_NO_EXCEPT { return *(it - 1); }
379 const T *operator->() const FL_NO_EXCEPT { 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_NO_EXCEPT { return &memory()[0]; }
394 const_iterator begin() const FL_NO_EXCEPT { return &memory()[0]; }
397
398 // Reverse iterator support
399 reverse_iterator rbegin() FL_NO_EXCEPT { return reverse_iterator(end()); }
400 const_reverse_iterator rbegin() const FL_NO_EXCEPT { return const_reverse_iterator(end()); }
401 reverse_iterator rend() FL_NO_EXCEPT { return reverse_iterator(begin()); }
402 const_reverse_iterator rend() const FL_NO_EXCEPT { 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_NO_EXCEPT { return *(it - 1); }
459 T *operator->() FL_NO_EXCEPT { return (it - 1); }
461 --it;
462 return *this;
463 }
464 bool operator==(const reverse_iterator &other) const FL_NO_EXCEPT {
465 return it == other.it;
466 }
467 bool operator!=(const reverse_iterator &other) const FL_NO_EXCEPT {
468 return it != other.it;
469 }
470 };
471
475 const T &operator*() const FL_NO_EXCEPT { return *(it - 1); }
476 const T *operator->() const FL_NO_EXCEPT { 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_NO_EXCEPT
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_NO_EXCEPT
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_NO_EXCEPT
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_NO_EXCEPT
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_NO_EXCEPT
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_NO_EXCEPT
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_NO_EXCEPT { reserve_impl(n); }
592
593 void resize(fl::size n) FL_NO_EXCEPT { resize_impl(n); }
594
595 void resize(fl::size n, const T &value) FL_NO_EXCEPT { resize_value_impl(n, &value); }
596
598
599 void ensure_size(fl::size n) FL_NO_EXCEPT { reserve_impl(n); }
600
602
603 // ======= ELEMENT ACCESS =======
604
605 T &operator[](fl::size index) FL_NO_EXCEPT {
606 return static_cast<T*>(mArray)[index];
607 }
608
609 const T &operator[](fl::size index) const FL_NO_EXCEPT {
610 return static_cast<const T*>(mArray)[index];
611 }
612
613 T &front() FL_NO_EXCEPT { return static_cast<T*>(mArray)[0]; }
614 const T &front() const FL_NO_EXCEPT { return static_cast<const T*>(mArray)[0]; }
615
616 T &back() FL_NO_EXCEPT { return static_cast<T*>(mArray)[mSize - 1]; }
617 const T &back() const FL_NO_EXCEPT { return static_cast<const T*>(mArray)[mSize - 1]; }
618
619 T *data() FL_NO_EXCEPT { return static_cast<T*>(mArray); }
620 const T *data() const FL_NO_EXCEPT { return static_cast<const T*>(mArray); }
621
622 // ======= MODIFIERS =======
623
626
627 template <typename... Args>
629 T tmp(fl::forward<Args>(args)...);
631 }
632
635
636 template <typename InputIt,
638 void assign(InputIt first, InputIt last) FL_NO_EXCEPT {
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_NO_EXCEPT {
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_NO_EXCEPT { return reverse_iterator(end()); }
669 const_reverse_iterator rbegin() const FL_NO_EXCEPT { return const_reverse_iterator(end()); }
670 reverse_iterator rend() FL_NO_EXCEPT { return reverse_iterator(begin()); }
671 const_reverse_iterator rend() const FL_NO_EXCEPT { 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_NO_EXCEPT {
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_NO_EXCEPT { 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_NO_EXCEPT {
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_NO_EXCEPT {
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_NO_EXCEPT {
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_NO_EXCEPT {
759 fl::size target_idx = pos - begin();
760 fl::size count = 0;
761 for (InputIt it = first; it != last; ++it) {
762 fl::size old_size = mSize;
763 push_back(*it);
764 if (mSize == old_size) {
765 break;
766 }
767 ++count;
768 }
769 if (count == 0) {
770 return begin() + target_idx;
771 }
772 // Rotate new elements into place via bubble swaps
773 fl::size src_start = mSize - count;
774 for (fl::size i = 0; i < count; ++i) {
775 for (fl::size j = src_start + i; j > target_idx + i; --j) {
776 fl::swap(static_cast<T*>(mArray)[j - 1],
777 static_cast<T*>(mArray)[j]);
778 }
779 }
780 return begin() + target_idx;
781 }
782
783 // ======= SWAP =======
784
785 void swap(vector &other) FL_NO_EXCEPT { swap_impl(other); }
786 void swap(vector &&other) FL_NO_EXCEPT { swap_impl(other); }
787
789 fl::swap(*a, *b);
790 }
791
792 // ======= COMPARISON =======
793
794 bool operator==(const vector &other) const FL_NO_EXCEPT {
795 if (size() != other.size()) return false;
796 const T* a = static_cast<const T*>(mArray);
797 const T* b = static_cast<const T*>(other.mArray);
798 for (fl::size i = 0; i < size(); ++i) {
799 if (a[i] != b[i]) return false;
800 }
801 return true;
802 }
803
804 bool operator!=(const vector &other) const FL_NO_EXCEPT { return !(*this == other); }
805
806 bool operator<(const vector &other) const FL_NO_EXCEPT {
807 fl::size min_size = mSize < other.mSize ? mSize : other.mSize;
808 const T* a = static_cast<const T*>(mArray);
809 const T* b = static_cast<const T*>(other.mArray);
810 for (fl::size i = 0; i < min_size; ++i) {
811 if (a[i] < b[i]) return true;
812 if (a[i] > b[i]) return false;
813 }
814 return mSize < other.mSize;
815 }
816
817 bool operator<=(const vector &other) const FL_NO_EXCEPT {
818 return *this < other || *this == other;
819 }
820
821 bool operator>(const vector &other) const FL_NO_EXCEPT { return other < *this; }
822
823 bool operator>=(const vector &other) const FL_NO_EXCEPT {
824 return *this > other || *this == other;
825 }
826
827 protected:
828 // For VectorN — constructor with inline buffer
829 vector(void* inlineBuffer, fl::size inlineCapacity) FL_NO_EXCEPT
830 : vector_basic(inlineBuffer, inlineCapacity, sizeof(T),
832
833 vector(void* inlineBuffer, fl::size inlineCapacity, memory_resource* resource) FL_NO_EXCEPT
834 : vector_basic(inlineBuffer, inlineCapacity, sizeof(T),
835 resource, vector_element_ops_for<T>()) {}
836};
837
839// VectorN<T, N> — Vector with inline buffer (replaces InlinedVector).
840// Same wrapper pattern fl::string uses on top of fl::basic_string:
841// the wrapper co-locates an inline buffer with the type-erased base.
842// When size <= N, data lives inline. When size > N, spills to heap.
843// Uses the offset trick from basic_string for trivial relocatability.
845
846template <typename T, fl::size INLINED_SIZE>
847class FL_ALIGN VectorN : public vector<T> {
848 private:
849 // Raw aligned storage — address is valid even before initialization,
850 // same pattern as fl::string::mInlineBuffer above basic_string.
851 FL_ALIGNAS(alignof(T) > alignof(fl::uptr) ? alignof(T) : alignof(fl::uptr))
852 char mInlineBuffer[INLINED_SIZE * sizeof(T)] = {};
853
854 T* inline_memory() FL_NO_EXCEPT { return fl::bit_cast<T*>(mInlineBuffer); }
855
856 public:
857 using typename vector<T>::iterator;
858 using typename vector<T>::const_iterator;
859 using typename vector<T>::value_type;
860
862 : vector<T>(mInlineBuffer, INLINED_SIZE) {}
863
865 : vector<T>(mInlineBuffer, INLINED_SIZE, resource) {}
866
867 VectorN(fl::size count, const T& value = T()) FL_NO_EXCEPT
868 : vector<T>(mInlineBuffer, INLINED_SIZE) {
869 this->resize_value_impl(count, &value);
870 }
871
873 : vector<T>(mInlineBuffer, INLINED_SIZE) {
874 this->copy_from(other);
875 }
876
877 template <fl::size M>
879 : vector<T>(mInlineBuffer, INLINED_SIZE) {
880 this->copy_from(other);
881 }
882
884 : vector<T>(mInlineBuffer, INLINED_SIZE) {
885 this->copy_from(other);
886 }
887
889 : vector<T>(mInlineBuffer, INLINED_SIZE) {
890 this->move_from(other);
891 }
892
893 VectorN(fl::initializer_list<T> init) FL_NO_EXCEPT
894 : vector<T>(mInlineBuffer, INLINED_SIZE) {
895 this->reserve_impl(init.size());
896 for (const auto& value : init) {
897 this->push_back(value);
898 }
899 }
900
902 if (this != &other) {
903 this->copy_from(other);
904 }
905 return *this;
906 }
907
909 if (this != &other) {
910 this->move_assign(other);
911 }
912 return *this;
913 }
914};
915
917// vector_psram<T> — Vector that allocates from PSRAM by default.
919
920template <typename T>
921class vector_psram : public vector<T> {
922 public:
925
926 vector_psram(fl::size count, const T& value = T()) FL_NO_EXCEPT
927 : vector<T>(count, value, psram_memory_resource()) {}
928
929 vector_psram(fl::initializer_list<T> init) FL_NO_EXCEPT
931 this->reserve_impl(init.size());
932 for (const auto& value : init) {
933 this->push_back(value);
934 }
935 }
936
937 // Iterator-range constructor
938 template <typename InputIterator,
940 vector_psram(InputIterator first, InputIterator last) FL_NO_EXCEPT
942 for (auto it = first; it != last; ++it) {
943 this->push_back(*it);
944 }
945 }
946
949 this->copy_from(other);
950 }
951
956
958 if (this != &other) {
959 this->copy_from(other);
960 }
961 return *this;
962 }
963
965 if (this != &other) {
966 this->move_assign(other);
967 }
968 return *this;
969 }
970};
971
973// SortedHeapVector — sorted wrapper around vector<T>
975
976template <typename T, typename LessThan = fl::less<T>>
978 private:
980 LessThan mLess;
981 fl::size mMaxSize = fl::size(-1);
982
983 public:
984 enum insert_result { inserted = 0, exists = 1, at_capacity = 2 };
985
986 typedef T value_type;
991
992 SortedHeapVector(LessThan less = LessThan()) FL_NO_EXCEPT : mLess(less) {}
993
994 // Copy constructor
995 SortedHeapVector(const SortedHeapVector& other) = default;
996
997 // Copy assignment
999
1000 // Move constructor
1002 : mArray(fl::move(other.mArray))
1003 , mLess(fl::move(other.mLess))
1004 , mMaxSize(other.mMaxSize) {
1005 other.mMaxSize = fl::size(-1);
1006 }
1007
1008 // Move assignment operator
1010 if (this != &other) {
1011 mArray = fl::move(other.mArray);
1012 mLess = fl::move(other.mLess);
1013 mMaxSize = other.mMaxSize;
1014 other.mMaxSize = fl::size(-1);
1015 }
1016 return *this;
1017 }
1018
1019 void setMaxSize(fl::size n) FL_NO_EXCEPT {
1020 if (mMaxSize == n) return;
1021 mMaxSize = n;
1022 const bool needs_adjustment = mArray.size() > mMaxSize;
1023 if (needs_adjustment) {
1024 mArray.resize(n);
1025 } else {
1026 mArray.reserve(n);
1027 }
1028 }
1029
1031
1032 void reserve(fl::size n) FL_NO_EXCEPT { mArray.reserve(n); }
1033
1034 // Insert while maintaining sort order
1035 bool insert(const T &value, insert_result *result = nullptr) FL_NO_EXCEPT {
1037 if (pos != end() && !mLess(value, *pos) && !mLess(*pos, value)) {
1038 if (result) *result = exists;
1039 return false;
1040 }
1041 if (mArray.size() >= mMaxSize) {
1042 if (result) *result = at_capacity;
1043 return false;
1044 }
1045 mArray.insert(pos, value);
1046 if (result) *result = inserted;
1047 return true;
1048 }
1049
1051 iterator first = mArray.begin();
1052 iterator last = mArray.end();
1053 while (first != last) {
1054 iterator mid = first + (last - first) / 2;
1055 if (mLess(*mid, value)) {
1056 first = mid + 1;
1057 } else {
1058 last = mid;
1059 }
1060 }
1061 return first;
1062 }
1063
1065 return const_cast<SortedHeapVector *>(this)->lower_bound(value);
1066 }
1067
1070 if (pos != end() && !mLess(value, *pos) && !mLess(*pos, value)) {
1071 return pos;
1072 }
1073 return end();
1074 }
1075
1076 void swap(SortedHeapVector &other) FL_NO_EXCEPT { mArray.swap(other.mArray); }
1077
1079 return const_cast<SortedHeapVector *>(this)->find(value);
1080 }
1081
1082 bool has(const T &value) const FL_NO_EXCEPT { return find(value) != end(); }
1083
1084 bool erase(const T &value) FL_NO_EXCEPT {
1085 iterator it = find(value);
1086 if (it != end()) {
1087 mArray.erase(it);
1088 return true;
1089 }
1090 return false;
1091 }
1092
1094
1095 fl::size size() const FL_NO_EXCEPT { return mArray.size(); }
1096 bool empty() const FL_NO_EXCEPT { return mArray.empty(); }
1097 fl::size capacity() const FL_NO_EXCEPT { return mArray.capacity(); }
1098
1099 void clear() FL_NO_EXCEPT { mArray.clear(); }
1100 bool full() const FL_NO_EXCEPT {
1101 if (mArray.size() >= mMaxSize) return true;
1102 return mArray.full();
1103 }
1104
1105 T &operator[](fl::size index) FL_NO_EXCEPT { return mArray[index]; }
1106 const T &operator[](fl::size index) const FL_NO_EXCEPT { return mArray[index]; }
1107
1108 T &front() FL_NO_EXCEPT { return mArray.front(); }
1109 const T &front() const FL_NO_EXCEPT { return mArray.front(); }
1110
1111 T &back() FL_NO_EXCEPT { return mArray.back(); }
1112 const T &back() const FL_NO_EXCEPT { return mArray.back(); }
1113
1114 iterator begin() FL_NO_EXCEPT { return mArray.begin(); }
1115 const_iterator begin() const FL_NO_EXCEPT { return mArray.begin(); }
1116 iterator end() FL_NO_EXCEPT { return mArray.end(); }
1117 const_iterator end() const FL_NO_EXCEPT { return mArray.end(); }
1118
1123
1124 // Raw data access
1125 T *data() FL_NO_EXCEPT { return mArray.data(); }
1126 const T *data() const FL_NO_EXCEPT { return mArray.data(); }
1127};
1128
1130// Type aliases
1132
1133template <typename T, fl::size INLINED_SIZE>
1135
1136template <typename T, fl::size INLINED_SIZE = 64>
1138
1139// Backward compat: InlinedVector is now VectorN
1140template <typename T, fl::size INLINED_SIZE>
1142
1143} // namespace fl
uint8_t pos
Definition Blur.ino:11
Alignment macros and utilities for FastLED.
Type-erased base class for fl::vector<T>.
void swap(FixedVector< T, N > &other) FL_NO_EXCEPT
Definition vector.h:409
const T * memory() const FL_NO_EXCEPT
Definition vector.h:92
const T & operator[](fl::size index) const FL_NO_EXCEPT
Definition vector.h:165
const T & back() const FL_NO_EXCEPT
Definition vector.h:355
FixedVector(FixedVector &&other) FL_NO_EXCEPT
Definition vector.h:105
const_iterator find(const T &value) const FL_NO_EXCEPT
Definition vector.h:333
InlinedMemoryBlock< fl::u32, N > mMemoryBlock
Definition vector.h:88
FixedVector(const FixedVector &other) FL_NO_EXCEPT
Definition vector.h:110
~FixedVector() FL_NO_EXCEPT
Definition vector.h:159
void resize(fl::size n) FL_NO_EXCEPT
Definition vector.h:173
const_iterator end() const FL_NO_EXCEPT
Definition vector.h:396
T & front() FL_NO_EXCEPT
Definition vector.h:349
T & operator[](fl::size index) FL_NO_EXCEPT
Definition vector.h:162
iterator find(const fl::u32 &value) FL_NO_EXCEPT
Definition vector.h:276
const_reverse_iterator rbegin() const FL_NO_EXCEPT
Definition vector.h:400
const T & front() const FL_NO_EXCEPT
Definition vector.h:351
constexpr bool empty() const FL_NO_EXCEPT
Definition vector.h:185
bool insert(iterator pos, T &&value) FL_NO_EXCEPT
Definition vector.h:314
FixedVector(fl::initializer_list< T > init) FL_NO_EXCEPT
Definition vector.h:120
void push_back(T &&value) FL_NO_EXCEPT
Definition vector.h:200
FixedVector(const T(&values)[N]) FL_NO_EXCEPT
Definition vector.h:101
void shrink_to_fit() FL_NO_EXCEPT
Definition vector.h:405
iterator find_if(Predicate pred) FL_NO_EXCEPT
Definition vector.h:285
iterator data() FL_NO_EXCEPT
Definition vector.h:342
FixedVector(T(&values)[M]) FL_NO_EXCEPT
Definition vector.h:114
T * memory() FL_NO_EXCEPT
Definition vector.h:90
FixedVector & operator=(FixedVector &&other) FL_NO_EXCEPT
Definition vector.h:150
constexpr FixedVector() FL_NO_EXCEPT
Definition vector.h:99
FixedVector(fl::span< const T, fl::size(-1)> s) FL_NO_EXCEPT
Definition vector.h:136
void push_back(const fl::u32 &value) FL_NO_EXCEPT
Definition vector.h:191
constexpr fl::size size() const FL_NO_EXCEPT
Definition vector.h:183
T & back() FL_NO_EXCEPT
Definition vector.h:353
bool insert(iterator pos, const T &value) FL_NO_EXCEPT
Definition vector.h:294
const_iterator data() const FL_NO_EXCEPT
Definition vector.h:344
iterator erase(iterator pos) FL_NO_EXCEPT
Definition vector.h:255
void assign_array(const fl::u32 *values, fl::size count) FL_NO_EXCEPT
Definition vector.h:225
void emplace_back(Args &&... args) FL_NO_EXCEPT
Definition vector.h:210
FixedVector & operator=(const FixedVector &other) FL_NO_EXCEPT
Definition vector.h:143
const_iterator begin() const FL_NO_EXCEPT
Definition vector.h:394
reverse_iterator rbegin() FL_NO_EXCEPT
Definition vector.h:399
const_reverse_iterator rend() const FL_NO_EXCEPT
Definition vector.h:402
iterator erase(const T &value) FL_NO_EXCEPT
Definition vector.h:268
constexpr fl::size capacity() const FL_NO_EXCEPT
Definition vector.h:188
iterator begin() FL_NO_EXCEPT
Definition vector.h:393
reverse_iterator rend() FL_NO_EXCEPT
Definition vector.h:401
bool has(const T &value) const FL_NO_EXCEPT
Definition vector.h:346
void assign(const_iterator begin, const_iterator end) FL_NO_EXCEPT
Definition vector.h:232
void reserve(fl::size n) FL_NO_EXCEPT
Definition vector.h:218
T & front() FL_NO_EXCEPT
Definition vector.h:1108
SortedHeapVector(SortedHeapVector &&other) FL_NO_EXCEPT
Definition vector.h:1001
~SortedHeapVector() FL_NO_EXCEPT
Definition vector.h:1030
reverse_iterator rend() FL_NO_EXCEPT
Definition vector.h:1121
vector< T >::iterator iterator
Definition vector.h:987
vector< T > mArray
Definition vector.h:979
iterator begin() FL_NO_EXCEPT
Definition vector.h:1114
vector< T >::const_iterator const_iterator
Definition vector.h:988
void setMaxSize(fl::size n) FL_NO_EXCEPT
Definition vector.h:1019
T & back() FL_NO_EXCEPT
Definition vector.h:1111
const T * data() const FL_NO_EXCEPT
Definition vector.h:1126
iterator end() FL_NO_EXCEPT
Definition vector.h:1116
fl::size size() const FL_NO_EXCEPT
Definition vector.h:1095
T * data() FL_NO_EXCEPT
Definition vector.h:1125
SortedHeapVector & operator=(const SortedHeapVector &other)=default
vector< T >::const_reverse_iterator const_reverse_iterator
Definition vector.h:990
iterator lower_bound(const T &value) FL_NO_EXCEPT
Definition vector.h:1050
void reserve(fl::size n) FL_NO_EXCEPT
Definition vector.h:1032
bool has(const T &value) const FL_NO_EXCEPT
Definition vector.h:1082
vector< T >::reverse_iterator reverse_iterator
Definition vector.h:989
const_iterator end() const FL_NO_EXCEPT
Definition vector.h:1117
const_reverse_iterator rbegin() const FL_NO_EXCEPT
Definition vector.h:1120
const T & front() const FL_NO_EXCEPT
Definition vector.h:1109
const_iterator find(const T &value) const FL_NO_EXCEPT
Definition vector.h:1078
SortedHeapVector(const SortedHeapVector &other)=default
bool full() const FL_NO_EXCEPT
Definition vector.h:1100
fl::size mMaxSize
Definition vector.h:981
T & operator[](fl::size index) FL_NO_EXCEPT
Definition vector.h:1105
const T & back() const FL_NO_EXCEPT
Definition vector.h:1112
void clear() FL_NO_EXCEPT
Definition vector.h:1099
reverse_iterator rbegin() FL_NO_EXCEPT
Definition vector.h:1119
iterator erase(iterator pos) FL_NO_EXCEPT
Definition vector.h:1093
void swap(SortedHeapVector &other) FL_NO_EXCEPT
Definition vector.h:1076
iterator find(const T &value) FL_NO_EXCEPT
Definition vector.h:1068
fl::size capacity() const FL_NO_EXCEPT
Definition vector.h:1097
bool erase(const T &value) FL_NO_EXCEPT
Definition vector.h:1084
bool insert(const T &value, insert_result *result=nullptr) FL_NO_EXCEPT
Definition vector.h:1035
const_iterator lower_bound(const T &value) const FL_NO_EXCEPT
Definition vector.h:1064
SortedHeapVector(LessThan less=LessThan()) FL_NO_EXCEPT
Definition vector.h:992
bool empty() const FL_NO_EXCEPT
Definition vector.h:1096
SortedHeapVector & operator=(SortedHeapVector &&other) FL_NO_EXCEPT
Definition vector.h:1009
const_reverse_iterator rend() const FL_NO_EXCEPT
Definition vector.h:1122
const_iterator begin() const FL_NO_EXCEPT
Definition vector.h:1115
const T & operator[](fl::size index) const FL_NO_EXCEPT
Definition vector.h:1106
VectorN(fl::size count, const T &value=T()) FL_NO_EXCEPT
Definition vector.h:867
VectorN & operator=(const VectorN &other) FL_NO_EXCEPT
Definition vector.h:901
VectorN(memory_resource *resource) FL_NO_EXCEPT
Definition vector.h:864
VectorN & operator=(VectorN &&other) FL_NO_EXCEPT
Definition vector.h:908
VectorN(VectorN &&other) FL_NO_EXCEPT
Definition vector.h:888
VectorN(const vector< T > &other) FL_NO_EXCEPT
Definition vector.h:883
T * inline_memory() FL_NO_EXCEPT
Definition vector.h:854
VectorN(const VectorN &other) FL_NO_EXCEPT
Definition vector.h:872
VectorN(const VectorN< T, M > &other) FL_NO_EXCEPT
Definition vector.h:878
FL_ALIGNAS(alignof(T) > alignof(fl::uptr) ? alignof(T) :alignof(fl::uptr)) char mInlineBuffer[INLINED_SIZE *sizeof(T)]
VectorN() FL_NO_EXCEPT
Definition vector.h:861
VectorN(fl::initializer_list< T > init) FL_NO_EXCEPT
Definition vector.h:893
Polymorphic memory resource base class (PMR-style).
void move_assign(vector_basic &other) FL_NO_EXCEPT
Move-assign from another vector_basic (clears this first).
fl::size size() const FL_NO_EXCEPT
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
void shrink_to_fit_impl() FL_NO_EXCEPT
void push_back_copy_impl(const void *element) FL_NO_EXCEPT
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 swap_impl(vector_basic &other) FL_NO_EXCEPT
Swap contents with another vector_basic.
vector_basic(fl::size elementSize, memory_resource *resource, const vector_element_ops *ops) FL_NO_EXCEPT
Heap-only vector (no inline buffer).
bool empty() const FL_NO_EXCEPT
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.
vector_psram & operator=(vector_psram &&other) FL_NO_EXCEPT
Definition vector.h:964
vector_psram(fl::size count, const T &value=T()) FL_NO_EXCEPT
Definition vector.h:926
vector_psram(fl::initializer_list< T > init) FL_NO_EXCEPT
Definition vector.h:929
vector_psram(const vector_psram &other) FL_NO_EXCEPT
Definition vector.h:947
vector_psram(vector_psram &&other) FL_NO_EXCEPT
Definition vector.h:952
vector_psram(InputIterator first, InputIterator last) FL_NO_EXCEPT
Definition vector.h:940
vector_psram & operator=(const vector_psram &other) FL_NO_EXCEPT
Definition vector.h:957
vector_psram() FL_NO_EXCEPT
Definition vector.h:923
iterator find_if(Predicate pred) FL_NO_EXCEPT
Definition vector.h:696
vector(span< const T, fl::size(-1)> s) FL_NO_EXCEPT
Definition vector.h:560
bool has(const T &value) const FL_NO_EXCEPT
Definition vector.h:703
const_iterator find(const T &value) const FL_NO_EXCEPT
Definition vector.h:689
const fl::i16 * const_iterator
Definition vector.h:453
void reserve(fl::size n) FL_NO_EXCEPT
Definition vector.h:591
void erase_range(iterator first, fl::size count) FL_NO_EXCEPT
Definition vector.h:733
reverse_iterator rbegin() FL_NO_EXCEPT
Definition vector.h:668
vector & operator=(vector &&other) FL_NO_EXCEPT
Definition vector.h:578
void shrink_to_fit() FL_NO_EXCEPT
Definition vector.h:597
void push_back(T &&value) FL_NO_EXCEPT
Definition vector.h:625
vector(T(&values)[N]) FL_NO_EXCEPT
Definition vector.h:528
const_reverse_iterator rend() const FL_NO_EXCEPT
Definition vector.h:671
vector(void *inlineBuffer, fl::size inlineCapacity, memory_resource *resource) FL_NO_EXCEPT
Definition vector.h:833
void emplace_back(Args &&... args) FL_NO_EXCEPT
Definition vector.h:628
vector(fl::initializer_list< T > init) FL_NO_EXCEPT
Definition vector.h:538
const_iterator cend() const FL_NO_EXCEPT
Definition vector.h:676
fl::i16 * iterator
Definition vector.h:452
vector(void *inlineBuffer, fl::size inlineCapacity) FL_NO_EXCEPT
Definition vector.h:829
void resize(fl::size n) FL_NO_EXCEPT
Definition vector.h:593
memory_resource * get_resource() const FL_NO_EXCEPT
Definition vector.h:601
vector(const vector &other) FL_NO_EXCEPT
Definition vector.h:514
void pop_back() FL_NO_EXCEPT
Definition vector.h:633
void clear() FL_NO_EXCEPT
Definition vector.h:634
bool operator<=(const vector &other) const FL_NO_EXCEPT
Definition vector.h:817
const T * data() const FL_NO_EXCEPT
Definition vector.h:620
const_iterator end() const FL_NO_EXCEPT
Definition vector.h:664
T * data() FL_NO_EXCEPT
Definition vector.h:619
void push_back(const fl::i16 &value) FL_NO_EXCEPT
Definition vector.h:624
T & back() FL_NO_EXCEPT
Definition vector.h:616
void swap(iterator a, iterator b) FL_NO_EXCEPT
Definition vector.h:788
iterator find(const T &value) FL_NO_EXCEPT
Definition vector.h:682
iterator end() FL_NO_EXCEPT
Definition vector.h:661
void assign(fl::size new_cap, const T &value) FL_NO_EXCEPT
Definition vector.h:645
vector(fl::size count, const T &value=T()) FL_NO_EXCEPT
Definition vector.h:501
iterator erase(iterator pos) FL_NO_EXCEPT
Definition vector.h:708
void assign(InputIt first, InputIt last) FL_NO_EXCEPT
Definition vector.h:638
vector(memory_resource *resource) FL_NO_EXCEPT
Definition vector.h:497
vector(fl::size count, const T &value, memory_resource *resource) FL_NO_EXCEPT
Definition vector.h:508
const T & back() const FL_NO_EXCEPT
Definition vector.h:617
bool operator!=(const vector &other) const FL_NO_EXCEPT
Definition vector.h:804
void swap(vector &other) FL_NO_EXCEPT
Definition vector.h:785
bool insert(iterator pos, T &&value) FL_NO_EXCEPT
Definition vector.h:749
bool operator>(const vector &other) const FL_NO_EXCEPT
Definition vector.h:821
reverse_iterator rend() FL_NO_EXCEPT
Definition vector.h:670
iterator begin() FL_NO_EXCEPT
Definition vector.h:655
const T & operator[](fl::size index) const FL_NO_EXCEPT
Definition vector.h:609
vector() FL_NO_EXCEPT
Definition vector.h:492
bool operator>=(const vector &other) const FL_NO_EXCEPT
Definition vector.h:823
T & operator[](fl::size index) FL_NO_EXCEPT
Definition vector.h:605
bool erase(iterator pos, T *out_value) FL_NO_EXCEPT
Definition vector.h:716
void ensure_size(fl::size n) FL_NO_EXCEPT
Definition vector.h:599
bool operator==(const vector &other) const FL_NO_EXCEPT
Definition vector.h:794
vector(InputIterator first, InputIterator last) FL_NO_EXCEPT
Definition vector.h:551
void resize(fl::size n, const T &value) FL_NO_EXCEPT
Definition vector.h:595
iterator insert(iterator pos, InputIt first, InputIt last) FL_NO_EXCEPT
Definition vector.h:758
vector(vector &&other) FL_NO_EXCEPT
Definition vector.h:521
const T & front() const FL_NO_EXCEPT
Definition vector.h:614
void swap(vector &&other) FL_NO_EXCEPT
Definition vector.h:786
const_reverse_iterator rbegin() const FL_NO_EXCEPT
Definition vector.h:669
void erase(const T &value) FL_NO_EXCEPT
Definition vector.h:725
vector & operator=(const vector &other) FL_NO_EXCEPT
Definition vector.h:571
T & front() FL_NO_EXCEPT
Definition vector.h:613
const_iterator begin() const FL_NO_EXCEPT
Definition vector.h:658
bool operator<(const vector &other) const FL_NO_EXCEPT
Definition vector.h:806
const_iterator cbegin() const FL_NO_EXCEPT
Definition vector.h:673
bool insert(iterator pos, const T &value) FL_NO_EXCEPT
Definition vector.h:742
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition move.h:30
constexpr T * begin(T(&array)[N]) FL_NO_EXCEPT
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition s16x16x4.h:30
constexpr T && forward(typename remove_reference< T >::type &t) FL_NO_EXCEPT
Definition s16x16x4.h:236
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:67
constexpr common_type_t< T, U > max(T a, U b) FL_NO_EXCEPT
Definition math.h:75
void swap(array< T, N > &lhs, array< T, N > &rhs) FL_NO_EXCEPT
Definition array.h:209
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
constexpr int type_rank< T >::value
VectorN< T, INLINED_SIZE > InlinedVector
Definition span.h:25
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NO_EXCEPT
Definition math.h:71
const vector_element_ops * vector_element_ops_for() FL_NO_EXCEPT
Generate a static ops table for type T.
void init(Context &ctx, int w, int h) FL_NO_EXCEPT
Definition engine.h:133
FASTLED_FORCE_INLINE void * memset(void *s, int c, size_t n) FL_NO_EXCEPT
Definition cstring.h:148
memory_resource * default_memory_resource() FL_NO_EXCEPT
Get the default memory resource (wraps fl::Malloc / fl::Free / fl::realloc).
memory_resource * psram_memory_resource() FL_NO_EXCEPT
Get the PSRAM memory resource (wraps PSRamAllocate / PSRamDeallocate).
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:32
uptr ptr_to_int(T *ptr) FL_NO_EXCEPT
Definition bit_cast.h:71
To bit_cast(const From &from) FL_NO_EXCEPT
Definition bit_cast.h:48
VectorN< T, INLINED_SIZE > vector_inlined
Definition vector.h:1137
FixedVector< T, INLINED_SIZE > vector_fixed
Definition vector.h:1134
Base definition for an LED controller.
corkscrew_args args
Definition old.h:149
#define FL_STATIC_ASSERT(...)
#define FL_ALIGN
Portable compile-time assertion wrapper.
bool operator!=(const const_reverse_iterator &other) const FL_NO_EXCEPT
Definition vector.h:387
const T & operator*() const FL_NO_EXCEPT
Definition vector.h:378
bool operator==(const const_reverse_iterator &other) const FL_NO_EXCEPT
Definition vector.h:384
const_reverse_iterator(const_iterator i) FL_NO_EXCEPT
Definition vector.h:377
const_reverse_iterator & operator++() FL_NO_EXCEPT
Definition vector.h:380
const T * operator->() const FL_NO_EXCEPT
Definition vector.h:379
bool operator==(const reverse_iterator &other) const FL_NO_EXCEPT
Definition vector.h:367
reverse_iterator & operator++() FL_NO_EXCEPT
Definition vector.h:363
reverse_iterator(iterator i) FL_NO_EXCEPT
Definition vector.h:360
T & operator*() FL_NO_EXCEPT
Definition vector.h:361
bool operator!=(const reverse_iterator &other) const FL_NO_EXCEPT
Definition vector.h:370
T * operator->() FL_NO_EXCEPT
Definition vector.h:362
Binary function object that returns whether the first argument is less than the second.
Definition utility.h:15
const_reverse_iterator(const_iterator i) FL_NO_EXCEPT
Definition vector.h:474
const T * operator->() const FL_NO_EXCEPT
Definition vector.h:476
const T & operator*() const FL_NO_EXCEPT
Definition vector.h:475
bool operator!=(const const_reverse_iterator &other) const FL_NO_EXCEPT
Definition vector.h:484
bool operator==(const const_reverse_iterator &other) const FL_NO_EXCEPT
Definition vector.h:481
const_reverse_iterator & operator++() FL_NO_EXCEPT
Definition vector.h:477
reverse_iterator & operator++() FL_NO_EXCEPT
Definition vector.h:460
bool operator==(const reverse_iterator &other) const FL_NO_EXCEPT
Definition vector.h:464
T & operator*() FL_NO_EXCEPT
Definition vector.h:458
reverse_iterator(iterator i) FL_NO_EXCEPT
Definition vector.h:457
T * operator->() FL_NO_EXCEPT
Definition vector.h:459
bool operator!=(const reverse_iterator &other) const FL_NO_EXCEPT
Definition vector.h:467