Map

0.40.0

Definitions

def adjust [vefk] ( f : v -> v \ ef k : k m : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

Updates m with k => f(v) if k => v is in m.

Otherwise, returns m.

def adjustWithKey [kvef] ( f : k -> (v -> v \ ef) k : k m : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

Updates m with k => f(k, v) if k => v is in m. Otherwise, returns m.

@ParallelWhenPure

def count [kvef] ( f : k -> (v -> Bool \ ef) m : Map[k, v] ) : Int32 \ ef

Source

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 : Map[k, v] m2 : Map[k, v] ) : Map[k, v] \ Pure with Order[k]

Source

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 [vefk] ( f : v -> (v -> Option[v] \ ef) m1 : Map[k, v] m2 : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

Returns 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 [kvef] ( f : k -> (v -> (v -> Option[v] \ ef)) m1 : Map[k, v] m2 : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

Returns 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 [kv] : Map[k, v] \ Pure

Source

Returns the empty map.

Map#{} is syntactic sugar for empty (Map#{} = empty()).

@ParallelWhenPure

def exists [kvef] ( f : k -> (v -> Bool \ ef) m : Map[k, v] ) : Bool \ ef

Source

Returns 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.

def explode [ktv] ( m : Map[k, t[v]] ) : Set[(k, v)] \ Pure with Foldable[t] Order[k] Order[v]

Source

Returns the set of tuples (k, v) where v is a value in t and k => t.

def filter [vefk] ( f : v -> Bool \ ef m : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

Returns a map of all mappings k => v in m where v satisfies the predicate f.

def filterMap [aefbk] ( f : a -> Option[b] \ ef m : Map[k, a] ) : Map[k, b] \ ef with Order[k]

Source

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 [kaefb] ( f : k -> (a -> Option[b] \ ef) m : Map[k, a] ) : Map[k, b] \ ef with Order[k]

Source

Returns 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.

def filterWithKey [kvef] ( f : k -> (v -> Bool \ ef) m : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

Returns a map of all mappings k => v in m where (k, v) satisfies the predicate f.

def find [kvef] ( f : k -> (v -> Bool \ ef) m : Map[k, v] ) : Option[(k, v)] \ ef

Source

Alias for findLeft.

def findLeft [kvef] ( f : k -> (v -> Bool \ ef) m : Map[k, v] ) : Option[(k, v)] \ ef

Source

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 : Map[k, v] ) : Option[(k, v)] \ ef

Source

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 : Map[k, v] ) : b \ ef

Source

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 : Map[k, v] ) : b \ ef

Source

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 : Map[k, v] ) : b \ ef with Monoid[b]

Source

Returns the result of mapping each value and combining the results.

def foldMapWithKey [kvefb] ( f : k -> (v -> b \ ef) m : Map[k, v] ) : b \ ef with Monoid[b]

Source

Returns the result of mapping each key-value pair and combining the results.

def foldRight [vbefk] ( f : v -> (b -> b \ ef) s : b m : Map[k, v] ) : b \ ef

Source

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 : Map[k, v] ) : b \ ef

Source

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 : Map[k, v] ) : b \ ef

Source

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 : Map[k, v] ) : b \ ef

Source

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 : Map[k, v] ) : b \ ef

Source

Alias for foldLeftWithKey.

@ParallelWhenPure

def forAll [kvef] ( f : k -> (v -> Bool \ ef) m : Map[k, v] ) : Bool \ ef

Source

Returns 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 [kvef] ( f : k -> (v -> Unit \ ef) m : Map[k, v] ) : Unit \ ef

Source

Applies f to every (key, value) of m.

def forEachWithIndex [kvef] ( f : Int32 -> (k -> (v -> Unit \ ef)) m : Map[k, v] ) : Unit \ ef

Source

Applies f to tuple (index, key, value) formed of the keys and values of Map m and the index of the traversal.

def get [kv] ( k : k m : Map[k, v] ) : Option[v] \ Pure with Order[k]

Source

Returns Some(v) if k => v is in m.

Otherwise returns None.

def getWithDefault [kv] ( k : k d : v m : Map[k, v] ) : v \ Pure with Order[k]

Source

Returns v if k => v is in m.

Otherwise, returns d.

def insert [kv] ( k : k v : v m : Map[k, v] ) : Map[k, v] \ Pure with Order[k]

Source

Updates m with k => v.

