Map
enum Map[k: Type, v: Type]Sourcecase Map(RedBlackTree[k, v])The Map type.
A map is currently represented internally as a red-black tree.
Instances
instance CommutativeMonoid[Map[k, v]] with Order[k], CommutativeMonoid[v]Sourceinstance CommutativeSemiGroup[Map[k, v]] with Order[k], CommutativeSemiGroup[v]Sourceinstance Filterable[Map[k]] with Order[k]Sourceinstance JoinLattice[Map[k, v]] with Order[k], Eq[v], JoinLattice[v]Sourceinstance LowerBound[Map[k, v]]Sourceinstance MeetLattice[Map[k, v]] with Order[k], Eq[v], MeetLattice[v]Sourceinstance PartialOrder[Map[k, v]] with Order[k], Eq[v]Sourceinstance Traversable[Map[k]]Sourceinstance UnorderedFoldable[Map[k]]Sourceinstance Witherable[Map[k]] with Order[k]SourceDefinitions
Updates m with k => f(v) if k => v is in m.
Otherwise, returns m.
Updates m with k => f(k, v) if k => v is in m. Otherwise, returns m.
@ParallelWhenPure def count(f: k -> (v -> Bool \ ef), m: Map[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.
Returns the difference of m1 and m2, i.e. m1 - m2.
That is, returns the map m1 with the keys removed that are in m2.
def differenceWith(f: v -> (v -> Option[v] \ ef), m1: Map[k, v], m2: Map[k, v]): Map[k, v] \ ef with Order[k]
SourceReturns the difference of m1 and m2, i.e. m1 - m2.
When a key k is in both m1 and m2, the associated values are passed to the merge function f.
If f returns None the mapping with k is thrown away (proper set difference).
If f returns Some(v) the mapping k => v is included in the result.
def differenceWithKey(f: k -> (v -> (v -> Option[v] \ ef)), m1: Map[k, v], m2: Map[k, v]): Map[k, v] \ ef with Order[k]
SourceReturns the difference of m1 and m2, i.e. m1 - m2.
When a key k is in both m1 and m2, k and the associated values are passed to the merge function f.
If f returns None the mapping with k is thrown away (proper set difference).
If f returns Some(v) the mapping k => v is included in the result.
def empty(): Map[k, v]
SourceReturns the empty map.
Map#{} is syntactic sugar for empty (Map#{} == empty()).
@ParallelWhenPure def exists(f: k -> (v -> Bool \ ef), m: Map[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 map.
Purity reflective: Runs in parallel when given a pure function f.
Returns the set of tuples (k, v) where v is a value in t and k => t.
Returns a map of all mappings k => v in m where v satisfies the predicate f.
Returns a map of all mappings k => v1 in m where applying the function f to v produces
a Some(v1). Elements that produce None are discarded.
def filterMapWithKey(f: k -> (a -> Option[b] \ ef), m: Map[k, a]): Map[k, b] \ ef with Order[k]
SourceReturns a map of all mappings k => v1 in m where applying the function f to (k, v) produces
Some(v1). Elements that produce None are discarded.
Returns a map of all mappings k => v in m where (k, v) satisfies the predicate f.
def find(f: k -> (v -> Bool \ ef), m: Map[k, v]): Option[(k, v)] \ ef
SourceAlias for findLeft.
def findLeft(f: k -> (v -> Bool \ ef), m: Map[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: Map[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: Map[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: Map[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).
Returns the result of mapping each value and combining the results.
Returns the result of mapping each key-value pair and combining the results.
def foldRight(f: v -> (b -> b \ ef), s: b, m: Map[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 foldRightWithKey(f: k -> (v -> (b -> b \ ef)), s: b, m: Map[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 foldWithKey(f: b -> (k -> (v -> b \ ef)), s: b, m: Map[k, v]): b \ ef
SourceAlias for foldLeftWithKey.
@ParallelWhenPure def forAll(f: k -> (v -> Bool \ ef), m: Map[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 map.
Purity reflective: Runs in parallel when given a pure function f.
def forEach(f: k -> (v -> Unit \ ef), m: Map[k, v]): Unit \ ef
SourceApplies f to every (key, value) of m.
def forEachWithIndex(f: Int32 -> (k -> (v -> Unit \ ef)), m: Map[k, v]): Unit \ ef
SourceApplies f to tuple (index, key, value) formed of the keys and values of
Map m and the index of the traversal.
Returns Some(v) if k => v is in m.
Otherwise returns None.
Returns v if k => v is in m.
Otherwise, returns d.
def insertWith(f: v -> (v -> v \ ef), k: k, v: v, m: Map[k, v]): Map[k, v] \ ef with Order[k]
SourceUpdates m with k => f(v, v1) if k => v1 is in m.
Otherwise, updates m with k => v.
def insertWithKey(f: k -> (v -> (v -> v \ ef)), k: k, v: v, m: Map[k, v]): Map[k, v] \ ef with Order[k]
SourceUpdates m with k => f(k, v, v1) if k => v1 is in m.
Otherwise, updates m with k => v.
Returns the left-biased intersection of m1 and m2.
That is, key collisions are resolved by taking the mapping from m1.
def intersectionWith(f: v1 -> (v2 -> v3 \ ef), m1: Map[k, v1], m2: Map[k, v2]): Map[k, v3] \ ef with Order[k]
SourceReturns the intersection of m1 and m2 where key collisions are resolved with the merge function f.
def intersectionWithKey(f: k -> (v1 -> (v2 -> v3 \ ef)), m1: Map[k, v1], m2: Map[k, v2]): Map[k, v3] \ ef with Order[k]
SourceReturns the intersection of m1 and m2 where key collisions are resolved with the merge function f, taking both the key and values.
Returns the inverse map of m.
That is, given a Map[k, v] returns a map Map[v, Set[k]]
where every value is mapped to its key(s) in the original map.
def isEmpty(m: Map[k, v]): Bool
SourceReturns true if and only if m is the empty map, i.e. Map(Nil).
Returns true if and only if all mappings in m1 occur in m2 and m1 != m2.
Returns true if and only if all mappings in m1 occur in m2.
def iterator(rc: Region[r], m: Map[k, v]): Iterator[(k, v), r, r] \ r
SourceReturns an iterator over all key-value pairs in m.
def iteratorKeys(rc: Region[r], m: Map[k, v]): Iterator[k, r, r] \ r
SourceReturns an iterator over keys in m.
def iteratorValues(rc: Region[r], m: Map[k, v]): Iterator[v, r, r] \ r
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: Map[k, v]): String \ ef
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.
@ParallelWhenPure def map(f: v1 -> v2 \ ef, m: Map[k, v1]): Map[k, v2] \ ef
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.
@ParallelWhenPure def mapWithKey(f: k -> (v1 -> v2 \ ef), m: Map[k, v1]): Map[k, v2] \ ef
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: Map[k, v]): Option[(k, v)]
SourceOptionally finds k => v where k is the largest key according to the Order instance of k.
Returns None if m is empty.
@ParallelWhenPure def maximumKeyBy(cmp: k -> (k -> Comparison \ ef), m: Map[k, v]): Option[(k, v)] \ ef
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 cmp.
@Parallel Optionally finds k => v where v is the largest value.
Returns None if m is empty.
@ParallelWhenPure def maximumValueBy(cmp: v -> (v -> Comparison \ ef), m: Map[k, v]): Option[(k, v)] \ ef
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 m contains the key k.
def minimumKey(m: Map[k, v]): Option[(k, v)]
SourceOptionally finds k => v where k is the smallest key according to the Order instance of k.
Returns None if m is empty.
@ParallelWhenPure def minimumKeyBy(cmp: k -> (k -> Comparison \ ef), m: Map[k, v]): Option[(k, v)] \ ef
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.
@ParallelWhenPure def minimumValueBy(cmp: v -> (v -> Comparison \ ef), m: Map[k, v]): Option[(k, v)] \ ef
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: Map[k, v]): Bool
SourceReturns true if and only if m is a non-empty map.
def rangeQuery(p: k -> Comparison \ ef, m: Map[k, v]): List[(k, v)] \ ef
SourceExtracts a range of key-value pairs from the 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: Map[k, v]): Unit \ ef1 + ef2
SourceApplies f to all key-value pairs (k, v) from the map m where p(k) returns EqualTo.
def reduceLeft(f: v -> (v -> v \ ef), m: Map[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 map.
def reduceLeftWithKey(f: k -> (v -> (k -> (v -> (k, v) \ ef))), m: Map[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 map.
def reduceRight(f: v -> (v -> v \ ef), m: Map[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 map.
def reduceRightWithKey(f: k -> (v -> (k -> (v -> (k, v) \ ef))), m: Map[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 map.
def sequence(m: Map[k, m[v]]): m[Map[k, v]] with Applicative[m]
SourceReturns the result of running all the actions in the map m.
Returns the singleton map where key k is mapped to value v.
Map#{k => v} is syntactic sugar for singleton (Map#{k => v} = singleton(k, v)).
def size(m: Map[k, v]): Int32
SourceReturns the number of keys in m.
@ParallelWhenPure def sumWith(f: k -> (v -> Int32 \ ef), m: Map[k, v]): Int32 \ ef
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(rc: Region[r], m: Map[k, v]): Array[(k, v), r] \ r
SourceReturns the map m as an array.
Returns the map m as a chain of key-value pairs.
def toList(m: Map[k, v]): List[(k, v)]
SourceReturns the map m as a list of key-value pairs.
Returns a MultiMap where key k is mapped to the singleton set containing v.
Returns the map m as a set of key-value pairs.
Returns a string representation of the given map m.
def toVector(m: Map[k, v]): Vector[(k, v)]
SourceReturns the map m as a vector.
def traverse(f: v1 -> m[v2] \ ef, m: Map[k, v1]): m[Map[k, v2]] \ ef with Applicative[m]
SourceReturns the result of applying the applicative mapping function f to all the values of the
map m.
def traverseWithKey(f: k -> (v1 -> m[v2] \ ef), m: Map[k, v1]): m[Map[k, v2]] \ ef with Applicative[m]
SourceReturns the result of applying the applicative mapping function f to all the key-value pairs
of the map m.
Build a map by applying f to the seed value st.
f should return Some(k,v,st1) to signal a new key-value pair k and v and a new seed value st1.
f should return None to signal the end of building the map.
Build a map by applying the function next to (). next is expected to encapsulate
a stateful resource such as a file handle that can be iterated.
next should return Some(k,v) to signal a new key-value pair k and v.
next should return None to signal the end of building the map.
Returns the left-biased union of m1 and m2.
That is, key collisions are resolved by taking the mapping from m1.
def unionWith(f: v -> (v -> v \ ef), m1: Map[k, v], m2: Map[k, v]): Map[k, v] \ ef with Order[k]
SourceReturns the union of m1 and m2 where key collisions are resolved with the merge function f.
def unionWithKey(f: k -> (v -> (v -> v \ ef)), m1: Map[k, v], m2: Map[k, v]): Map[k, v] \ ef with Order[k]
SourceReturns the union of m1 and m2 where key collisions are resolved with the merge function f, taking both the key and values.
Updates 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: Map[k, v]): Map[k, v] \ ef with Order[k]
SourceUpdates m with k => v1 if k => v is in m and f(k, v) = Some(v1). Otherwise, returns m.
def valuesOf(m: Map[k, v]): List[v]
SourceReturns the values of m.