code wiki / (root) / sketch_bit_vector.nx

sketch_bit_vector.nx

buildroot/runtime/sketch_bit_vector.nx

6343 B243 linesdepth 4pulls 4 transitivereach 1 importersview sourcekind sketch/demotopic sketch
docsdependenciesstructsconstsfunctions

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

syscalls.nx sketch_types.nx sketch_bit_vector.nx sketch_bit_vector_test.nx

imports: syscalls.nxsketch_types.nx

imported by: sketch_bit_vector_test.nx

structs

25struct BitVector {

consts

22const NX_BV_MIN_BITS: i64 = 8
23const NX_BV_MAX_BITS: i64 = 1073741824 // 1G bits = 128 MB

functions

35func nx_bv_alloc(n_bits: i64) -> *BitVector {
called by 1: main
56func nx_bv_set(v: *BitVector, i: i64) -> i64 {
called by 1: main
70func nx_bv_clear(v: *BitVector, i: i64) -> i64 {
called by 1: main
84func nx_bv_toggle(v: *BitVector, i: i64) -> i64 {
called by 1: main
102func nx_bv_get(v: *BitVector, i: i64) -> i64 {
112func nx_bv_popcount_byte(b: i64) -> i64 {
122func nx_bv_recompute_popcount(v: *BitVector) -> i64 {
called by 1: nx_bv_popcount calls 1: nx_bv_popcount_byte
134func nx_bv_popcount(v: *BitVector) -> i64 {
141func nx_bv_popcount_range(v: *BitVector, lo: i64, hi: i64) -> i64 {
called by 1: main calls 1: nx_bv_get
156func nx_bv_ffs(v: *BitVector) -> i64 {
called by 1: main calls 1: nx_bv_get
165func nx_bv_ffc(v: *BitVector) -> i64 {
called by 1: main calls 1: nx_bv_get
178func nx_bv_and(dst: *BitVector, src: *BitVector) -> i64 {
called by 1: main
189func nx_bv_or(dst: *BitVector, src: *BitVector) -> i64 {
called by 1: main
200func nx_bv_xor(dst: *BitVector, src: *BitVector) -> i64 {
called by 1: main
211func nx_bv_not(v: *BitVector) -> i64 {
called by 1: main
223func nx_bv_query_popcount(v: *BitVector) -> *ApproxI64 {
called by 1: main calls 2: nx_bv_popcountnx_approx_new
230func nx_bv_memory_bytes(v: *BitVector) -> i64 {
234func nx_bv_clear_all(v: *BitVector) -> i64 {
called by 1: main