def insertWith [vefk] ( f : v -> (v -> v \ ef) k : k v : v m : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

Updates m with k => f(v, v1) if k => v1 is in m.

Otherwise, updates m with k => v.

def insertWithKey [kvef] ( f : k -> (v -> (v -> v \ ef)) k : k v : v m : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

Updates m with k => f(k, v, v1) if k => v1 is in m.

Otherwise, updates m with k => v.

def intersection [kv] ( m1 : Map[k, v] m2 : Map[k, v] ) : Map[k, v] \ Pure with Order[k]

Source

Returns the left-biased intersection of m1 and m2.

That is, key collisions are resolved by taking the mapping from m1.

def intersectionWith [v1v2efv3k] ( f : v1 -> (v2 -> v3 \ ef) m1 : Map[k, v1] m2 : Map[k, v2] ) : Map[k, v3] \ ef with Order[k]

Source

Returns the intersection of m1 and m2 where key collisions are resolved with the merge function f.

def intersectionWithKey [kv1v2efv3] ( f : k -> (v1 -> (v2 -> v3 \ ef)) m1 : Map[k, v1] m2 : Map[k, v2] ) : Map[k, v3] \ ef with Order[k]

Source

Returns the intersection of m1 and m2 where key collisions are resolved with the merge function f, taking both the key and values.

def invert [kv] ( m : Map[k, v] ) : Map[v, Set[k]] \ Pure with Order[k] Order[v]

Source

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 [kv] ( m : Map[k, v] ) : Bool \ Pure

Source

Returns true if and only if m is the empty map, i.e. Map(Nil).

def isProperSubmapOf [kv] ( m1 : Map[k, v] m2 : Map[k, v] ) : Bool \ Pure with Order[k] Eq[v]

Source

Returns true if and only if all mappings in m1 occur in m2 and m1 != m2.

def isSubmapOf [kv] ( m1 : Map[k, v] m2 : Map[k, v] ) : Bool \ Pure with Order[k] Eq[v]

Source

Returns true if and only if all mappings in m1 occur in m2.

def iterator [rkv] ( rc : Region[r] m : Map[k, v] ) : Iterator[(k, v), r, r] \ r

Source

Returns an iterator over all key-value pairs in m.

def iteratorKeys [rkv] ( rc : Region[r] m : Map[k, v] ) : Iterator[k, r, r] \ r

Source

Returns an iterator over keys in m.

def iteratorValues [rkv] ( rc : Region[r] m : Map[k, v] ) : Iterator[v, r, r] \ r

Source

Returns an iterator over values in m.

def joinKeys [kv] ( sep : String m : Map[k, v] ) : String \ Pure with ToString[k]

Source

Returns the concatenation of the string representation of each key k in m with sep inserted between each element.

def joinValues [kv] ( sep : String m : Map[k, v] ) : String \ Pure with ToString[v]

Source

Returns the concatenation of the string representation of each value v in m with sep inserted between each element.

def joinWith [kvef] ( f : k -> (v -> String \ ef) sep : String m : Map[k, v] ) : String \ ef

Source

Returns the concatenation of the string representation of each key-value pair k => v in m according to f with sep inserted between each element.

def keysOf [kv] ( m : Map[k, v] ) : Set[k] \ Pure with Order[k]

Source

Returns the keys of m.

@ParallelWhenPure

def map [v1efv2k] ( f : v1 -> v2 \ ef m : Map[k, v1] ) : Map[k, v2] \ ef

Source

Returns 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 [kv1efv2] ( f : k -> (v1 -> v2 \ ef) m : Map[k, v1] ) : Map[k, v2] \ ef

Source

Returns 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 [kv] ( m : Map[k, v] ) : Option[(k, v)] \ Pure

Source

Optionally 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 [kefv] ( cmp : k -> (k -> Comparison \ ef) m : Map[k, v] ) : Option[(k, v)] \ ef

Source

Optionally 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

def maximumValue [kv] ( m : Map[k, v] ) : Option[(k, v)] \ Pure with Order[v]

Source

Optionally finds k => v where v is the largest value.

Returns None if m is empty.

@ParallelWhenPure

def maximumValueBy [vefk] ( cmp : v -> (v -> Comparison \ ef) m : Map[k, v] ) : Option[(k, v)] \ ef

Source

Optionally 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.

def memberOf [kv] ( k : k m : Map[k, v] ) : Bool \ Pure with Order[k]

Source

Returns true if and only if m contains the key k.

def minimumKey [kv] ( m : Map[k, v] ) : Option[(k, v)] \ Pure

Source

Optionally 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 [kefv] ( cmp : k -> (k -> Comparison \ ef) m : Map[k, v] ) : Option[(k, v)] \ ef

Source

Optionally 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

def minimumValue [kv] ( m : Map[k, v] ) : Option[(k, v)] \ Pure with Order[v]

Source

Optionally finds k => v where v is the smallest value.

Returns None if m is empty.

@ParallelWhenPure

def minimumValueBy [vefk] ( cmp : v -> (v -> Comparison \ ef) m : Map[k, v] ) : Option[(k, v)] \ ef

Source

Optionally 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 query [kefv] ( p : k -> Comparison \ ef m : Map[k, v] ) : List[(k, v)] \ ef

Source

Extracts 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 queryWith [kef1vef2] ( p : k -> Comparison \ ef1 f : k -> (v -> Unit \ ef2) m : Map[k, v] ) : Unit \ ef1 + ef2

Source

Applies f to all key-value pairs (k, v) from the map m where p(k) returns EqualTo.

def reduceLeft [vefk] ( f : v -> (v -> v \ ef) m : Map[k, v] ) : Option[v] \ ef

Source

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 map.

def reduceLeftWithKey [kvef] ( f : k -> (v -> (k -> (v -> (k, v) \ ef))) m : Map[k, v] ) : Option[(k, v)] \ ef

Source

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 map.

def reduceRight [vefk] ( f : v -> (v -> v \ ef) m : Map[k, v] ) : Option[v] \ ef

Source

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 map.

def reduceRightWithKey [kvef] ( f : k -> (v -> (k -> (v -> (k, v) \ ef))) m : Map[k, v] ) : Option[(k, v)] \ ef

Source

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 map.

def remove [kv] ( k : k m : Map[k, v] ) : Map[k, v] \ Pure with Order[k]

Source

Removes the mapping k from the map m.

def sequence [kmv] ( m : Map[k, m[v]] ) : m[Map[k, v]] \ Pure with Applicative[m]

Source

Returns the result of running all the actions in the map m.

def singleton [kv] ( k : k v : v ) : Map[k, v] \ Pure with Order[k]

Source

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 [kv] ( m : Map[k, v] ) : Int32 \ Pure

Source

Returns the size of m.

def sumKeys [v] ( m : Map[Int32, v] ) : Int32 \ Pure

Source

Returns the sum of all keys in the map m.

def sumValues [k] ( m : Map[k, Int32] ) : Int32 \ Pure

Source

Returns the sum of all values in the map m.

@ParallelWhenPure

def sumWith [kvef] ( f : k -> (v -> Int32 \ ef) m : Map[k, v] ) : Int32 \ ef

Source

Returns 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 toChain [ab] ( m : Map[a, b] ) : Chain[(a, b)] \ Pure with Order[a]

Source

Returns the map m as a chain of key-value pairs.

def toDelayList [kv] ( m : Map[k, v] ) : DelayList[(k, v)] \ Pure

Source

Returns the map m as a DelayList of key-value pairs.

def toDelayMap [kv] ( m : Map[k, v] ) : DelayMap[k, v] \ Pure

Source

Returns m as a DelayMap.

def toList [kv] ( m : Map[k, v] ) : List[(k, v)] \ Pure

Source

Returns the map m as a list of key-value pairs.

def toMultiMap [kv] ( m : Map[k, v] ) : MultiMap[k, v] \ Pure with Order[k] Order[v]

Source

Returns a MultiMap where key k is mapped to the singleton set containing v.

def toMutDeque [rkv] ( rc : Region[r] m : Map[k, v] ) : MutDeque[(k, v), r] \ r

Source

Returns m as a MutDeque.

def toMutMap [rkv] ( rc : Region[r] m : Map[k, v] ) : MutMap[k, v, r] \ r

Source

Returns m as a mutable map.

def toSet [kv] ( m : Map[k, v] ) : Set[(k, v)] \ Pure with Order[k] Order[v]

Source

Returns the map m as a set of key-value pairs.

def toString [kv] ( m : Map[k, v] ) : String \ Pure with ToString[k] ToString[v]

Source

Returns a string representation of the given map m.

def traverse [v1efmv2k] ( f : v1 -> m[v2] \ ef m : Map[k, v1] ) : m[Map[k, v2]] \ ef with Applicative[m]

Source

Returns the result of applying the applicative mapping function f to all the values of the map m.

def traverseWithKey [kv1efmv2] ( f : k -> (v1 -> m[v2] \ ef) m : Map[k, v1] ) : m[Map[k, v2]] \ ef with Applicative[m]

Source

Returns the result of applying the applicative mapping function f to all the key-value pairs of the map m.

def unfold [sefkv] ( f : s -> Option[(k, v, s)] \ ef st : s ) : Map[k, v] \ ef with Order[k]

Source

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.

def unfoldWithIter [efkv] ( next : Unit -> Option[(k, v)] \ ef ) : Map[k, v] \ ef with Order[k]

Source

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.

def union [kv] ( m1 : Map[k, v] m2 : Map[k, v] ) : Map[k, v] \ Pure with Order[k]

Source

Returns the left-biased union of m1 and m2.

That is, key collisions are resolved by taking the mapping from m1.

def unionWith [vefk] ( f : v -> (v -> v \ ef) m1 : Map[k, v] m2 : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

Returns the union of m1 and m2 where key collisions are resolved with the merge function f.

def unionWithKey [kvef] ( f : k -> (v -> (v -> v \ ef)) m1 : Map[k, v] m2 : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

Returns the union of m1 and m2 where key collisions are resolved with the merge function f, taking both the key and values.

def update [vefk] ( f : v -> Option[v] \ ef k : k m : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

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 : Map[k, v] ) : Map[k, v] \ ef with Order[k]

Source

Updates m with k => v1 if k => v is in m and f(k, v) = Some(v1). Otherwise, returns m.

def valuesOf [kv] ( m : Map[k, v] ) : List[v] \ Pure

Source

Returns the values of m.