vec.nx
buildroot/runtime/vec.nx
about
vec.nx -- dynamic-array of i64 (Phase G7 in the roadmap).
Specialised to i64 for now; generics will generalise to Vec<T> once
parse.nx grows multi-param + full monomorphization support. That
migration is API-compatible: rename occurrences of i64 in element
positions only.
Growth: geometric 2x on push (classical amortized O(1)). Backing
storage via sys_mmap; never freed (compiler run-once, servers
long-running will switch to a per-request arena later).
No bounds-check-on-get to match kernel-code convention; call
vec_get only after checking vec_len.
dependencies 1 imports · 1 importers
imports: syscalls.nx
imported by: vec_test.nx
structs
| 17 | struct Vec { |
consts
| none |
functions
| 25 | func vec_new(initial_cap: i64) -> *Vec {
called by 1: main |
| 38 | func vec_len(v: *Vec) -> i64 {
called by 1: main |
| 43 | func vec_get(v: *Vec, i: i64) -> i64 {
called by 1: main |
| 48 | func vec_set(v: *Vec, i: i64, x: i64) -> i64 {
called by 1: main |
| 56 | func vec_grow(v: *Vec, want: i64) -> i64 {
called by 1: vec_push |
| 72 | func vec_push(v: *Vec, x: i64) -> i64 { |
| 83 | func vec_pop(v: *Vec) -> i64 {
called by 1: main |
| 91 | func vec_truncate(v: *Vec, n: i64) -> i64 {
called by 1: main |
| 97 | func vec_index_of(v: *Vec, needle: i64) -> i64 {
called by 1: main |