MultiMap
Definitions
def
adjust
[vefk]
(
f :
v -> v \ ef
k :
k
m :
MultiMap[k, v]
)
: MultiMap[k, v]
\ ef
with
Order[k]
Order[v]
Updates m with k => map(f, vs) if k => vs is in m.
Otherwise, returns m.
def
adjustWithKey
[kvef]
(
f :
k -> (v -> v \ ef)
k :
k
m :
MultiMap[k, v]
)
: MultiMap[k, v]
\ ef
with
Order[k]
Order[v]
Updates m with k => map(f(k), vs) if k => vs is in m. Otherwise, returns m.
def
count
[kvef]
(
f :
k -> (v -> Bool \ ef)
m :
MultiMap[k, v]
)
: Int32
\ ef
Returns 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
[kv]
(
m1 :
MultiMap[k, v]
m2 :
MultiMap[k, v]
)
: MultiMap[k, v]
\ Pure
with
Order[k]
Order[v]
Returns the difference of m1 and m2 i.e m1 - m2 (left biased).
def
empty
[kv]
: MultiMap[k, v]
\ Pure
Returns the empty MultiMap.
def
exists
[kvef]
(
f :
k -> (v -> Bool \ ef)
m :
MultiMap[k, v]
)
: Bool
\ ef
Returns 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
[vefk]
(
f :
v -> Bool \ ef
m :
MultiMap[k, v]
)
: MultiMap[k, v]
\ ef
with
Order[k]
Order[v]
Returns a MultiMap of all mappings k => v in m where v satisfies the predicate f.
def
filterWithKey
[kvef]
(
f :
k -> (v -> Bool \ ef)
m :
MultiMap[k, v]
)
: MultiMap[k, v]
\ ef
with
Order[k]
Order[v]
Returns a MultiMap of all mappings k => v in m where (k, v) satisfies the predicate f.
def
find
[kvef]
(
f :
k -> (v -> Bool \ ef)
m :
MultiMap[k, v]
)
: Option[(k, v)]
\ ef
Alias for findLeft.
def
findLeft
[kvef]
(
f :
k -> (v -> Bool \ ef)
m :
MultiMap[k, v]
)
: Option[(k, v)]
\ ef
Optionally returns the first mapping of m that satisfies the predicate f when searching from left to right.
def
findRight
[kvef]
(
f :
k -> (v -> Bool \ ef)
m :
MultiMap[k, v]
)
: Option[(k, v)]
\ ef
Optionally returns the first mapping of m that satisfies the predicate f when searching from right to left.
def
foldLeft
[bvefk]
(
f :
b -> (v -> b \ ef)
s :
b
m :
MultiMap[k, v]
)
: b
\ ef
Applies 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
[bkvef]
(
f :
b -> (k -> (v -> b \ ef))
s :
b
m :
MultiMap[k, v]
)
: b
\ ef
Applies 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
[vefbk]
(
f :
v -> b \ ef
m :
MultiMap[k, v]
)
: b
\ ef
with
Monoid[b]
Returns the result of mapping each value and combining the results.
def
foldMapWithKey
[kvefb]
(
f :
k -> (v -> b \ ef)
m :
MultiMap[k, v]
)
: b
\ ef
with
Monoid[b]
Returns the result of mapping each key-value pair and combining the results.
def
foldRight
[vbefk]
(
f :
v -> (b -> b \ ef)
s :
b
m :
MultiMap[k, v]
)
: b
\ ef
Applies 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
[vefbk]
(
f :
v -> ((Unit -> b \ ef) -> b \ ef)
z :
b
m :
MultiMap[k, v]
)
: b
\ ef
Applies 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
[kvbef]
(
f :
k -> (v -> (b -> b \ ef))
s :
b
m :
MultiMap[k, v]
)
: b
\ ef
Applies 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
[kvefb]
(
f :
k -> (v -> ((Unit -> b \ ef) -> b \ ef))
z :
b
m :
MultiMap[k, v]
)
: b
\ ef
Applies 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
[bkvef]
(
f :
b -> (k -> (v -> b \ ef))
s :
b
m :
MultiMap[k, v]
)
: b
\ ef
Alias for foldLeftWithKey.
def
forAll
[kvef]
(
f :
k -> (v -> Bool \ ef)
m :
MultiMap[k, v]
)
: Bool
\ ef
Returns true if and only if all mappings in m satisfy the predicate f.
Returns true if m is the empty MultiMap.
def
forEach
[kvef]
(
f :
k -> (v -> Unit \ ef)
m :
MultiMap[k, v]
)
: Unit
\ ef
Applies f to every (key, value) of MultiMap m.
def
forEachWithIndex
[kvef]
(
f :
Int32 -> (k -> (v -> Unit \ ef))
m :
MultiMap[k, v]
)
: Unit
\ ef
Applies f to tuple (index, key, value) formed of the keys and values of
MultiMap m and the index of the traversal.
def
get
[kv]
(
k :
k
m :
MultiMap[k, v]
)
: Set[v]
\ Pure
with
Order[k]
Returns Some(vs) if k => vs is in m.
Otherwise returns Nil.
def
insert
[kv]
(
k :
k
v :
v
m :
MultiMap[k, v]
)
: MultiMap[k, v]
\ Pure
with
Order[k]
Order[v]
Updates m with k => v.
def
insertAll
[ktv]
(
k :
k
vs :
t[v]
m :
MultiMap[k, v]
)
: MultiMap[k, v]
\ Pure
with
Order[k]
Order[v]
Foldable[t]
Updates m with k => vs.
Where vs is any foldable container. If vs is empty nothing is inserted.
def
intersection
[kv]
(
m1 :
MultiMap[k, v]
m2 :
MultiMap[k, v]
)
: MultiMap[k, v]
\ Pure
with
Order[k]
Order[v]
Returns the intersection of m1 and m2.
def
isEmpty
[kv]
(
m :
MultiMap[k, v]
)
: Bool
\ Pure
Returns true if and only if m is the empty MultiMap.
def
iterator
[rkv]
(
rc :
Region[r]
m :
MultiMap[k, v]
)
: Iterator[(k, Set[v]), r, r]
\ r
Returns an iterator over all key-value pairs in m i.e. k => Set#{v_1, ..., v_n}.
def
keysOf
[kv]
(
m :
MultiMap[k, v]
)
: Set[k]
\ Pure
with
Order[k]
Returns the keys of m.
def
map
[v1efv2k]
(
f :
v1 -> v2 \ ef
m :
MultiMap[k, v1]
)
: MultiMap[k, v2]
\ ef
with
Order[v2]
Returns a MultiMap with mappings k => f(v) for every k => v in m.
Purity reflective: Runs in parallel when given a pure function f.
def
mapWithKey
[kv1efv2]
(
f :
k -> (v1 -> v2 \ ef)
m :
MultiMap[k, v1]
)
: MultiMap[k, v2]
\ ef
with
Order[v2]
Returns 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
memberOf
[kv]
(
k :
k
m :
MultiMap[k, v]
)
: Bool
\ Pure
with
Order[k]
Returns true if and only if m contains the key k.
def
reduceLeft
[vefk]
(
f :
v -> (v -> v \ ef)
m :
MultiMap[k, v]
)
: Option[v]
\ ef
Applies 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
[kvef]
(
f :
k -> (v -> (k -> (v -> (k, v) \ ef)))
m :
MultiMap[k, v]
)
: Option[(k, v)]
\ ef
Applies 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
[vefk]
(
f :
v -> (v -> v \ ef)
m :
MultiMap[k, v]
)
: Option[v]
\ ef
Applies 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
[kvef]
(
f :
k -> (v -> (k -> (v -> (k, v) \ ef)))
m :
MultiMap[k, v]
)
: Option[(k, v)]
\ ef
Applies 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
remove
[kv]
(
k :
k
m :
MultiMap[k, v]
)
: MultiMap[k, v]
\ Pure
with
Order[k]
Removes the mapping k from the MultiMap m.
def
removeWithValue
[kv]
(
k :
k
v :
v
m :
MultiMap[k, v]
)
: MultiMap[k, v]
\ Pure
with
Order[k]
Order[v]
Removes the mapping of (k, v) from the MultiMap m it it exists.
def
singleton
[kv]
(
k :
k
v :
v
)
: MultiMap[k, v]
\ Pure
with
Order[k]
Order[v]
Returns the singleton MultiMap where key k is mapped to value v.
def
sumKeys
[v]
(
m :
MultiMap[Int32, v]
)
: Int32
\ Pure
Returns the sum of all keys in the MultiMap m.
def
sumValues
[k]
(
m :
MultiMap[k, Int32]
)
: Int32
\ Pure
Returns the sum of all values in the MultiMap m.
def
sumWith
[kvef]
(
f :
k -> (v -> Int32 \ ef)
m :
MultiMap[k, v]
)
: Int32
\ ef
Returns 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
[kv]
(
m :
MultiMap[k, v]
)
: List[(k, v)]
\ Pure
Returns the MultiMap m as a list of singleton key-value pairs in ascending order.
def
toAssocList
[kv]
(
m :
MultiMap[k, v]
)
: List[(k, Set[v])]
\ Pure
Returns the MultiMap m as a list of (key, Set[value]) pairs in ascending order.
def
toDescList
[kv]
(
m :
MultiMap[k, v]
)
: List[(k, v)]
\ Pure
Returns the MultiMap m as a list of singleton key-value pairs in descending order.
def
toList
[kv]
(
m :
MultiMap[k, v]
)
: List[(k, v)]
\ Pure
Returns the MultiMap m as a list of singleton key-value pairs.
def
toMap
[kv]
(
m :
MultiMap[k, v]
)
: Map[k, Set[v]]
\ Pure
Returns the MultiMap m as a list of singleton key-value pairs in ascending order.
def
toMutDeque
[rkv]
(
rc :
Region[r]
m :
MultiMap[k, v]
)
: MutDeque[(k, Set[v]), r]
\ r
Returns the MultiMap m as a list of singleton key-value pairs in ascending order.
def
toString
[kv]
(
m :
MultiMap[k, v]
)
: String
\ Pure
with
ToString[k]
ToString[v]
Returns a string representation of m.
def
union
[kv]
(
m1 :
MultiMap[k, v]
m2 :
MultiMap[k, v]
)
: MultiMap[k, v]
\ Pure
with
Order[k]
Order[v]
Returns the union of m1 and m2.
def
update
[vefk]
(
f :
v -> Option[v] \ ef
k :
k
m :
MultiMap[k, v]
)
: MultiMap[k, v]
\ ef
with
Order[k]
Order[v]
Updates m with k => v1 if k => v is in m and f(v) = Some(v1). Otherwise, returns m.
def
updateWithKey
[kvef]
(
f :
k -> (v -> Option[v] \ ef)
k :
k
m :
MultiMap[k, v]
)
: MultiMap[k, v]
\ ef
with
Order[k]
Order[v]
Updates m with k => v1 if k => v is in m and f(k, v) = Some(v1). Otherwise, returns m.
def
valuesOf
[kv]
(
m :
MultiMap[k, v]
)
: List[v]
\ Pure
with
Order[k]
Returns the values of m.
Answer may contain duplicates where values were ascribed to multiple keys.