bitset.h

A Bit Set is an array where each bit can be individually modified and queried by using bitwise operators such as |, &, ^, ~, >> and << (or, and, xor, not, right shift, left shift respectively).

BitSet Implementation

This BitSet implementation uses an array of type cmc_bitset_word which can be typedefed to any unsigned type such as uint8_t, uint16_t, uint32_t, uint64_t, size_t, etc. The BitSet does not make use of K or V. Because of that, it also doesn't have Functions Tables.

The BitSet is initialized with a custom capacity but, if a bit index accessed is greater than the total capacity, the BitSet will resize. This means that the BitSet will try to guarantee that every bit index is accessible, as long as there is enough memory.

BitSet Generation Macros

  • CMC_GENERATE_BITSET(PFX, SNAME) - Generate full definition.
  • CMC_GENERATE_BITSET_HEADER(PFX, SNAME) - Generate only the header portion
  • CMC_GENERATE_BITSET_SOURCE(PFX, SNAME) - Generate only the source portion
ParameterDescription
PFXFunctions namespace or prefix
SNAMEStructure name

BitSet Structures

Declared structsDescription
struct SNAMEA bit set data structure
struct SNAME##_iterA bit set iterator

struct SNAME

struct SNAMEDescription
cmc_bitset_word *bufferDynamic array of bits.
size_t capacityCurrent array capacity .
int flagFlag indicating errors or success.
struct cmc_alloc_node *allocCustom allocation functions.
struct cmc_callbacks *callbacksCallback functions.

struct SNAME##_iter

struct SNAME##_iterDescription
struct SNAME *targetBitSet being iterated over.
size_t cursorCursor's current position (index).
bool startIf the iterator reached the start of the iteration.
bool endIf the iterator reached the end of iteration.

cmc_bitset_word

The typedefed data type o the underlying bit set buffer.

typedef uint32_t cmc_bitset_word;

This typedef can be changed to any unsigned integer data type and the bit set will still work properly.

Callbacks

This list associates which functions calls which callbacks.

  • create
    • PFX##_set()
    • PFX##_set_range()
  • read
  • update
  • delete
    • PFX##_clear()
    • PFX##_clear_range()
  • resize
    • PFX##_resize()

Functions Table

CMPCPYSTRFREEHASHPRI
#2ef625#2ef625#2ef625#2ef625#2ef625#2ef625