FastLED 3.9.15
Loading...
Searching...
No Matches

◆ assign()

FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_NULL_DEREFERENCE void fl::bitset_dynamic::assign ( fl::u32 n,
bool value )
inline

Definition at line 89 of file bitset_dynamic.h.

89 {
90 if (n > _size) {
91 resize(n);
92 }
93 if (value) {
94 // Set all bits to 1
95 if (_blocks && _block_count > 0) {
96 for (fl::u32 i = 0; i < _block_count; ++i) {
97 _blocks[i] = static_cast<block_type>(~block_type(0));
98 }
99 // Clear any bits beyond the actual size
100 if (_size % bits_per_block != 0) {
101 fl::u32 last_block_idx = (_size - 1) / bits_per_block;
102 fl::u32 last_bit_pos = (_size - 1) % bits_per_block;
103 block_type mask = static_cast<block_type>((static_cast<block_type>(1) << (last_bit_pos + 1)) - 1);
104 _blocks[last_block_idx] &= mask;
105 }
106 }
107 } else {
108 // Set all bits to 0
109 reset();
110 }
111 }
FL_DISABLE_WARNING_POP FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_NULL_DEREFERENCE void resize(fl::u32 new_size) FL_NOEXCEPT
fl::unique_ptr< block_type[]> _blocks
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_NULL_DEREFERENCE void reset() FL_NOEXCEPT
static constexpr fl::u32 bits_per_block
constexpr int type_rank< T >::value

References _block_count, _blocks, _size, bits_per_block, FL_NOEXCEPT, reset(), resize(), and fl::type_rank< T >::value.

+ Here is the call graph for this function: