std.map
open-addressed maps/sets and SortedMap, all in an Arena; no per-entry frees
ByteKey
Section titled “ByteKey”pub ByteKey :: constraint($K)keys whose bytes are their value: no floats, slices, unions or padding
AutoHashMap
Section titled “AutoHashMap”pub AutoHashMap :: struct($K: ByteKey, $V: type) { region: *Arena, states: []u8, keys: []K, vals: []V, count: usize, tombs: usize,}keys hashed and compared by their raw bytes
count: live entriestombs: tombstone slots (count toward the load factor)
AutoHashMap.len
Section titled “AutoHashMap.len”pub len :: fn(self: *Self) -> usizeAutoHashMap.cap
Section titled “AutoHashMap.cap”pub cap :: fn(self: *Self) -> usizeAutoHashMap.is_empty
Section titled “AutoHashMap.is_empty”pub is_empty :: fn(self: *Self) -> boolAutoHashMap.put
Section titled “AutoHashMap.put”pub put :: fn(self: *Self, k: K, v: V)overwrites; grows past 0.75 load (live + tombstones)
AutoHashMap.get
Section titled “AutoHashMap.get”pub get :: fn(self: *Self, k: K) -> ?VAutoHashMap.contains
Section titled “AutoHashMap.contains”pub contains :: fn(self: *Self, k: K) -> boolAutoHashMap.remove
Section titled “AutoHashMap.remove”pub remove :: fn(self: *Self, k: K) -> boolfalse if absent; leaves a tombstone
AutoHashMap.clear
Section titled “AutoHashMap.clear”pub clear :: fn(self: *Self)keeps the tables for reuse
AutoHashMap.entries
Section titled “AutoHashMap.entries”pub entries :: fn(self: *Self) -> AutoEntries(K, V)no particular order; put/remove while iterating may skip or repeat
pub Entry :: struct($K: type, $V: type) { key: K, value: V,}AutoEntries
Section titled “AutoEntries”pub AutoEntries :: struct($K: ByteKey, $V: type) { m: *AutoHashMap(K, V), i: usize,}AutoHashMap.entries iterator
i: the next slot to look at
AutoEntries.next
Section titled “AutoEntries.next”pub next :: fn(self: *Self) -> ?Entry(K, V)pub auto :: fn($K: ByteKey, $V: type, a: *Arena) -> AutoHashMap(K, V)empty map in a
StrMap
Section titled “StrMap”pub StrMap :: struct($V: type) { region: *Arena, states: []u8, keys: [][]const u8, vals: []V, count: usize, tombs: usize,}string keys by content; keys are copied into the arena
StrMap.len
Section titled “StrMap.len”pub len :: fn(self: *Self) -> usizeStrMap.cap
Section titled “StrMap.cap”pub cap :: fn(self: *Self) -> usizeStrMap.is_empty
Section titled “StrMap.is_empty”pub is_empty :: fn(self: *Self) -> boolStrMap.put
Section titled “StrMap.put”pub put :: fn(self: *Self, k: []const u8, v: V)StrMap.get
Section titled “StrMap.get”pub get :: fn(self: *Self, k: []const u8) -> ?VStrMap.contains
Section titled “StrMap.contains”pub contains :: fn(self: *Self, k: []const u8) -> boolStrMap.remove
Section titled “StrMap.remove”pub remove :: fn(self: *Self, k: []const u8) -> boolStrMap.clear
Section titled “StrMap.clear”pub clear :: fn(self: *Self)StrMap.entries
Section titled “StrMap.entries”pub entries :: fn(self: *Self) -> StrEntries(V)no particular order; put/remove while iterating may skip or repeat
StrEntries
Section titled “StrEntries”pub StrEntries :: struct($V: type) { m: *StrMap(V), i: usize,}StrMap.entries iterator; keys are the map’s own copies
StrEntries.next
Section titled “StrEntries.next”pub next :: fn(self: *Self) -> ?Entry([]const u8, V)strmap
Section titled “strmap”pub strmap :: fn($V: type, a: *Arena) -> StrMap(V)empty map in a
AutoSet
Section titled “AutoSet”pub AutoSet :: struct($K: ByteKey) { m: AutoHashMap(K, u8),}AutoHashMap(K, u8) with nothing stored
AutoSet.len
Section titled “AutoSet.len”pub len :: fn(self: *Self) -> usizeAutoSet.is_empty
Section titled “AutoSet.is_empty”pub is_empty :: fn(self: *Self) -> boolAutoSet.contains
Section titled “AutoSet.contains”pub contains :: fn(self: *Self, k: K) -> boolAutoSet.add
Section titled “AutoSet.add”pub add :: fn(self: *Self, k: K) -> booltrue if newly added
AutoSet.remove
Section titled “AutoSet.remove”pub remove :: fn(self: *Self, k: K) -> booltrue if it was there
AutoSet.clear
Section titled “AutoSet.clear”pub clear :: fn(self: *Self)AutoSet.each
Section titled “AutoSet.each”pub each :: fn(self: *Self) -> AutoSetKeys(K)no particular order
AutoSetKeys
Section titled “AutoSetKeys”pub AutoSetKeys :: struct($K: ByteKey) { it: AutoEntries(K, u8),}AutoSet.each iterator
AutoSetKeys.next
Section titled “AutoSetKeys.next”pub next :: fn(self: *Self) -> ?KStrSet
Section titled “StrSet”pub StrSet :: struct { m: StrMap(u8),}strings by content; keeps its own copies
StrSet.len
Section titled “StrSet.len”pub len :: fn(self: *Self) -> usizeStrSet.is_empty
Section titled “StrSet.is_empty”pub is_empty :: fn(self: *Self) -> boolStrSet.contains
Section titled “StrSet.contains”pub contains :: fn(self: *Self, k: []const u8) -> boolStrSet.add
Section titled “StrSet.add”pub add :: fn(self: *Self, k: []const u8) -> booltrue if newly added
StrSet.remove
Section titled “StrSet.remove”pub remove :: fn(self: *Self, k: []const u8) -> booltrue if it was there
StrSet.clear
Section titled “StrSet.clear”pub clear :: fn(self: *Self)StrSet.each
Section titled “StrSet.each”pub each :: fn(self: *Self) -> StrSetKeysno particular order
StrSetKeys
Section titled “StrSetKeys”pub StrSetKeys :: struct { it: StrEntries(u8),}StrSet.each iterator
StrSetKeys.next
Section titled “StrSetKeys.next”pub next :: fn(self: *Self) -> ?[]const u8autoset
Section titled “autoset”pub autoset :: fn($K: ByteKey, a: *Arena) -> AutoSet(K)empty set in a
strset
Section titled “strset”pub strset :: fn(a: *Arena) -> StrSetempty set in a
SortedMap
Section titled “SortedMap”pub SortedMap :: struct($K: type, $V: type, $C: type) { region: *Arena, keys: []K, vals: []V, count: usize, order: C,}sorted arrays in the arena; binary-search get, put/remove shift (fine to ~10k entries)
C has less(self, a, b), like sort::Asc(K) or sort::By(K)
keys: firstcountin use
SortedMap.len
Section titled “SortedMap.len”pub len :: fn(self: *Self) -> usizeSortedMap.is_empty
Section titled “SortedMap.is_empty”pub is_empty :: fn(self: *Self) -> boolSortedMap.put
Section titled “SortedMap.put”pub put :: fn(self: *Self, k: K, v: V)replaces an existing value
SortedMap.get
Section titled “SortedMap.get”pub get :: fn(self: *Self, k: K) -> ?VSortedMap.contains
Section titled “SortedMap.contains”pub contains :: fn(self: *Self, k: K) -> boolSortedMap.remove
Section titled “SortedMap.remove”pub remove :: fn(self: *Self, k: K) -> booltrue if it was there
SortedMap.first
Section titled “SortedMap.first”pub first :: fn(self: *Self) -> ?Entry(K, V)smallest key; null if empty
SortedMap.last
Section titled “SortedMap.last”pub last :: fn(self: *Self) -> ?Entry(K, V)largest key; null if empty
SortedMap.entries
Section titled “SortedMap.entries”pub entries :: fn(self: *Self) -> SortedEntries(K, V, C)smallest first; put/remove while iterating may skip or repeat
SortedMap.from
Section titled “SortedMap.from”pub from :: fn(self: *Self, k: K) -> SortedEntries(K, V, C)from the first key not before k
SortedMap.clear
Section titled “SortedMap.clear”pub clear :: fn(self: *Self)SortedEntries
Section titled “SortedEntries”pub SortedEntries :: struct($K: type, $V: type, $C: type) { m: *SortedMap(K, V, C), i: usize,}SortedMap.entries/from iterator, key order
SortedEntries.next
Section titled “SortedEntries.next”pub next :: fn(self: *Self) -> ?Entry(K, V)sorted_with
Section titled “sorted_with”pub sorted_with :: fn($K: type, $V: type, $C: type, a: *Arena, order: C) -> SortedMap(K, V, C)map in a ordered by order
sorted
Section titled “sorted”pub sorted :: fn($K: type, $V: type, a: *Arena) -> SortedMap(K, V, sort::Asc(K))keys ordered by <
sorted_by
Section titled “sorted_by”pub sorted_by :: fn($K: type, $V: type, a: *Arena, less: fn(K, K) -> bool) -> SortedMap(K, V, sort::By(K))keys ordered by less (mem::less_bytes for text)