structDict
struct Dict
keys: [string]
values: [int]
states: [int]
count: int
taken: int
enddict: look things up by name. use "dict.jamo"
Dict maps text to ints, and TextDict maps text to text. Both are hash tables: a key's hash picks a place, and if that place is taken, the next ones are tried. A removed key leaves a marker, so keys placed after it can still be found. The table doubles when it's two thirds full.
struct Dict
keys: [string]
values: [int]
states: [int]
count: int
taken: int
endstruct TextDict
keys: [string]
values: [string]
states: [int]
count: int
taken: int
endfunc dict_hash(key: string): int
FNV-1a over the key's bytes, kept between 0 and 2^62 so it's never below 0
func dict_find(keys: [string], states: [int], key: string): int
Where a key is, or -1 - where it can go when it's missing. states: 0 empty, 1 in use, 2 removed
func dict_empty_states(size: int): [int]
func new_dict(): Dict
func Dict.set(key: string, value: int)
func Dict.grow()
func Dict.get(key: string): int
The value for a key. A missing key stops with an error, so check has() first when it may be missing
func Dict.get_or(key: string, fallback: int): int
The value for a key, or the fallback when it's missing
func Dict.has(key: string): bool
func Dict.remove(key: string): bool
Takes a key out. Answers whether it was there
func Dict.size(): int
func Dict.key_list(): [string]
Every key, in no particular order
func new_text_dict(): TextDict
func TextDict.set(key: string, value: string)
func TextDict.grow()
func TextDict.get(key: string): string
func TextDict.get_or(key: string, fallback: string): string
func TextDict.has(key: string): bool
func TextDict.remove(key: string): bool
func TextDict.size(): int
func TextDict.key_list(): [string]