MCPcopy Create free account
hub / github.com/FastLED/FastLED / assign

Method assign

src/fl/stl/bitset_dynamic.h:89–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87 FL_DISABLE_WARNING_PUSH
88 FL_DISABLE_WARNING_NULL_DEREFERENCE
89 void assign(fl::u32 n, bool value) FL_NOEXCEPT {
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 }
112 FL_DISABLE_WARNING_POP
113
114 // Resize the bitset

Callers

nothing calls this directly

Calls 2

resizeFunction · 0.70
resetFunction · 0.50

Tested by

no test coverage detected