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 size_t bitary_nbytes(size_t nbit)
[source] get number of bytes required to represent
nbitcontiguous bits in memory
-
static inline cbyte_t *bitary_alloc(size_t nbit)
[source] allocate a bit array with at least
nbitbits, all set to zero. The returnet memory must be free’d withfreeordiverge_mem_free().
-
static inline void bitary_set(cbyte_t *ary, size_t bitidx)
[source] set the \(n\)-th bit (
bitidx) of the bit arrayaryto one
-
static inline void bitary_unset(cbyte_t *ary, size_t bitidx)
[source] set the \(n\)-th bit (
bitidx) of the bit arrayaryto zero
-
static inline void bitary_toggle(cbyte_t *ary, size_t bitidx)
[source] toggle the \(n\)-th bit (
bitidx) of the bit arrayary
-
static inline cbit bitary_get(const cbyte_t *ary, size_t bitidx)
[source] get the \(n\)-th bit (
bitidx) of the bit arrayary
-
static inline void bitary_set_all(cbyte_t *ary, size_t nbit)
[source] set the first
nbitbits of the bit arrayaryto one