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

◆ resize()

template<uint32_t N = 256>
void fl::BitsetInlined< N >::resize ( uint32_t new_size)
inline

Resizes the Bitset if needed.

Definition at line 291 of file bitset.h.

291 {
292 if (new_size <= N) {
293 // If we're already using the fixed Bitset, nothing to do
294 if (_storage.template is<bitset_dynamic>()) {
295 // Convert back to fixed Bitset
298 _storage.template ptr<bitset_dynamic>();
299
300 // Copy bits from dynamic to fixed
301 for (uint32_t i = 0; i < N && i < dynamic->size(); ++i) {
302 if (dynamic->test(i)) {
303 fixed.set(i);
304 }
305 }
306
307 _storage = fixed;
308 }
309 } else {
310 // Need to use dynamic Bitset
311 if (_storage.template is<fixed_bitset>()) {
312 // Convert from fixed to dynamic
315
316 // Copy bits from fixed to dynamic
317 for (uint32_t i = 0; i < N; ++i) {
318 if (fixed->test(i)) {
319 dynamic.set(i);
320 }
321 }
322
324 } else {
325 // Already using dynamic, just resize
327 }
328 }
329 }
bool test(uint32_t pos) const noexcept
Tests whether the bit at position pos is set.
Definition bitset.h:383
BitsetInlined & set(uint32_t pos, bool value=true)
Sets or clears the bit at position pos.
Definition bitset.h:332
uint32_t size() const noexcept
Size of the Bitset (number of bits).
Definition bitset.h:430
void resize(uint32_t new_size)
Resizes the Bitset if needed.
Definition bitset.h:291
A Bitset implementation with inline storage that can grow if needed.
Definition bitset.h:225

Referenced by assign(), flip(), operator^, operator|, and set().

+ Here is the caller graph for this function: