MutMap
Definitions
def
adjust!
[vefkr]
(
f :
v -> v \ ef
k :
k
m :
MutMap[k, v, r]
)
: Unit
\ ef + r
with
Order[k]
Updates the mutable map m
with k -> f(v)
if k -> v
is in m
.
Otherwise leaves the map is unchanged.
def
adjustWithKey!
[kvefr]
(
f :
k -> (v -> v \ ef)
k :
k
m :
MutMap[k, v, r]
)
: Unit
\ ef + r
with
Order[k]
Updates the mutable map m
with k -> f(k, v)
if k -> v
is in m
.
Otherwise leaves the map is unchanged.
def
clear!
[kvr]
(
m :
MutMap[k, v, r]
)
: Unit
\ r
Removes all mappings from the mutable map m
.
def
copy
[r1kvr]
(
rc :
Region[r1]
m :
MutMap[k, v, r]
)
: MutMap[k, v, r1]
\ r + r1
Returns a shallow copy of the mutable map m
.
def
count
[kvefr]
(
f :
k -> (v -> Bool \ ef)
m :
MutMap[k, v, r]
)
: Int32
\ ef + r
Returns the number of mappings in the mutable map m
that satisfy the predicate function f
.
Purity reflective: Runs in parallel when given a pure function f
.
def
exists
[kvefr]
(
f :
k -> (v -> Bool \ ef)
m :
MutMap[k, v, r]
)
: Bool
\ ef + r
Returns true
if and only if at least one mapping in the mutable map m
satisfies the predicate function f
.
Returns false
if m
is the empty map.
def
find
[kvr]
(
f :
k -> (v -> Bool)
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ r
Alias for findLeft
.
The function f
must be pure.
def
findLeft
[kvr]
(
f :
k -> (v -> Bool)
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ r
Optionally returns the first mapping of the mutable map m
that satisfies the predicate function f
when searching from left to right.
The function f
must be pure.
def
findRight
[kvr]
(
f :
k -> (v -> Bool)
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ r
Optionally returns the first mapping of the mutable map m
that satisfies the predicate function f
when searching from right to left.
The function f
must be pure.
def
foldLeft
[bvefkr]
(
f :
b -> (v -> b \ ef)
i :
b
m :
MutMap[k, v, r]
)
: b
\ ef + r
Applies f
to a start value i
and all values in the mutable map m
going from left to right.
That is, the result is of the form: f(...f(f(i, v1), v2)..., vn)
.
def
foldLeftWithKey
[bkvefr]
(
f :
b -> (k -> (v -> b \ ef))
i :
b
m :
MutMap[k, v, r]
)
: b
\ ef + r
Applies f
to a start value i
and all key-value pairs in the mutable map m
going from left to right.
That is, the result is of the form: f(...f(k2, f(k1, i, v1), v2)..., vn)
.
def
foldRight
[vbefkr]
(
f :
v -> (b -> b \ ef)
s :
b
m :
MutMap[k, v, r]
)
: b
\ ef + r
Applies f
to a start value s
and all values in the mutable map m
going from right to left.
That is, the result is of the form: f(v1, ...f(vn-1, f(vn, s)))
.
def
foldRightWithCont
[vefbkr]
(
f :
v -> ((Unit -> b \ ef) -> b \ ef)
z :
b
m :
MutMap[k, v, r]
)
: b
\ ef + r
Applies f
to a start value z
and all values in the mutable map m
going from right to left.
That is, the result is of the form: f(v1, ...f(vn-1, f(vn, z)))
.
A foldRightWithCont
allows early termination by not calling the continuation.
def
foldRightWithKey
[kvbefr]
(
f :
k -> (v -> (b -> b \ ef))
s :
b
m :
MutMap[k, v, r]
)
: b
\ ef + r
Applies f
to a start value s
and all key-value pairs in the mutable map m
going from right to left.
That is, the result is of the form: f(k1, v1, ...f(kn-1, vn-1, f(kn, vn, s)))
.
def
foldRightWithKeyCont
[kvefbr]
(
f :
k -> (v -> ((Unit -> b \ ef) -> b \ ef))
z :
b
m :
MutMap[k, v, r]
)
: b
\ ef + r
Applies f
to a start value z
and all key-value pairs in the mutable map m
going from right to left.
That is, the result is of the form: f(k1, v1, ...f(kn-1, vn-1, f(kn, vn, z)))
.
A foldRightWithKeyCont
allows early termination by not calling the continuation.
def
foldWithKey
[bkvefr]
(
f :
b -> (k -> (v -> b \ ef))
i :
b
m :
MutMap[k, v, r]
)
: b
\ ef + r
Alias for foldLeftWithKey
.
def
forAll
[kvefr]
(
f :
k -> (v -> Bool \ ef)
m :
MutMap[k, v, r]
)
: Bool
\ ef + r
Returns true
if and only if all mappings in the mutable map m
satisfy the predicate function f
.
Returns true
if m
is the empty map.
def
forEach
[kvefr]
(
f :
k -> (v -> Unit \ ef)
m :
MutMap[k, v, r]
)
: Unit
\ ef + r
Applies f
to all the (key, value)
pairs in the mutable map m
.
def
forEachWithIndex
[kvefr]
(
f :
Int32 -> (k -> (v -> Unit \ ef))
m :
MutMap[k, v, r]
)
: Unit
\ ef + r
Apply the effectful function f
to all the (key, value)
pairs in the mutable map m
along with that element's index.
def
get
[kvr]
(
k :
k
m :
MutMap[k, v, r]
)
: Option[v]
\ r
with
Order[k]
Returns Some(v)
if k -> v
is in the mutable map m
.
Otherwise returns None
.
def
getOrElsePut!
[kvr]
(
k :
k
d :
v
m :
MutMap[k, v, r]
)
: v
\ r
with
Order[k]
Returns v
if k -> v
is in the mutable map m
.
Otherwise updates the mutable map m
with a new mapping k -> d
and returns d.
def
getWithDefault
[kvr]
(
k :
k
d :
v
m :
MutMap[k, v, r]
)
: v
\ r
with
Order[k]
Returns v
if k -> v
is in the mutable map m
.
Otherwise returns d
.
def
isEmpty
[kvr]
(
m :
MutMap[k, v, r]
)
: Bool
\ r
Returns true
if and only if m
is the empty map.
def
isProperSubmapOf
[kvr1r2]
(
m1 :
MutMap[k, v, r1]
m2 :
MutMap[k, v, r2]
)
: Bool
\ r1 + r2
with
Order[k]
Eq[v]
Returns true
if and only if all mappings in the mutable map m1
occur in the mutable map m2
and m1 != m2
.
def
isSubmapOf
[kvr1r2]
(
m1 :
MutMap[k, v, r1]
m2 :
MutMap[k, v, r2]
)
: Bool
\ r1 + r2
with
Order[k]
Eq[v]
Returns true
if and only if all mappings in the mutable map m1
occur in the mutable map m2
.
def
iterator
[r1kvr2]
(
rc :
Region[r1]
m :
MutMap[k, v, r2]
)
: Iterator[(k, v), r1 + r2, r1]
\ r1 + r2
Returns an iterator over all key-value pairs in m
.
def
iteratorKeys
[r1kvr2]
(
rc :
Region[r1]
m :
MutMap[k, v, r2]
)
: Iterator[k, r1 + r2, r1]
\ r1 + r2
Returns an iterator over keys in m
.
def
iteratorValues
[r1kvr2]
(
rc :
Region[r1]
m :
MutMap[k, v, r2]
)
: Iterator[v, r1 + r2, r1]
\ r1 + r2
Returns an iterator over values in m
.
def
joinKeys
[kvr]
(
sep :
String
m :
MutMap[k, v, r]
)
: String
\ r
with
ToString[k]
Returns the concatenation of the string representation of each key k
in m
with sep
inserted between each element.
def
joinValues
[kvr]
(
sep :
String
m :
MutMap[k, v, r]
)
: String
\ r
with
ToString[v]
Returns the concatenation of the string representation of each value v
in m
with sep
inserted between each element.
def
joinWith
[kvefr]
(
f :
k -> (v -> String \ ef)
sep :
String
m :
MutMap[k, v, r]
)
: String
\ ef + r
Returns the concatenation of the string representation of each key-value pair
k => v
in m
according to f
with sep
inserted between each element.
def
keysOf
[kvr]
(
m :
MutMap[k, v, r]
)
: Set[k]
\ r
with
Order[k]
Returns the keys of the mutable map m
.
def
map
[r1v1efv2kr]
(
rc1 :
Region[r1]
f :
v1 -> v2 \ ef
m :
MutMap[k, v1, r]
)
: MutMap[k, v2, r1]
\ ef + r + r1
Returns a map with mappings k => f(v)
for every k => v
in m
.
Purity reflective: Runs in parallel when given a pure function f
.
def
mapWithKey
[r1kv1efv2r]
(
rc :
Region[r1]
f :
k -> (v1 -> v2 \ ef)
m :
MutMap[k, v1, r]
)
: MutMap[k, v2, r1]
\ ef + r + r1
Returns a map with mappings k => f(k, v)
for every k => v
in m
.
Purity reflective: Runs in parallel when given a pure function f
.
def
maximumKey
[kvr]
(
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ r
Optionally finds k => v
where k
is the largest key according to the Order
instance of k
.
Returns None
if m
is empty.
def
maximumKeyBy
[kefvr]
(
cmp :
k -> (k -> Comparison \ ef)
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ ef + r
Optionally finds k => v
where k
is the largest key according to the given comparator cmp
.
Returns None
if m
is empty.
Purity reflective: Runs in parallel when given a pure function f
.
def
maximumValue
[kvr]
(
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ r
with
Order[v]
Optionally finds k => v
where v
is the largest value.
Returns None
if m
is empty.
def
maximumValueBy
[vefkr]
(
cmp :
v -> (v -> Comparison \ ef)
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ ef + r
Optionally finds k => v
where v
is the largest value according to the given comparator cmp
.
Returns None
if m
is empty.
Purity reflective: Runs in parallel when given a pure function cmp
.
def
memberOf
[kvr]
(
k :
k
m :
MutMap[k, v, r]
)
: Bool
\ r
with
Order[k]
Returns true
if and only if the mutable map m
contains the key k
.
def
merge!
[kvr1r2]
(
m1 :
MutMap[k, v, r1]
m2 :
MutMap[k, v, r2]
)
: Unit
\ r1 + r2
with
Order[k]
Merges the mutable map m1
into the mutable map m2
in a left-biased manner.
That is, key collisions are resolved by taking the mapping from m1
.
def
mergeWith!
[vefkr1r2]
(
f :
v -> (v -> v \ ef)
m1 :
MutMap[k, v, r1]
m2 :
MutMap[k, v, r2]
)
: Unit
\ ef + r1 + r2
with
Order[k]
Merges the mutable map m1
into the mutable map m2
where key collisions are resolved with the merge function f
.
def
mergeWithKey!
[kvefr1r2]
(
f :
k -> (v -> (v -> v \ ef))
m1 :
MutMap[k, v, r1]
m2 :
MutMap[k, v, r2]
)
: Unit
\ ef + r1 + r2
with
Order[k]
Merges the mutable map m1
into the mutable map m2
where key collisions are resolved with the merge function f
, taking both the key and values.
def
minimumKey
[kvr]
(
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ r
Optionally finds k -> v
where k
is the smallest key according to the Order
instance of k
.
Returns None
if m
is empty.
def
minimumKeyBy
[kefvr]
(
cmp :
k -> (k -> Comparison \ ef)
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ ef + r
Optionally finds k => v
where k
is the smallest key according to the given comparator cmp
.
Returns None
if m
is empty.
Purity reflective: Runs in parallel when given a pure function cmp
.
def
minimumValue
[kvr]
(
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ r
with
Order[v]
Optionally finds k => v
where v
is the smallest value.
Returns None
if m
is empty.
def
minimumValueBy
[vefkr]
(
cmp :
v -> (v -> Comparison \ ef)
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ ef + r
Optionally finds k => v
where v
is the smallest value according to the given comparator cmp
.
Returns None
if m
is empty.
Purity reflective: Runs in parallel when given a pure function cmp
.
def
new
[rkv]
(
rc :
Region[r]
)
: MutMap[k, v, r]
\ r
Returns a fresh empty mutable map.
def
put!
[kvr]
(
k :
k
v :
v
m :
MutMap[k, v, r]
)
: Unit
\ r
with
Order[k]
Updates the mutable map m
with the binding k -> v
. Replaces any existing binding.
def
putWith!
[vefkr]
(
f :
v -> (v -> v \ ef)
k :
k
v :
v
m :
MutMap[k, v, r]
)
: Unit
\ ef + r
with
Order[k]
Updates the mutable map m
with the binding k -> f(v, v1)
if k -> v1
is in m
.
Otherwise updates the mutable map m
with the binding k -> v
.
def
query
[kefvr]
(
p :
k -> Comparison \ ef
m :
MutMap[k, v, r]
)
: List[(k, v)]
\ ef + r
Extracts a range of key-value pairs from the mutable map m
.
That is, the result is a list of all pairs (k, v)
where p(k)
returns Equal
.
def
queryWith
[kef1vef2r]
(
p :
k -> Comparison \ ef1
f :
k -> (v -> Unit \ ef2)
m :
MutMap[k, v, r]
)
: Unit
\ ef1 + ef2 + r
Applies f
to all key-value pairs (k, v)
in the mutable map m
where p(k)
returns EqualTo
.
def
reduceLeft
[vefkr]
(
f :
v -> (v -> v \ ef)
m :
MutMap[k, v, r]
)
: Option[v]
\ ef + r
Applies f
to all values in the mutable map m
going from left to right until a single value v
is obtained. Returns Some(v)
.
That is, the result is of the form: Some(f(...f(f(v1, v2), v3)..., vn))
Returns None
if m
is the empty map.
def
reduceLeftWithKey
[kvefr]
(
f :
k -> (v -> (k -> (v -> (k, v) \ ef)))
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ ef + r
Applies f
to all mappings in the mutable map m
going from left to right until a single mapping (k, v)
is obtained. Returns Some((k, v))
.
That is, the result is of the form: Some(f(...f(f(k1, v1, k2, v2), k3, v3)..., kn, vn))
Returns None
if m
is the empty map.
def
reduceRight
[vefkr]
(
f :
v -> (v -> v \ ef)
m :
MutMap[k, v, r]
)
: Option[v]
\ ef + r
Applies f
to all values in the mutable map m
going from right to left until a single value v
is obtained. Returns Some(v)
.
That is, the result is of the form: Some(f(v1, ...f(vn-2, f(vn-1, vn))...))
Returns None
if m
is the empty map.
def
reduceRightWithKey
[kvefr]
(
f :
k -> (v -> (k -> (v -> (k, v) \ ef)))
m :
MutMap[k, v, r]
)
: Option[(k, v)]
\ ef + r
Applies f
to all mappings in the mutable map m
going from right to left until a single mapping (k, v)
is obtained. Returns Some((k, v))
.
That is, the result is of the form: Some(f(k1, v1, ...f(kn-2, vn-2, f(kn-1, vn-1, kn, vn))...))
Returns None
if m
is the empty map.
def
refine!
[vkr]
(
f :
v -> Bool
m :
MutMap[k, v, r]
)
: Unit
\ r
with
Order[k]
Removes all mappings k -> v
from the mutable map m
where v
does not satisfy the predicate function f
.
The function f
must be pure.
def
refineWithKey!
[kvr]
(
f :
k -> (v -> Bool)
m :
MutMap[k, v, r]
)
: Unit
\ r
with
Order[k]
Removes all mappings k -> v
from the mutable map m
where (k, v)
does not satisfy the predicate function f
.
The function f
must be pure.
def
remove!
[kvr]
(
k :
k
m :
MutMap[k, v, r]
)
: Unit
\ r
with
Order[k]
Removes the mapping k
from the mutable map m
.
Leaves the map unchanged if the mutable map m
does not contain any mapping for k
.
def
sameElements
[kvr1r2]
(
a :
MutMap[k, v, r1]
b :
MutMap[k, v, r2]
)
: Bool
\ r1 + r2
with
Order[k]
Eq[v]
Returns true
if MutMaps a
and b
have the same elements, i.e. are structurally equal.
def
singleton
[rkv]
(
rc :
Region[r]
k :
k
v :
v
)
: MutMap[k, v, r]
\ r
with
Order[k]
Returns the singleton map where key k
is mapped to value v
.
def
size
[kvr]
(
m :
MutMap[k, v, r]
)
: Int32
\ r
Returns the size of the mutable map m
.
def
sumKeys
[vr]
(
m :
MutMap[Int32, v, r]
)
: Int32
\ r
Returns the sum of all keys in the map m
.
def
sumValues
[kr]
(
m :
MutMap[k, Int32, r]
)
: Int32
\ r
Returns the sum of all values in the map m
.
def
sumWith
[kvefr]
(
f :
k -> (v -> Int32 \ ef)
m :
MutMap[k, v, r]
)
: Int32
\ ef + r
Returns the sum of all key-value pairs k => v
in the map m
according to the function f
.
Purity reflective: Runs in parallel when given a pure function f
.
def
toList
[kvr]
(
m :
MutMap[k, v, r]
)
: List[(k, v)]
\ r
Returns the mutable map m
as a list of key-value pairs.
def
toMap
[kvr]
(
m :
MutMap[k, v, r]
)
: Map[k, v]
\ r
Returns the mutable map m
as an immutable map.
def
toMutDeque
[r1kvr2]
(
rc1 :
Region[r1]
m :
MutMap[k, v, r2]
)
: MutDeque[(k, v), r1]
\ r2 + r1
Returns m
as a MutDeque.
def
toSet
[kvr]
(
m :
MutMap[k, v, r]
)
: Set[(k, v)]
\ r
with
Order[k]
Order[v]
Returns the mutable map m
as a set of key-value pairs.
def
toString
[kvr]
(
m :
MutMap[k, v, r]
)
: String
\ r
with
ToString[k]
ToString[v]
Returns a string representation of the given MutMap m
.
def
transform!
[vefkr]
(
f :
v -> v \ ef
m :
MutMap[k, v, r]
)
: Unit
\ ef + r
with
Order[k]
Applies the function f
to every value in the mutable map m
.
def
transformWithKey!
[kvefr]
(
f :
k -> (v -> v \ ef)
m :
MutMap[k, v, r]
)
: Unit
\ ef + r
with
Order[k]
Applies the function f
to every value in the mutable map m
.
def
valuesOf
[kvr]
(
m :
MutMap[k, v, r]
)
: List[v]
\ r
Returns the values of the mutable map m
.