MultiMap
enum MultiMap[k: Type, v: Type]Sourcecase MultiMap(Map[k, Set[v]])Type of immutable maps that allow multiple values per key.
Multiple values are stored in a Set so duplicates are not allowed.
The key and value types must implement the Eq and Order traits.
Type of immutable maps that allow multiple values per key, and its functions.
Instances
instance CommutativeMonoid[MultiMap[k, v]] with Order[k], Order[v]Sourceinstance CommutativeSemiGroup[MultiMap[k, v]] with Order[k], Order[v]Sourceinstance Formattable[MultiMap[k, v]] with Formattable[k], Formattable[v]Sourcetype Aef = Aef[k] + Aef[v]type Idx = ktype Elm = Set[v]type Aef = KeyNotFoundinstance UnorderedFoldable[MultiMap[k]]SourceDefinitions
def adjust(f: v -> v \ ef, k: k, m: MultiMap[k, v]): MultiMap[k, v] \ ef with Order[k], Order[v]§ 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 with Order[k], Order[v]§ SourceUpdates m with k => map(f(k), vs) if k => vs is in m. Otherwise, returns m.
@ParallelWhenPure 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(m1: MultiMap[k, v], m2: MultiMap[k, v]): MultiMap[k, v] with Order[k], Order[v]§ SourceReturns the difference of m1 and m2 i.e m1 - m2 (left biased).
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(f: v -> Bool \ ef, m: MultiMap[k, v]): MultiMap[k, v] \ ef with Order[k], Order[v]§ 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 with Order[k], Order[v]§ SourceReturns a MultiMap of all mappings k => v in m where (k, v) satisfies the predicate f.
Alias for findLeft.
Optionally returns the first mapping of m that satisfies the predicate f when searching from left to right.
Optionally returns the first mapping of m that satisfies the predicate f when searching from right to left.
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).
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).
Returns the result of mapping each value and combining the results.
Returns the result of mapping each key-value pair and combining the results.
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))).
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))).
Alias for foldLeftWithKey.
Returns true if and only if all mappings in m satisfy the predicate f.
Returns true if m is the empty MultiMap.
Applies f to every (key, value) of MultiMap m.
Applies f to tuple (index, key, value) formed of the keys and values of
MultiMap m and the index of the traversal.
Returns Some(vs) if k => vs is in m.
Otherwise returns Set.empty().
Updates m with k => Set.union(v, v0) if k => v0 is in m.
Otherwise, returns m with k => Set.singleton(v).
def insertAll(k: k, vs: t[v], m: MultiMap[k, v]): MultiMap[k, v] \ Aef[t] with Order[k], Order[v], Foldable[t]§ 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] with Order[k], Order[v]§ SourceReturns the intersection of m1 and m2.
Returns an iterator over all key-value pairs in m i.e. k => Set#{v_1, ..., v_n}.
@ParallelWhenPure 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.
@ParallelWhenPure def mapWithKey(f: k -> (v1 -> v2 \ ef), m: MultiMap[k, v1]): MultiMap[k, v2] \ ef with Order[v2]§ 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.
Returns true if and only if m contains the key k.
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(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.
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(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.
Removes the mapping k from the MultiMap m.
Removes the mapping of (k, v) from the MultiMap m if it exists.
Returns the singleton MultiMap where key k is mapped to value v.
Returns the MultiMap m as a list of singleton key-value pairs in ascending order.
Returns the MultiMap m as a list of (key, Set[value]) pairs in ascending order.
Returns the MultiMap m as a list of singleton key-value pairs in descending order.
Returns the MultiMap m as a list of singleton key-value pairs.
Returns the MultiMap m as a list of singleton key-value pairs in ascending order.
Returns a string representation of m.
Returns the union of m1 and m2.
def update(f: v -> Option[v] \ ef, k: k, m: MultiMap[k, v]): MultiMap[k, v] \ ef with Order[k], Order[v]§ SourceUpdates m with k => v1 if k => v is in m and f(v) = Some(v1). Otherwise, returns m.