sketch_bit_vector.nx
buildroot/runtime/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 · 1 importers
imports: syscalls.nxsketch_types.nx
imported by: sketch_bit_vector_test.nx
structs
| 25 | struct BitVector { |
consts
| 22 | const NX_BV_MIN_BITS: i64 = 8 |
| 23 | const NX_BV_MAX_BITS: i64 = 1073741824 // 1G bits = 128 MB |
functions
| 35 | func nx_bv_alloc(n_bits: i64) -> *BitVector {
called by 1: main |
| 56 | func nx_bv_set(v: *BitVector, i: i64) -> i64 {
called by 1: main |
| 70 | func nx_bv_clear(v: *BitVector, i: i64) -> i64 {
called by 1: main |
| 84 | func nx_bv_toggle(v: *BitVector, i: i64) -> i64 {
called by 1: main |
| 102 | func nx_bv_get(v: *BitVector, i: i64) -> i64 { |
| 112 | func nx_bv_popcount_byte(b: i64) -> i64 {
called by 1: nx_bv_recompute_popcount |
| 122 | func nx_bv_recompute_popcount(v: *BitVector) -> i64 { |
| 134 | func nx_bv_popcount(v: *BitVector) -> i64 { |
| 141 | func nx_bv_popcount_range(v: *BitVector, lo: i64, hi: i64) -> i64 { |
| 156 | func nx_bv_ffs(v: *BitVector) -> i64 { |
| 165 | func nx_bv_ffc(v: *BitVector) -> i64 { |
| 178 | func nx_bv_and(dst: *BitVector, src: *BitVector) -> i64 {
called by 1: main |
| 189 | func nx_bv_or(dst: *BitVector, src: *BitVector) -> i64 {
called by 1: main |
| 200 | func nx_bv_xor(dst: *BitVector, src: *BitVector) -> i64 {
called by 1: main |
| 211 | func nx_bv_not(v: *BitVector) -> i64 {
called by 1: main |
| 223 | func nx_bv_query_popcount(v: *BitVector) -> *ApproxI64 { |
| 230 | func nx_bv_memory_bytes(v: *BitVector) -> i64 { |
| 234 | func nx_bv_clear_all(v: *BitVector) -> i64 {
called by 1: main |