MultiMap
Definitions
def adjust(f: v -> v \ ef, k: k, m: MultiMap[k, v]): MultiMap[k, v] \ ef
SourceUpdates m
with k => map(f, vs)
if k => vs
is in m
.
Otherwise, returns m
.
def adjustWithKey(f: k -> (v -> v \ ef), k: k, m: MultiMap[k, v]): MultiMap[k, v] \ ef
SourceUpdates m
with k => map(f(k), vs)
if k => vs
is in m
. Otherwise, returns m
.
@ParallelWhenPure
def count(f: k -> (v -> Bool \ ef), m: MultiMap[k, v]): Int32 \ ef
SourceReturns the number of mappings k => v
in m
that satisfy the predicate f
.
Purity reflective: Runs in parallel when given a pure function f
.
def difference(m1: MultiMap[k, v], m2: MultiMap[k, v]): MultiMap[k, v]
SourceReturns the difference of m1
and m2
i.e m1 - m2
(left biased).
def exists(f: k -> (v -> Bool \ ef), m: MultiMap[k, v]): Bool \ ef
SourceReturns true
if and only if at least one mapping in m
satisfies the predicate f
.
Returns false
if m
is the empty MultiMap.
def filter(f: v -> Bool \ ef, m: MultiMap[k, v]): MultiMap[k, v] \ ef
SourceReturns a MultiMap of all mappings k => v
in m
where v
satisfies the predicate f
.
def filterWithKey(f: k -> (v -> Bool \ ef), m: MultiMap[k, v]): MultiMap[k, v] \ ef
SourceReturns a MultiMap of all mappings k => v
in m
where (k, v)
satisfies the predicate f
.
def findLeft(f: k -> (v -> Bool \ ef), m: MultiMap[k, v]): Option[(k, v)] \ ef
SourceOptionally returns the first mapping of m
that satisfies the predicate f
when searching from left to right.
def findRight(f: k -> (v -> Bool \ ef), m: MultiMap[k, v]): Option[(k, v)] \ ef
SourceOptionally returns the first mapping of m
that satisfies the predicate f
when searching from right to left.
def foldLeft(f: b -> (v -> b \ ef), s: b, m: MultiMap[k, v]): b \ ef
SourceApplies f
to a start value s
and all values in m
going from left to right.
That is, the result is of the form: f(...f(f(s, v1), v2)..., vn)
.
def foldLeftWithKey(f: b -> (k -> (v -> b \ ef)), s: b, m: MultiMap[k, v]): b \ ef
SourceApplies f
to a start value s
and all key-value pairs in m
going from left to right.
That is, the result is of the form: f(...f(f(s, k1, v1), k2, v2)..., vn)
.
def foldMap(f: v -> b \ ef, m: MultiMap[k, v]): b \ ef
SourceReturns the result of mapping each value and combining the results.
def foldMapWithKey(f: k -> (v -> b \ ef), m: MultiMap[k, v]): b \ ef
SourceReturns the result of mapping each key-value pair and combining the results.
def foldRight(f: v -> (b -> b \ ef), s: b, m: MultiMap[k, v]): b \ ef
SourceApplies f
to a start value s
and all values in 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: MultiMap[k, v]): b \ ef
SourceApplies f
to a start value z
and all values in 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: MultiMap[k, v]): b \ ef
SourceApplies f
to a start value s
and all key-value pairs in 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: MultiMap[k, v]): b \ ef
SourceApplies f
to a start value z
and all key-value pairs in 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)), s: b, m: MultiMap[k, v]): b \ ef
SourceAlias for foldLeftWithKey
.
def forAll(f: k -> (v -> Bool \ ef), m: MultiMap[k, v]): Bool \ ef
SourceReturns true
if and only if all mappings in m
satisfy the predicate f
.
Returns true
if m
is the empty MultiMap.
def forEach(f: k -> (v -> Unit \ ef), m: MultiMap[k, v]): Unit \ ef
SourceApplies f
to every (key, value)
of MultiMap m
.
def forEachWithIndex(f: Int32 -> (k -> (v -> Unit \ ef)), m: MultiMap[k, v]): Unit \ ef
SourceApplies f
to tuple (index, key, value)
formed of the keys and values of
MultiMap m
and the index of the traversal.
def get(k: k, m: MultiMap[k, v]): Set[v]
SourceReturns Some(vs)
if k => vs
is in m
.
Otherwise returns Nil
.
def insertAll(k: k, vs: t[v], m: MultiMap[k, v]): MultiMap[k, v]
SourceUpdates m
with k => vs
.
Where vs
is any foldable container. If vs
is empty nothing is inserted.
def intersection(m1: MultiMap[k, v], m2: MultiMap[k, v]): MultiMap[k, v]
SourceReturns the intersection of m1
and m2
.
def iterator(rc: Region[r], m: MultiMap[k, v]): Iterator[(k, Set[v]), r, r] \ r
SourceReturns an iterator over all key-value pairs in m
i.e. k => Set#{v_1, ..., v_n}
.
@ParallelWhenPure
def map(f: v1 -> v2 \ ef, m: MultiMap[k, v1]): MultiMap[k, v2] \ ef
SourceReturns a MultiMap with mappings k => f(v)
for every k => v
in m
.
Purity reflective: Runs in parallel when given a pure function f
.
@ParallelWhenPure
def mapWithKey(f: k -> (v1 -> v2 \ ef), m: MultiMap[k, v1]): MultiMap[k, v2] \ ef
SourceReturns a MultiMap with mappings k => f(k, v)
for every k => v
in m
.
Purity reflective: Runs in parallel when given a pure function f
.
def reduceLeft(f: v -> (v -> v \ ef), m: MultiMap[k, v]): Option[v] \ ef
SourceApplies f
to all values in 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 MultiMap.
def reduceLeftWithKey(f: k -> (v -> (k -> (v -> (k, v) \ ef))), m: MultiMap[k, v]): Option[(k, v)] \ ef
SourceApplies f
to all mappings in 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 MultiMap.
def reduceRight(f: v -> (v -> v \ ef), m: MultiMap[k, v]): Option[v] \ ef
SourceApplies f
to all values in 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 MultiMap.
def reduceRightWithKey(f: k -> (v -> (k -> (v -> (k, v) \ ef))), m: MultiMap[k, v]): Option[(k, v)] \ ef
SourceApplies f
to all mappings in 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 MultiMap.
def removeWithValue(k: k, v: v, m: MultiMap[k, v]): MultiMap[k, v]
SourceRemoves the mapping of (k, v)
from the MultiMap m
it it exists.
def singleton(k: k, v: v): MultiMap[k, v]
SourceReturns the singleton MultiMap where key k
is mapped to value v
.
@ParallelWhenPure
def sumWith(f: k -> (v -> Int32 \ ef), m: MultiMap[k, v]): Int32 \ ef
SourceReturns the sum of all key-value pairs k => v
in the MultiMap m
according to the function f
.
Purity reflective: Runs in parallel when given a pure function f
.
def toAscList(m: MultiMap[k, v]): List[(k, v)]
SourceReturns the MultiMap m
as a list of singleton key-value pairs in ascending order.
def toAssocList(m: MultiMap[k, v]): List[(k, Set[v])]
SourceReturns the MultiMap m
as a list of (key, Set[value])
pairs in ascending order.
def toDescList(m: MultiMap[k, v]): List[(k, v)]
SourceReturns the MultiMap m
as a list of singleton key-value pairs in descending order.
def toList(m: MultiMap[k, v]): List[(k, v)]
SourceReturns the MultiMap m
as a list of singleton key-value pairs.
def toMap(m: MultiMap[k, v]): Map[k, Set[v]]
SourceReturns the MultiMap m
as a list of singleton key-value pairs in ascending order.
def toMutDeque(rc: Region[r], m: MultiMap[k, v]): MutDeque[(k, Set[v]), r] \ r
SourceReturns the MultiMap m
as a list of singleton key-value pairs in ascending order.
def union(m1: MultiMap[k, v], m2: MultiMap[k, v]): MultiMap[k, v]
SourceReturns the union of m1
and m2
.
def update(f: v -> Option[v] \ ef, k: k, m: MultiMap[k, v]): MultiMap[k, v] \ ef
SourceUpdates m
with k => v1
if k => v
is in m
and f(v) = Some(v1)
. Otherwise, returns m
.
def updateWithKey(f: k -> (v -> Option[v] \ ef), k: k, m: MultiMap[k, v]): MultiMap[k, v] \ ef
SourceUpdates m
with k => v1
if k => v
is in m
and f(k, v) = Some(v1)
. Otherwise, returns m
.
def valuesOf(m: MultiMap[k, v]): List[v]
SourceReturns the values of m
.
Answer may contain duplicates where values were ascribed to multiple keys.