crow/col/mut-map.crow
(source)
mut-map
[k
, v
] record
mut
(has non-public fields)
Mutable unordered map.
Unordered means that iteration functions like each
reach each entry in arbitrary order.
new
[k
, v
] k
mut[
v
]
(...
a
(k
, v
) tuple2
array
) k
key
key
New map containing the given pairs.
Later pairs overwrite earlier pairs with the same key.
to
[k
, v
] k
mut[
v
]
(a
(k
, v
) tuple2
array
) k
key
key
Convert a list of pairs to a map.
Later pairs overwrite earlier pairs with the same key.
to
[k
, v
] k
[
v
]
(a
k
mut[
v
]
) k
key
key
to
[k
, v
] (k
, v
) tuple2
array
(a
k
mut[
v
]
) k
key
key
Copy pairs to a list.
move-to
[k
, v
] (k
, v
) tuple2
array
(a
k
mut[
v
]
) k
key
key
Copy pairs to a list and clear the map.
move-to
[k
, v
] k
[
v
]
(a
k
mut[
v
]
) k
key
key
move-to
[k
, v
] k
mut[
v
]
(a
k
mut[
v
]
) k
key
key
copy
[k
, v
] k
mut[
v
]
(a
k
mut[
v
]
) k
key
key
Copy pairs to a new map.
is-empty
[k
, v
] bool
(a
k
mut[
v
]
) k
key
key
true
iff a.size == 0
.
size
[k
, v
] nat64
(a
k
mut[
v
]
) k
key
key
Number of unique keys in the map.
subscript
[k
, v
] v
?
(a
k
mut[
v
]
, key
k
) k
key
key
Gets the value associated with a key.
Returns an empty option if the key is not in the map.
in
[k
, v
] bool
(key
k
, a
k
mut[
v
]
) k
key
key
true
iff the key is in the map.
set-subscript
[k
, v
] void
(a
k
mut[
v
]
, key
k
, value
v
) k
key
key
Sets the key to the given value, so that a[key]
will return value
.
If the key is already in the map, this overwrites the previous value.
clear
[k
, v
] void
(a
k
mut[
v
]
) k
key
key
Remove all keys, leaving the map empty.
swap
[k
, v
] void
(a
k
mut[
v
]
, b
k
mut[
v
]
) k
key
key
Set the contents of a
to the contents of b
and vice versa.
remove
[k
, v
] v
?
(a
k
mut[
v
]
, key
k
) k
key
key
If the key was in the map, remove it and return the old value.
Returns an empty option if the key was not in the map.
ensure
[k
, v
] v
(a
k
mut[
v
]
, key
k
, get-value
mut
v
(void
)) k
key
key
ensure
[k
, v
] v
(a
k
mut[
v
]
, key
k
) k
key
, v
new
key
new
~=
[k
, v
] void
(a
k
mut[
v
]
, anonymous
(k
, v
) tuple2
) k
key
key
This is the same as calling a[b a] := b b
.
~~=
[k
, v
] void
(a
k
mut[
v
]
, pairs
(k
, v
) tuple2
array
) k
key
key
This is the same as calling a ~= x
for every x
in b
.
filter=
[k
, v
] void
(a
k
mut[
v
]
, f
mut
bool
((k
, v
) tuple2
)) k
key
key
Filters the map in place.
Calls f
on every key and value and removes the key if f
returns false.
map-values=
[k
, v
] void
(a
k
mut[
v
]
, f
mut
v
((k
, v
) tuple2
)) k
key
key
Calls f
on every key and value, and replaces the value with the new value returned by f
.
iterate
[k
, v
] bool
(a
k
mut[
v
]
, f
mut
bool
((k
, v
) tuple2
)) k
key
key
Calls f
for every key and value in the map.
build
[k
, v
] k
mut[
v
]
(a
build-options
, f
mut
void
(k
mut[
v
]
)) k
key
key