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

◆ count()

template<uint32_t N>
uint32_t fl::BitsetFixed< N >::count ( ) const
inlinenoexcept

Returns the number of set bits.

Definition at line 121 of file bitset.h.

121 {
122 uint32_t cnt = 0;
123 // Count bits in all complete blocks
124 for (uint32_t i = 0; i < block_count - 1; ++i) {
126 }
127
128 // For the last block, we need to be careful about counting only valid
129 // bits
130 if (block_count > 0) {
132 // If N is not a multiple of bits_per_block, mask out the unused
133 // bits
134 if (N % bits_per_block != 0) {
136 // Create a mask with only the valid bits set to 1
138 ? ~block_type(0)
139 : ((block_type(1) << valid_bits) - 1);
140 last_block &= mask;
141 }
143 }
144
145 return cnt;
146 }
static constexpr uint32_t block_count
Definition bitset.h:24
block_type _blocks[block_count]
Definition bitset.h:29
uint64_t block_type
Definition bitset.h:26
static constexpr uint32_t bits_per_block
Definition bitset.h:23
A simple fixed-size Bitset implementation similar to std::Bitset.
Definition bitset.h:21

References _blocks, bits_per_block, and block_count.

Referenced by any(), and none().

+ Here is the caller graph for this function: