MutMap
enum MutMap[k: Type, v: Type, r: Eff]
Sourcecase MutMap(Region[r], Ref[Map[k, v], r])
The Mutable Map type.
Definitions
Updates the mutable map m
with k -> f(v)
if k -> v
is in m
.
Otherwise leaves the map is unchanged.
def adjustWithKey(f: k -> (v -> v \ ef), k: k, m: MutMap[k, v, r]): Unit \ ef + r with Order[k]
SourceUpdates the mutable map m
with k -> f(k, v)
if k -> v
is in m
.
Otherwise leaves the map is unchanged.
def clear(m: MutMap[k, v, r]): Unit \ r
SourceRemoves all mappings from the mutable map m
.
def copy(rc: Region[r1], m: MutMap[k, v, r]): MutMap[k, v, r1] \ r + r1
SourceReturns a shallow copy of the mutable map m
.
def count(f: k -> (v -> Bool \ ef), m: MutMap[k, v, r]): Int32 \ ef + r
SourceReturns 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 empty(rc: Region[r]): MutMap[k, v, r] \ r
SourceReturns a fresh empty mutable map.
def exists(f: k -> (v -> Bool \ ef), m: MutMap[k, v, r]): Bool \ ef + r
SourceReturns 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(f: k -> (v -> Bool), m: MutMap[k, v, r]): Option[(k, v)] \ r
SourceAlias for findLeft
.
The function f
must be pure.
def findLeft(f: k -> (v -> Bool), m: MutMap[k, v, r]): Option[(k, v)] \ r
SourceOptionally 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(f: k -> (v -> Bool), m: MutMap[k, v, r]): Option[(k, v)] \ r
SourceOptionally 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(f: b -> (v -> b \ ef), i: b, m: MutMap[k, v, r]): b \ ef + r
SourceApplies 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(f: b -> (k -> (v -> b \ ef)), i: b, m: MutMap[k, v, r]): b \ ef + r
SourceApplies 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(f: v -> (b -> b \ ef), s: b, m: MutMap[k, v, r]): b \ ef + r
SourceApplies 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(f: v -> ((Unit -> b \ ef) -> b \ ef), z: b, m: MutMap[k, v, r]): b \ ef + r
SourceApplies 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(f: k -> (v -> (b -> b \ ef)), s: b, m: MutMap[k, v, r]): b \ ef + r
SourceApplies 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(f: k -> (v -> ((Unit -> b \ ef) -> b \ ef)), z: b, m: MutMap[k, v, r]): b \ ef + r
SourceApplies 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(f: b -> (k -> (v -> b \ ef)), i: b, m: MutMap[k, v, r]): b \ ef + r
SourceAlias for foldLeftWithKey
.
def forAll(f: k -> (v -> Bool \ ef), m: MutMap[k, v, r]): Bool \ ef + r
SourceReturns 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(f: k -> (v -> Unit \ ef), m: MutMap[k, v, r]): Unit \ ef + r
SourceApplies f
to all the (key, value)
pairs in the mutable map m
.
def forEachWithIndex(f: Int32 -> (k -> (v -> Unit \ ef)), m: MutMap[k, v, r]): Unit \ ef + r
SourceApply the effectful function f
to all the (key, value)
pairs in the mutable map m
along with that element's index.
Returns Some(v)
if k -> v
is in the mutable map m
.
Otherwise returns None
.
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.
Returns v
if k -> v
is in the mutable map m
.
Otherwise returns d
.
def isEmpty(m: MutMap[k, v, r]): Bool \ r
SourceReturns true
if and only if m
is the empty map.
def isProperSubmapOf(m1: MutMap[k, v, r1], m2: MutMap[k, v, r2]): Bool \ r1 + r2 with Order[k], Eq[v]
SourceReturns true
if and only if all mappings in the mutable map m1
occur in the mutable map m2
and m1 != m2
.
def isSubmapOf(m1: MutMap[k, v, r1], m2: MutMap[k, v, r2]): Bool \ r1 + r2 with Order[k], Eq[v]
SourceReturns true
if and only if all mappings in the mutable map m1
occur in the mutable map m2
.
def iterator(rc: Region[r1], m: MutMap[k, v, r2]): Iterator[(k, v), r1 + r2, r1] \ r1 + r2
SourceReturns an iterator over all key-value pairs in m
.
def iteratorKeys(rc: Region[r1], m: MutMap[k, v, r2]): Iterator[k, r1 + r2, r1] \ r1 + r2
SourceReturns an iterator over keys in m
.
def iteratorValues(rc: Region[r1], m: MutMap[k, v, r2]): Iterator[v, r1 + r2, r1] \ r1 + r2
SourceReturns an iterator over values in m
.
Returns the concatenation of the string representation of each key k
in m
with sep
inserted between each element.
Returns the concatenation of the string representation of each value v
in m
with sep
inserted between each element.
def joinWith(f: k -> (v -> String \ ef), sep: String, m: MutMap[k, v, r]): String \ ef + r
SourceReturns the concatenation of the string representation of each key-value pair
k => v
in m
according to f
with sep
inserted between each element.
Returns the keys of the mutable map m
.
def map(rc1: Region[r1], f: v1 -> v2 \ ef, m: MutMap[k, v1, r]): MutMap[k, v2, r1] \ ef + r + r1
SourceReturns 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(rc: Region[r1], f: k -> (v1 -> v2 \ ef), m: MutMap[k, v1, r]): MutMap[k, v2, r1] \ ef + r + r1
SourceReturns 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(m: MutMap[k, v, r]): Option[(k, v)] \ r
SourceOptionally finds k => v
where k
is the largest key according to the Order
instance of k
.
Returns None
if m
is empty.
def maximumKeyBy(cmp: k -> (k -> Comparison \ ef), m: MutMap[k, v, r]): Option[(k, v)] \ ef + r
SourceOptionally 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
.
@Parallel
Optionally finds k => v
where v
is the largest value.
Returns None
if m
is empty.
def maximumValueBy(cmp: v -> (v -> Comparison \ ef), m: MutMap[k, v, r]): Option[(k, v)] \ ef + r
SourceOptionally 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
.
Returns true
if and only if the mutable map m
contains the key 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(f: v -> (v -> v \ ef), m1: MutMap[k, v, r1], m2: MutMap[k, v, r2]): Unit \ ef + r1 + r2 with Order[k]
SourceMerges the mutable map m1
into the mutable map m2
where key collisions are resolved with the merge function f
.
def mergeWithKey(f: k -> (v -> (v -> v \ ef)), m1: MutMap[k, v, r1], m2: MutMap[k, v, r2]): Unit \ ef + r1 + r2 with Order[k]
SourceMerges 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(m: MutMap[k, v, r]): Option[(k, v)] \ r
SourceOptionally finds k -> v
where k
is the smallest key according to the Order
instance of k
.
Returns None
if m
is empty.
def minimumKeyBy(cmp: k -> (k -> Comparison \ ef), m: MutMap[k, v, r]): Option[(k, v)] \ ef + r
SourceOptionally 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
.
@Parallel
Optionally finds k => v
where v
is the smallest value.
Returns None
if m
is empty.
def minimumValueBy(cmp: v -> (v -> Comparison \ ef), m: MutMap[k, v, r]): Option[(k, v)] \ ef + r
SourceOptionally 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 nonEmpty(m: MutMap[k, v, r]): Bool \ r
SourceReturns true
if and only if m
is a non-empty map.
Updates the mutable map m
with the binding k -> v
. Replaces any existing binding.
def putWith(f: v -> (v -> v \ ef), k: k, v: v, m: MutMap[k, v, r]): Unit \ ef + r with Order[k]
SourceUpdates 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 rangeQuery(p: k -> Comparison \ ef, m: MutMap[k, v, r]): List[(k, v)] \ ef + r
SourceExtracts 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 rangeQueryWith(p: k -> Comparison \ ef1, f: k -> (v -> Unit \ ef2), m: MutMap[k, v, r]): Unit \ ef1 + ef2 + r
SourceApplies f
to all key-value pairs (k, v)
in the mutable map m
where p(k)
returns EqualTo
.
def reduceLeft(f: v -> (v -> v \ ef), m: MutMap[k, v, r]): Option[v] \ ef + r
SourceApplies 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(f: k -> (v -> (k -> (v -> (k, v) \ ef))), m: MutMap[k, v, r]): Option[(k, v)] \ ef + r
SourceApplies 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(f: v -> (v -> v \ ef), m: MutMap[k, v, r]): Option[v] \ ef + r
SourceApplies 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(f: k -> (v -> (k -> (v -> (k, v) \ ef))), m: MutMap[k, v, r]): Option[(k, v)] \ ef + r
SourceApplies 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.
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.
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.
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(a: MutMap[k, v, r1], b: MutMap[k, v, r2]): Bool \ r1 + r2 with Order[k], Eq[v]
SourceReturns true
if MutMaps a
and b
have the same elements, i.e. are structurally equal.
Returns the singleton map where key k
is mapped to value v
.
def size(m: MutMap[k, v, r]): Int32 \ r
SourceReturns the number of keys in the mutable map m
.
def sumKeys(m: MutMap[Int32, v, r]): Int32 \ r
SourceReturns the sum of all keys in the map m
.
def sumValues(m: MutMap[k, Int32, r]): Int32 \ r
SourceReturns the sum of all values in the map m
.
def sumWith(f: k -> (v -> Int32 \ ef), m: MutMap[k, v, r]): Int32 \ ef + r
SourceReturns 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 toArray(rc1: Region[r1], m: MutMap[k, v, r]): Array[(k, v), r1] \ r + r1
SourceReturns the mutable map m
as an array of key-value pairs.
def toList(m: MutMap[k, v, r]): List[(k, v)] \ r
SourceReturns the mutable map m
as a list of key-value pairs.
def toMap(m: MutMap[k, v, r]): Map[k, v] \ r
SourceReturns the mutable map m
as an immutable map.
def toMutDeque(rc1: Region[r1], m: MutMap[k, v, r2]): MutDeque[(k, v), r1] \ r2 + r1
SourceReturns m
as a MutDeque.
Returns the mutable map m
as a set of key-value pairs.
Returns a string representation of the given MutMap m
.
def toVector(m: MutMap[k, v, r]): Vector[(k, v)] \ r
SourceReturns the mutable map m
as a vector of key-value pairs.
Applies the function f
to every value in the mutable map m
.
Applies the function f
to every value in the mutable map m
.
def valuesOf(m: MutMap[k, v, r]): List[v] \ r
SourceReturns the values of the mutable map m
.