keen/col/mut-map
SourceThis is a standard module
and does not need to be explicitly imported.
mut-map[k, v] record (has private fields)Mutable unordered map.
to[k, v] v mut[k](a (k, v)[]) k keyConvert a list of pairs to a map. Later pairs overwrite earlier pairs with the same key.
subscript[k, v] v option(a v mut[k], key k) k keyGets the value associated with a key. Returns an empty option if
key is not in the map.set-subscript[k, v] void(a v mut[k], key k, value v) k keySets the key to the given value, so that
a[key] will return value. If the key was already in the map, this overwrites the previous value.swap[k, v] void(a v mut[k], b v mut[k]) k keySet the contents of
a to the contents of b and vice versa. This is O(1).remove[k, v] v option(a v mut[k], key k) k keyIf the key is in the map, removes it and returns the associated value.
ensure[k, v] v(a v mut[k], key k, get-value v mut(void)) k keyEnsures that a key is the map. If the key is already in the map, does nothing and returns the associated value. Otherwise, sets the value to
get-value[] and returns that.~=[k, v] void(a v mut[k], (key k, value v)) k keyThis is the same as calling
a[key] := value. Prefer to write it that way instead.map-values=[k, v] void(a v mut[k], f v mut((k, v))) k keyCalls
f on every key and value, and replaces the value with the new value returned by f. Does not modify keys.mut-map-unsorted[k, v] record (has private fields)