Bit Arrays

Compressed boolean arrays are useful to create memory efficient masks, so they are part of divERGe as static inline functions (i.e. only from the C interface). Documentation of all functions is found below:

static inline void bit_set(cbyte_t *b, cbit bit)
[source]

set bit number bit of byte b to one

static inline void bit_unset(cbyte_t *b, cbit bit)
[source]

set bit number bit of byte b to zero

static inline void bit_toggle(cbyte_t *b, cbit bit)
[source]

toggle bit number bit of byte b

static inline cbit bit_get(const cbyte_t *b, cbit bit)
[source]

get bit number bit of byte b

static inline size_t bitary_nbytes(size_t nbit)
[source]

get number of bytes required to represent nbit contiguous bits in memory

static inline cbyte_t *bitary_alloc(size_t nbit)
[source]

allocate a bit array with at least nbit bits, all set to zero. The returnet memory must be free’d with free or diverge_mem_free().

static inline void bitary_set(cbyte_t *ary, size_t bitidx)
[source]

set the \(n\)-th bit (bitidx) of the bit array ary to one

static inline void bitary_unset(cbyte_t *ary, size_t bitidx)
[source]

set the \(n\)-th bit (bitidx) of the bit array ary to zero

static inline void bitary_toggle(cbyte_t *ary, size_t bitidx)
[source]

toggle the \(n\)-th bit (bitidx) of the bit array ary

static inline cbit bitary_get(const cbyte_t *ary, size_t bitidx)
[source]

get the \(n\)-th bit (bitidx) of the bit array ary

static inline void bitary_set_all(cbyte_t *ary, size_t nbit)
[source]

set the first nbit bits of the bit array ary to one

static inline void bitary_unset_all(cbyte_t *ary, size_t nbit)
[source]

set the first nbit bits of the bit array ary to zero

static inline void bitary_toggle_all(cbyte_t *ary, size_t nbit)
[source]

toggle the first nbit bits of the bit array ary