18#define BITSET_BITS_PER_WORD 32
28#define BITSET_ARRAY_SIZE 8
34#define BITSET_MAX_BITS (BITSET_BITS_PER_WORD * BITSET_ARRAY_SIZE)
198#define BITSET_DEFINE(name, capacity) \
199 static uint32_t name##_w[BITSET_ARRAY_SIZE] = {0}; \
200 static Bitset name = { \
202 .nbits = BITSET_BITS_PER_WORD, \
203 .nwords = BITSET_ARRAY_SIZE, \
bool bitset_get_idx(Bitset *bitset, int idx)
Get the value of a flag.
bool bitset_is_empty(Bitset *bitset)
Check if a bitset is empty (all 0's)
void bitset_clear(Bitset *bitset)
Clear the bitset, all to 0.
int bitset_num_set_bits(Bitset *bitset)
Count how many bits are set to 1 in a bitset.
int bitset_find_idx_of_nth_set(const Bitset *bitset, int n)
Find the index of the nth set bit.
int bitset_set_next_free_idx(Bitset *bitset)
Set the next free index in the bitset and return the index value.
BitsetItr bitset_itr_create(const Bitset *bitset)
Declare a BitsetItr.
int bitset_itr_next(BitsetItr *itr)
Get the index of the next set bit in the bitset from a BitsetItr.
void bitset_set_idx(Bitset *bitset, int idx, bool on)
Set a flag in a bitset to a value.
An iterator into a Bitset.
int bit
Current bit the iterator is on.
int word
Current word the iterator is on.
int itr
Number of bits that have been iterated through in total.
const Bitset * bitset
Bitset this is iterating through
A bitset spread across multiple uint32_t words.
uint32_t nbits
Number of bits in a word, will be 32.
uint32_t nwords
Number of words int the w array.
uint32_t cap
Number of actual flags (nbits * nwords)
uint32_t * w
Word array of uint32_t to hold the bitset data.