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 92 of file bitset_dynamic.h.

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

References _block_count, _blocks, _size, bits_per_block, reset(), and resize().

+ Here is the call graph for this function: