crow/col/map.crow (source)
map[k, v] record
(has non-public fields)
Immutable unordered map type.
A map is logically a collection of key-value pairs ((k, v)).
A key can appear at most once, and given a key, you can access the associated value in O(1).
There should be ==, <=>, and hash-mix functions defined for the key type k.
==[k, v] bool(a k[v], b k[v]) k key, v equal
keyequalnew[k, v] k[v](...a (k, v) tuple2 array) k key
keyCreates a new map from the given key-value pairs.
Later pairs overwrite earlier pairs with the same key.
to[k, v] k[v](a (k, v) tuple2 array) k key
keyConverts a list of pairs to a map.
Later pairs overwrite earlier pairs with the same key.
to[k, v] (k, v) tuple2 array(a k[v]) k key
keyReturns all pairs in the map.
is-empty[k, v] bool(a k[v]) k key
keyTrue iff the map has no entries.
size[k, v] nat64(a k[v]) k key
keyNumber of pairs.
subscript[k, v] v?(a k[v], key k) k key
keyGets the value associated with a key.
Returns an empty option if the key is not in a.
in[k, v] bool(key k, a k[v]) k key
keytrue iff the key is in the map.
~[k, v] k[v](a k[v], anonymous (k, v) tuple2) k key
keyAssociates the key with the value.
This may overwrite the key if it's already in a, or add a new entry.
~~[k, v] k[v](a k[v], pairs k[v]) k key
keyAdds/updates many entries to a.
keys[k, v] k array(a k[v]) k key
keyvalues[k, v] v array(a k[v]) k key
key-[k, v] k[v](a k[v], key k) k key
keyRemoves a key and its associated value.
If the key is not in the map, returns a unmodified.
(To distinguish that case, and to get the removed value, use try-remove.)
try-remove[k, v] (v, k[v]) tuple2?(a k[v], key k) k key
keyRemoves a key and its associated value, and returns the value and the new map.
If the key is not in the map, returns an empty option.
iterate[k, v] bool(a k[v], f mut bool((k, v) tuple2))
map-builder[k, v] record mut
(has non-public fields)
build[k, v] k[v](a build-options, f mut void((k, v) map-builder)) k key
key