std.vec
growable arrays that bump-allocate from an arena; no per-element frees resetting the arena frees every Vec in it; don’t touch one after
pub Vec :: struct($T: type) { region: *Arena, data: []T, count: usize,}region: grows into this; borrowed, not owneddata: backing storage; capacity == data.lencount: elements in use
Vec.len
Section titled “Vec.len”pub len :: fn(self: *Self) -> usizeVec.cap
Section titled “Vec.cap”pub cap :: fn(self: *Self) -> usizeVec.is_empty
Section titled “Vec.is_empty”pub is_empty :: fn(self: *Self) -> boolVec.get
Section titled “Vec.get”pub get :: fn(self: *Self, i: usize) -> TVec.set
Section titled “Vec.set”pub set :: fn(self: *Self, i: usize, v: T)Vec.at
Section titled “Vec.at”pub at :: fn(self: *Self, i: usize) -> *Tpointer to element i, for in-place mutation
Vec.last
Section titled “Vec.last”pub last :: fn(self: *Self) -> Tassumes non-empty
Vec.items
Section titled “Vec.items”pub items :: fn(self: *Self) -> []Tvalid until the next growth
Vec.reserve
Section titled “Vec.reserve”pub reserve :: fn(self: *Self, want: usize)capacity for at least want; doubles, never shrinks
Vec.push
Section titled “Vec.push”pub push :: fn(self: *Self, item: T)Vec.extend
Section titled “Vec.extend”pub extend :: fn(self: *Self, src: []const T)append all of src
Vec.pop
Section titled “Vec.pop”pub pop :: fn(self: *Self) -> Tassumes non-empty
Vec.insert
Section titled “Vec.insert”pub insert :: fn(self: *Self, i: usize, item: T)shifts the tail right; O(n)
Vec.remove
Section titled “Vec.remove”pub remove :: fn(self: *Self, i: usize) -> Tshifts the tail left, keeps order; O(n)
Vec.remove_swap
Section titled “Vec.remove_swap”pub remove_swap :: fn(self: *Self, i: usize) -> TO(1): last element moves into i; order NOT kept
Vec.clear
Section titled “Vec.clear”pub clear :: fn(self: *Self)keeps capacity
Vec.clone_into
Section titled “Vec.clone_into”pub clone_into :: fn(self: *Self, into: *Arena) -> Vec(T)deep copy into into; lets data escape a scratch arena
pub make :: fn($T: type, a: *Arena) -> Vec(T)empty, bound to a
with_cap
Section titled “with_cap”pub with_cap :: fn($T: type, a: *Arena, cap: usize) -> Vec(T)empty with cap reserved
pub from :: fn($T: type, a: *Arena, src: []const T) -> Vec(T)copies src into a
VecUnmanaged
Section titled “VecUnmanaged”pub VecUnmanaged :: struct($T: type) { data: []T, count: usize,}VecUnmanaged(T): no region of its own; growing calls take the *Arena
VecUnmanaged.len
Section titled “VecUnmanaged.len”pub len :: fn(self: *Self) -> usizeVecUnmanaged.cap
Section titled “VecUnmanaged.cap”pub cap :: fn(self: *Self) -> usizeVecUnmanaged.is_empty
Section titled “VecUnmanaged.is_empty”pub is_empty :: fn(self: *Self) -> boolVecUnmanaged.get
Section titled “VecUnmanaged.get”pub get :: fn(self: *Self, i: usize) -> TVecUnmanaged.set
Section titled “VecUnmanaged.set”pub set :: fn(self: *Self, i: usize, v: T)VecUnmanaged.last
Section titled “VecUnmanaged.last”pub last :: fn(self: *Self) -> TVecUnmanaged.items
Section titled “VecUnmanaged.items”pub items :: fn(self: *Self) -> []TVecUnmanaged.clear
Section titled “VecUnmanaged.clear”pub clear :: fn(self: *Self)VecUnmanaged.reserve
Section titled “VecUnmanaged.reserve”pub reserve :: fn(self: *Self, a: *Arena, want: usize)VecUnmanaged.push
Section titled “VecUnmanaged.push”pub push :: fn(self: *Self, a: *Arena, item: T)VecUnmanaged.pop
Section titled “VecUnmanaged.pop”pub pop :: fn(self: *Self) -> Tpub empty :: fn($T: type) -> VecUnmanaged(T)no storage yet; first push allocates