map.jamo (built in)

map: look things up by any key. use "map.jamo"

Map<K, V> maps keys to values of any type. Keys can be ints, strings, bools or enums, since they're compared with == and hashed with hash_of. The entries sit in order in keys and values, and slots is the hash table: each slot holds its entry's place plus 1, 0 when empty, or -1 where an entry was removed, so entries placed after it can still be found. The table doubles when it's two thirds full.

structMap

struct Map<K, V>
    keys: [K]
    values: [V]
    slots: [int]
    removed: int
end

funcnew_map

func new_map<K, V>(): Map<K, V>

funcmap_empty_slots

func map_empty_slots(size: int): [int]

funcMap.find

func Map<K, V>.find(key: K): int

The slot holding the key, or -1 - the slot where it can go when it's missing

funcMap.set

func Map<K, V>.set(key: K, value: V)

funcMap.grow

func Map<K, V>.grow()

Doubles the table when most of it is in use, or rebuilds it the same size to clear out removed slots

funcMap.get

func Map<K, V>.get(key: K): V

funcMap.get_or

func Map<K, V>.get_or(key: K, fallback: V): V

funcMap.has

func Map<K, V>.has(key: K): bool

funcMap.remove

func Map<K, V>.remove(key: K): bool

The last entry moves into the removed one's place, so the entries stay packed together

funcMap.size

func Map<K, V>.size(): int

funcMap.key_list

func Map<K, V>.key_list(): [K]

A copy of the keys, in the order they were added, except that removing one moves the last key into its place

funcMap.value_list

func Map<K, V>.value_list(): [V]