nx_sketch_bit_vector.nx
buildroot/runtime/nx_sketch_bit_vector.nx
about
sketch_bit_vector.nx -- dense bit vector with popcount + bitwise ops.
Foundational primitive for bitmap indices, finite-universe set ops,
Bloom variants, sparse-index compression, etc.
API:
set(i) bit i := 1
clear(i) bit i := 0
toggle(i) bit i := ~bit i
get(i) return bit i (0 or 1)
popcount() count of set bits (cached on mutation)
popcount_range(lo, hi) count over [lo, hi)
ffs() find first set bit (-1 if none)
ffc() find first clear bit
bv_and / bv_or / bv_xor / bv_not in-place bitwise ops
Production tier; exact semantics.
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_sketch_types.nx
imported by: nobody (leaf or entry point)
structs
| 31 | struct BitVector |
consts
| 28 | const NX_BV_MIN_BITS: i64 = 8 |
| 29 | const NX_BV_MAX_BITS: i64 = 1073741824 // 1G bits = 128 MB |
functions
| 41 | func nx_bv_alloc(n_bits: i64) -> *BitVector calls 1: sys_mmap |
| 62 | func nx_bv_set(v: *BitVector, i: i64) -> i64 |
| 76 | func nx_bv_clear(v: *BitVector, i: i64) -> i64 |
| 90 | func nx_bv_toggle(v: *BitVector, i: i64) -> i64 |
| 108 | func nx_bv_get(v: *BitVector, i: i64) -> i64 |
| 118 | func nx_bv_popcount_byte(b: i64) -> i64 called by 1: nx_bv_recompute_popcount |
| 128 | func nx_bv_recompute_popcount(v: *BitVector) -> i64 |
| 140 | func nx_bv_popcount(v: *BitVector) -> i64 |
| 147 | func nx_bv_popcount_range(v: *BitVector, lo: i64, hi: i64) -> i64 calls 1: nx_bv_get |
| 162 | func nx_bv_ffs(v: *BitVector) -> i64 calls 1: nx_bv_get |
| 171 | func nx_bv_ffc(v: *BitVector) -> i64 calls 1: nx_bv_get |
| 184 | func nx_bv_and(dst: *BitVector, src: *BitVector) -> i64 |
| 195 | func nx_bv_or(dst: *BitVector, src: *BitVector) -> i64 |
| 206 | func nx_bv_xor(dst: *BitVector, src: *BitVector) -> i64 |
| 217 | func nx_bv_not(v: *BitVector) -> i64 |
| 229 | func nx_bv_query_popcount(v: *BitVector) -> *ApproxI64 |
| 236 | func nx_bv_memory_bytes(v: *BitVector) -> i64 |
| 240 | func nx_bv_clear_all(v: *BitVector) -> i64 |