dict.jamo (built in)

dict: 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.

structDict

struct Dict
    keys: [string]
    values: [int]
    states: [int]
    count: int
    taken: int
end

structTextDict

struct TextDict
    keys: [string]
    values: [string]
    states: [int]
    count: int
    taken: int
end

funcdict_hash

func dict_hash(key: string): int

FNV-1a over the key's bytes, kept between 0 and 2^62 so it's never below 0

funcdict_find

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

funcdict_empty_states

func dict_empty_states(size: int): [int]

funcnew_dict

func new_dict(): Dict

funcDict.set

func Dict.set(key: string, value: int)

funcDict.grow

func Dict.grow()

funcDict.get

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

funcDict.get_or

func Dict.get_or(key: string, fallback: int): int

The value for a key, or the fallback when it's missing

funcDict.has

func Dict.has(key: string): bool

funcDict.remove

func Dict.remove(key: string): bool

Takes a key out. Answers whether it was there

funcDict.size

func Dict.size(): int

funcDict.key_list

func Dict.key_list(): [string]

Every key, in no particular order

funcnew_text_dict

func new_text_dict(): TextDict

funcTextDict.set

func TextDict.set(key: string, value: string)

funcTextDict.grow

func TextDict.grow()

funcTextDict.get

func TextDict.get(key: string): string

funcTextDict.get_or

func TextDict.get_or(key: string, fallback: string): string

funcTextDict.has

func TextDict.has(key: string): bool

funcTextDict.remove

func TextDict.remove(key: string): bool

funcTextDict.size

func TextDict.size(): int

funcTextDict.key_list

func TextDict.key_list(): [string]