27template <
typename T, fl::size Extent>
class span;
31template <
typename T, fl::size N>
32struct FL_ALIGNAS(alignof(T) > alignof(
fl::uptr) ? alignof(T) : alignof(fl::uptr)) InlinedMemoryBlock {
34 typedef fl::uptr MemoryType;
36 kTotalBytes = N *
sizeof(T),
40 kTotalBytesAligned = kTotalBytes + kExtraSize,
41 kBlockSize = (kTotalBytesAligned +
sizeof(MemoryType) - 1) /
sizeof(MemoryType),
45 fl::memset(mMemoryBlock, 0,
sizeof(mMemoryBlock));
51 InlinedMemoryBlock(
const InlinedMemoryBlock &other)
FL_NOEXCEPT =
default;
52 InlinedMemoryBlock(InlinedMemoryBlock &&other)
FL_NOEXCEPT =
default;
57 MemoryType mMemoryBlock[kBlockSize];
60 MemoryType *
begin = &mMemoryBlock[0];
63 MemoryType *raw =
begin + shift_up;
68 const MemoryType *
begin = &mMemoryBlock[0];
69 const fl::uptr shift_up =
71 const MemoryType *raw =
begin + shift_up;
85template <
typename T, fl::size N>
121 if (
init.size() > N) {
123 auto it =
init.begin();
124 for (fl::size i = 0; i < N && it !=
init.end(); ++i, ++it) {
137 fl::size count = s.size() < N ? s.size() : N;
138 for (fl::size i = 0; i < count; ++i) {
144 if (
this != &other) {
151 if (
this != &other) {
167 const T *out =
nullptr;
209 template<
typename... Args>
227 for (fl::size i = 0; i < count; ++i) {
368 return it == other.it;
371 return it != other.it;
385 return it == other.it;
388 return it != other.it;
410 if (
this == &other)
return;
414 for (fl::size i = 0; i < min_sz; ++i) {
419 for (fl::size i = min_sz; i < max_sz; ++i) {
421 T* dst = other.memory() + i;
426 for (fl::size i = min_sz; i < max_sz; ++i) {
427 T* src = other.memory() + i;
435 other.current_size = temp_size;
465 return it == other.it;
468 return it != other.it;
482 return it == other.it;
485 return it != other.it;
532 for (fl::size i = 0; i < N; ++i) {
549 template <
typename InputIterator,
554 for (
auto it = first; it != last; ++it) {
564 for (fl::size i = 0; i < s.size(); ++i) {
572 if (
this != &other) {
579 if (
this != &other) {
606 return static_cast<T*
>(
mArray)[index];
610 return static_cast<const T*
>(
mArray)[index];
627 template <
typename... Args>
636 template <
typename InputIt,
640 for (
auto it = first; it != last; ++it) {
648 for (fl::size i = 0; i < new_cap; ++i) {
659 return mArray ?
static_cast<const T*
>(
mArray) :
nullptr;
674 return mArray ?
static_cast<const T*
>(
mArray) :
nullptr;
684 if (*it ==
value)
return it;
691 if (*it ==
value)
return it;
698 if (pred(*it))
return it;
712 return begin() + index;
734 if (count == 0 || first >=
end())
return;
735 fl::size index = first -
begin();
736 if (index + count >
mSize) count =
mSize - index;
744 fl::size old_size =
mSize;
746 return mSize > old_size;
751 fl::size old_size =
mSize;
753 return mSize > old_size;
757 template <
typename InputIt>
759 fl::size target_idx =
pos -
begin();
761 for (InputIt it = first; it != last; ++it) {
766 return begin() + target_idx;
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) {
773 static_cast<T*
>(
mArray)[j]);
776 return begin() + target_idx;
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;
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;
810 return mSize < other.mSize;
814 return *
this < other || *
this == other;
820 return *
this > other || *
this == other;
842template <
typename T, fl::size INLINED_SIZE>
847 FL_ALIGNAS(
alignof(T) >
alignof(fl::uptr) ?
alignof(T) :
alignof(fl::uptr))
848 char mInlineBuffer[INLINED_SIZE *
sizeof(T)] = {};
858 :
vector<T>(mInlineBuffer, INLINED_SIZE) {}
861 :
vector<T>(mInlineBuffer, INLINED_SIZE, resource) {}
864 :
vector<T>(mInlineBuffer, INLINED_SIZE) {
869 :
vector<T>(mInlineBuffer, INLINED_SIZE) {
873 template <fl::size M>
875 :
vector<T>(mInlineBuffer, INLINED_SIZE) {
880 :
vector<T>(mInlineBuffer, INLINED_SIZE) {
885 :
vector<T>(mInlineBuffer, INLINED_SIZE) {
890 :
vector<T>(mInlineBuffer, INLINED_SIZE) {
898 if (
this != &other) {
905 if (
this != &other) {
934 template <
typename InputIterator,
938 for (
auto it = first; it != last; ++it) {
954 if (
this != &other) {
961 if (
this != &other) {
972template <
typename T,
typename LessThan = fl::less<T>>
1001 other.mMaxSize = fl::size(-1);
1006 if (
this != &other) {
1010 other.mMaxSize = fl::size(-1);
1019 if (needs_adjustment) {
1049 while (first != last) {
1050 iterator mid = first + (last - first) / 2;
1129template <
typename T, fl::size INLINED_SIZE>
1132template <
typename T, fl::size INLINED_SIZE = 64>
1136template <
typename T, fl::size INLINED_SIZE>
Alignment macros and utilities for FastLED.
Type-erased base class for fl::vector<T>.
iterator data() FL_NOEXCEPT
iterator end() FL_NOEXCEPT
const fl::u32 * const_iterator
bool insert(iterator pos, const T &value) FL_NOEXCEPT
bool has(const T &value) const FL_NOEXCEPT
const T & back() const FL_NOEXCEPT
void shrink_to_fit() FL_NOEXCEPT
void emplace_back(Args &&... args) FL_NOEXCEPT
FixedVector(const FixedVector &other) FL_NOEXCEPT
const_iterator begin() const FL_NOEXCEPT
FixedVector(FixedVector &&other) FL_NOEXCEPT
void assign_array(const fl::u32 *values, fl::size count) FL_NOEXCEPT
InlinedMemoryBlock< fl::u32, N > mMemoryBlock
FixedVector(fl::span< const T, fl::size(-1)> s) FL_NOEXCEPT
FixedVector & operator=(FixedVector &&other) FL_NOEXCEPT
const T * memory() const FL_NOEXCEPT
const_iterator data() const FL_NOEXCEPT
void assign(const_iterator begin, const_iterator end) FL_NOEXCEPT
FixedVector(T(&values)[M]) FL_NOEXCEPT
void reserve(fl::size n) FL_NOEXCEPT
void swap(FixedVector< T, N > &other) FL_NOEXCEPT
const T & front() const FL_NOEXCEPT
reverse_iterator rend() FL_NOEXCEPT
void pop_back() FL_NOEXCEPT
void push_back(const fl::u32 &value) FL_NOEXCEPT
bool insert(iterator pos, T &&value) FL_NOEXCEPT
iterator find_if(Predicate pred) FL_NOEXCEPT
void push_back(T &&value) FL_NOEXCEPT
iterator erase(const T &value) FL_NOEXCEPT
const_reverse_iterator rend() const FL_NOEXCEPT
const_reverse_iterator rbegin() const FL_NOEXCEPT
const_iterator end() const FL_NOEXCEPT
~FixedVector() FL_NOEXCEPT
reverse_iterator rbegin() FL_NOEXCEPT
constexpr bool empty() const FL_NOEXCEPT
FixedVector & operator=(const FixedVector &other) FL_NOEXCEPT
T & operator[](fl::size index) FL_NOEXCEPT
iterator begin() FL_NOEXCEPT
iterator erase(iterator pos) FL_NOEXCEPT
FixedVector(const T(&values)[N]) FL_NOEXCEPT
constexpr fl::size capacity() const FL_NOEXCEPT
const_iterator find(const T &value) const FL_NOEXCEPT
FixedVector(fl::initializer_list< T > init) FL_NOEXCEPT
constexpr FixedVector() FL_NOEXCEPT
iterator find(const fl::u32 &value) FL_NOEXCEPT
constexpr fl::size size() const FL_NOEXCEPT
void resize(fl::size n) FL_NOEXCEPT
const T & operator[](fl::size index) const FL_NOEXCEPT
const_iterator find(const T &value) const FL_NOEXCEPT
fl::size size() const FL_NOEXCEPT
bool empty() const FL_NOEXCEPT
const_reverse_iterator rend() const FL_NOEXCEPT
iterator begin() FL_NOEXCEPT
SortedHeapVector & operator=(SortedHeapVector &&other) FL_NOEXCEPT
const_reverse_iterator rbegin() const FL_NOEXCEPT
iterator erase(iterator pos) FL_NOEXCEPT
vector< T >::iterator iterator
iterator lower_bound(const T &value) FL_NOEXCEPT
bool full() const FL_NOEXCEPT
bool erase(const T &value) FL_NOEXCEPT
reverse_iterator rend() FL_NOEXCEPT
vector< T >::const_iterator const_iterator
const T & front() const FL_NOEXCEPT
void setMaxSize(fl::size n) FL_NOEXCEPT
const T & back() const FL_NOEXCEPT
SortedHeapVector & operator=(const SortedHeapVector &other)=default
void swap(SortedHeapVector &other) FL_NOEXCEPT
const_iterator lower_bound(const T &value) const FL_NOEXCEPT
iterator find(const T &value) FL_NOEXCEPT
vector< T >::const_reverse_iterator const_reverse_iterator
vector< T >::reverse_iterator reverse_iterator
~SortedHeapVector() FL_NOEXCEPT
const T & operator[](fl::size index) const FL_NOEXCEPT
const_iterator begin() const FL_NOEXCEPT
SortedHeapVector(const SortedHeapVector &other)=default
const T * data() const FL_NOEXCEPT
iterator end() FL_NOEXCEPT
bool insert(const T &value, insert_result *result=nullptr) FL_NOEXCEPT
T & operator[](fl::size index) FL_NOEXCEPT
SortedHeapVector(LessThan less=LessThan()) FL_NOEXCEPT
bool has(const T &value) const FL_NOEXCEPT
const_iterator end() const FL_NOEXCEPT
SortedHeapVector(SortedHeapVector &&other) FL_NOEXCEPT
reverse_iterator rbegin() FL_NOEXCEPT
void reserve(fl::size n) FL_NOEXCEPT
fl::size capacity() const FL_NOEXCEPT
VectorN(const VectorN< T, M > &other) FL_NOEXCEPT
VectorN(const VectorN &other) FL_NOEXCEPT
VectorN & operator=(const VectorN &other) FL_NOEXCEPT
VectorN(fl::initializer_list< T > init) FL_NOEXCEPT
VectorN & operator=(VectorN &&other) FL_NOEXCEPT
VectorN(memory_resource *resource) FL_NOEXCEPT
VectorN(const vector< T > &other) FL_NOEXCEPT
FL_ALIGNAS(alignof(T) > alignof(fl::uptr) ? alignof(T) :alignof(fl::uptr)) char mInlineBuffer[INLINED_SIZE *sizeof(T)]
VectorN(VectorN &&other) FL_NOEXCEPT
VectorN(fl::size count, const T &value=T()) FL_NOEXCEPT
T * inline_memory() FL_NOEXCEPT
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
vector_psram & operator=(vector_psram &&other) FL_NOEXCEPT
vector_psram(fl::initializer_list< T > init) FL_NOEXCEPT
vector_psram & operator=(const vector_psram &other) FL_NOEXCEPT
vector_psram(vector_psram &&other) FL_NOEXCEPT
vector_psram() FL_NOEXCEPT
vector_psram(const vector_psram &other) FL_NOEXCEPT
vector_psram(InputIterator first, InputIterator last) FL_NOEXCEPT
bool operator>(const vector &other) const FL_NOEXCEPT
iterator erase(iterator pos) FL_NOEXCEPT
iterator begin() FL_NOEXCEPT
const fl::i16 * const_iterator
const_iterator end() const FL_NOEXCEPT
bool operator<=(const vector &other) const FL_NOEXCEPT
iterator find(const T &value) FL_NOEXCEPT
bool insert(iterator pos, const T &value) FL_NOEXCEPT
vector(void *inlineBuffer, fl::size inlineCapacity) FL_NOEXCEPT
bool has(const T &value) const FL_NOEXCEPT
iterator insert(iterator pos, InputIt first, InputIt last) FL_NOEXCEPT
void emplace_back(Args &&... args) FL_NOEXCEPT
vector(vector &&other) FL_NOEXCEPT
vector(fl::initializer_list< T > init) FL_NOEXCEPT
void reserve(fl::size n) FL_NOEXCEPT
vector(const vector &other) FL_NOEXCEPT
bool operator>=(const vector &other) const FL_NOEXCEPT
iterator end() FL_NOEXCEPT
const_iterator cbegin() const FL_NOEXCEPT
bool operator!=(const vector &other) const FL_NOEXCEPT
const T * data() const FL_NOEXCEPT
vector(memory_resource *resource) FL_NOEXCEPT
void swap(iterator a, iterator b) FL_NOEXCEPT
bool operator<(const vector &other) const FL_NOEXCEPT
void assign(fl::size new_cap, const T &value) FL_NOEXCEPT
vector(InputIterator first, InputIterator last) FL_NOEXCEPT
const T & operator[](fl::size index) const FL_NOEXCEPT
const_iterator begin() const FL_NOEXCEPT
void push_back(T &&value) FL_NOEXCEPT
void erase(const T &value) FL_NOEXCEPT
vector(fl::size count, const T &value, memory_resource *resource) FL_NOEXCEPT
void assign(InputIt first, InputIt last) FL_NOEXCEPT
void ensure_size(fl::size n) FL_NOEXCEPT
const T & back() const FL_NOEXCEPT
void swap(vector &other) FL_NOEXCEPT
vector & operator=(const vector &other) FL_NOEXCEPT
bool insert(iterator pos, T &&value) FL_NOEXCEPT
const_reverse_iterator rbegin() const FL_NOEXCEPT
const_reverse_iterator rend() const FL_NOEXCEPT
T & operator[](fl::size index) FL_NOEXCEPT
reverse_iterator rbegin() FL_NOEXCEPT
void pop_back() FL_NOEXCEPT
void shrink_to_fit() FL_NOEXCEPT
void swap(vector &&other) FL_NOEXCEPT
vector(T(&values)[N]) FL_NOEXCEPT
vector(fl::size count, const T &value=T()) FL_NOEXCEPT
memory_resource * get_resource() const FL_NOEXCEPT
void resize(fl::size n, const T &value) FL_NOEXCEPT
iterator find_if(Predicate pred) FL_NOEXCEPT
reverse_iterator rend() FL_NOEXCEPT
vector & operator=(vector &&other) FL_NOEXCEPT
const_iterator cend() const FL_NOEXCEPT
void erase_range(iterator first, fl::size count) FL_NOEXCEPT
const_iterator find(const T &value) const FL_NOEXCEPT
vector(void *inlineBuffer, fl::size inlineCapacity, memory_resource *resource) FL_NOEXCEPT
void push_back(const fl::i16 &value) FL_NOEXCEPT
vector(span< const T, fl::size(-1)> s) FL_NOEXCEPT
bool operator==(const vector &other) const FL_NOEXCEPT
const T & front() const FL_NOEXCEPT
void resize(fl::size n) FL_NOEXCEPT
bool erase(iterator pos, T *out_value) FL_NOEXCEPT
constexpr T && forward(typename remove_reference< T >::type &t) FL_NOEXCEPT
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
max_align_selector<(sizeof(longdouble)>sizeof(double))>::type max_align_t
typename enable_if< Condition, T >::type enable_if_t
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
constexpr int type_rank< T >::value
VectorN< T, INLINED_SIZE > InlinedVector
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
void init(Context &ctx, int w, int h)
constexpr T * begin(T(&array)[N]) FL_NOEXCEPT
uptr ptr_to_int(T *ptr) FL_NOEXCEPT
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
expected< T, E > result
Alias for expected (Rust-style naming)
struct FL_ALIGNAS(4) Wave3BitExpansionLut
Lookup table for nibble-to-waveform expansion in wave3 format (32 bytes)
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
To bit_cast(const From &from) FL_NOEXCEPT
FixedVector< T, INLINED_SIZE > vector_fixed
Base definition for an LED controller.
#define FL_STATIC_ASSERT(...)
Portable compile-time assertion wrapper.
bool operator!=(const const_reverse_iterator &other) const FL_NOEXCEPT
bool operator==(const const_reverse_iterator &other) const FL_NOEXCEPT
const T * operator->() const FL_NOEXCEPT
const_reverse_iterator(const_iterator i) FL_NOEXCEPT
const_reverse_iterator & operator++() FL_NOEXCEPT
const T & operator*() const FL_NOEXCEPT
reverse_iterator(iterator i) FL_NOEXCEPT
reverse_iterator & operator++() FL_NOEXCEPT
T & operator*() FL_NOEXCEPT
bool operator==(const reverse_iterator &other) const FL_NOEXCEPT
T * operator->() FL_NOEXCEPT
bool operator!=(const reverse_iterator &other) const FL_NOEXCEPT
Binary function object that returns whether the first argument is less than the second.
const T & operator*() const FL_NOEXCEPT
const_reverse_iterator(const_iterator i) FL_NOEXCEPT
const_reverse_iterator & operator++() FL_NOEXCEPT
bool operator!=(const const_reverse_iterator &other) const FL_NOEXCEPT
bool operator==(const const_reverse_iterator &other) const FL_NOEXCEPT
const T * operator->() const FL_NOEXCEPT
reverse_iterator & operator++() FL_NOEXCEPT
T & operator*() FL_NOEXCEPT
T * operator->() FL_NOEXCEPT
reverse_iterator(iterator i) FL_NOEXCEPT
bool operator==(const reverse_iterator &other) const FL_NOEXCEPT
bool operator!=(const reverse_iterator &other) const FL_NOEXCEPT