nx_set.nx
buildroot/runtime/nx_set.nx
about
nx_set.nx -- unordered set of i64 elements.
Thin wrapper over nx_hash that uses the value as both key and a
sentinel "1" payload. Foundation for:
* Visited-set in graph traversals (DFS/BFS)
* Reachable-block analysis in opt
* Used-symbol tracking in nxld
* Dedup of result lists
API:
nx_set_new(cap_pow2)
nx_set_add(s, x) -- 1 if newly added, 0 if already present
nx_set_has(s, x) -- 1 / 0
nx_set_count(s)
Caller invariant (inherited from nx_hash): element 0 is reserved
(collides with empty-slot sentinel). If you need to track 0, use
nx_intern instead (which has its own remapping).
dependencies 2 imports · 0 importers
imports: syscalls.nxnx_hash.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 30 | struct NxSet |
consts
| 34 | const NX_SET_BYTES: i64 = 8 |
functions
| 36 | func nx_set_new(cap_pow2: i64) -> *NxSet |
| 44 | func nx_set_add(s: *NxSet, x: i64) -> i64 |
| 52 | func nx_set_has(s: *NxSet, x: i64) -> i64 |
| 57 | func nx_set_count(s: *NxSet) -> i64 { return nx_hash_count(s.h) } |
| 61 | func main() -> i64 |