cbits 0.1.1
High-performance BitVector C-API & Python binding
|
Packed BitVector C-API declarations. More...
Go to the source code of this file.
Classes | |
struct | BitVector |
Packed array of bits with support for rank/select operations. More... | |
Macros | |
#define | BV_ALIGN 64 |
Alignment in bytes for all BitVector allocations. | |
#define | BV_WORDS_SUPER_SHIFT 3 |
Number of bits to shift a word index to compute a superblock index. | |
#define | BV_WORDS_SUPER (1u << BV_WORDS_SUPER_SHIFT) |
Number of 64-bit worde per superblock. | |
Functions | |
static size_t | bv_word (const size_t pos) |
Compute the word index for a given bit position. | |
static size_t | bv_bit (const size_t pos) |
Compute the bit offset within its 64-bit word. | |
BitVector * | bv_new (size_t n_bits) |
Allocate a new BitVector with all bits cleared. | |
BitVector * | bv_copy (const BitVector *src) |
Make a copy of an existing BitVector. | |
void | bv_free (BitVector *bv) |
Free all memory associated with a BitVector. | |
void | bv_build_rank (BitVector *bv) |
Build or rebuild the rank tables for a BitVector. | |
static int | bv_get (const BitVector *bv, const size_t pos) |
Get the bit value at a given position. | |
static void | bv_set (BitVector *bv, const size_t pos) |
Set the bit at a given position (set to 1) | |
static void | bv_clear (BitVector *bv, const size_t pos) |
Clear the bit at a given position (set to 0) | |
static void | bv_flip (BitVector *bv, const size_t pos) |
Toggle (flip) the bit at a given position. | |
size_t | bv_rank (BitVector *bv, const size_t pos) |
Compute the rank (number of set bits) up to a position. | |
bool | bv_equal (const BitVector *a, const BitVector *b) |
Test equality of two BitVectors. | |
bool | bv_contains_subvector (const BitVector *a, const BitVector *b) |
Check weather B appears as a contiguous sub-bitvector of A. | |
Packed BitVector C-API declarations.
This header decleares the BitVector C-API:
#define BV_ALIGN 64 |
Alignment in bytes for all BitVector allocations.
#define BV_WORDS_SUPER (1u << BV_WORDS_SUPER_SHIFT) |
Number of 64-bit worde per superblock.
#define BV_WORDS_SUPER_SHIFT 3 |
Number of bits to shift a word index to compute a superblock index.
|
inlinestatic |
Compute the bit offset within its 64-bit word.
pos | bit index |
void bv_build_rank | ( | BitVector * | bv | ) |
|
inlinestatic |
Clear the bit at a given position (set to 0)
Marks the rank table dirty so it will be rebuilt on next rank query.
bv | Pointer to the BitVector |
pos | Bit index |
|
inlinestatic |
Toggle (flip) the bit at a given position.
Marks the rank table dirty so it will be rebuilt on next rank query.
bv | Pointer to the BitVector |
pos | Bit index |
void bv_free | ( | BitVector * | bv | ) |
|
inlinestatic |
Get the bit value at a given position.
bv | Pointer to the BitVector |
pos | Bit index |
0
or 1
depending on the bit value BitVector * bv_new | ( | size_t | n_bits | ) |
size_t bv_rank | ( | BitVector * | bv, |
const size_t | pos | ||
) |
Compute the rank (number of set bits) up to a position.
If the internal rank tables are dirty, they will be rebuilt.
bv | Pointer to the BitVector |
pos | Bit index |
[0...pos]
|
inlinestatic |
Set the bit at a given position (set to 1)
Marks the rank table dirty so it will be rebuilt on next rank query.
bv | Pointer to the BitVector |
pos | Bit index |
|
inlinestatic |
Compute the word index for a given bit position.
pos | bit index |