Hash_Map module

entry

procedureextensionsince 0.23.0Source

A pointer to the key's value, adding a zero-initialized one if the key is missing. added says whether it was added. Handy for counting.

Example↗
Hash_Map :: #import "Extensions/Hash_Map";

counts: Hash_Map.Map(string, int);
defer Hash_Map.deinit(*counts);

for word: string.["a", "b", "a"] {
    count := Hash_Map.entry(*counts, word);
    count.* += 1;
}
assert(Hash_Map.get(*counts, "a") == 2);
entry :: (map: *Map, key: map.Key) -> (value: *map.Value, added: bool)

Parameters

map: *Map
key: map.Key

Returns

value: *map.Value
added: bool

See also