MutMap

enum MutMap[k: Type, v: Type, r: Eff]Source
case MutMap(Region[r], Ref[Map[k, v], r])

The Mutable Map type.

Definitions

def adjust!(f: v -> v \ ef, k: k, m: MutMap[k, v, r]): Unit \ ef + r with Order[k] Source

Updates the mutable map m with k -> f(v) if k -> v is in m.

Otherwise leaves the map is unchanged.

def adjustWithKey!(f: k -> (v -> v \ ef), k: k, m: MutMap[k, v, r]): Unit \ ef + r with Order[k] Source

Updates the mutable map m with k -> f(k, v) if k -> v is in m.

Otherwise leaves the map is unchanged.

def clear!(m: MutMap[k, v, r]): Unit \ r Source

Removes all mappings from the mutable map m.

def copy(rc: Region[r1], m: MutMap[k, v, r]): MutMap[k, v, r1] \ r + r1 Source

Returns a shallow copy of the mutable map m.

def count(f: k -> (v -> Bool \ ef), m: MutMap[k, v, r]): Int32 \ ef + r Source

Returns the number of mappings in the mutable map m that satisfy the predicate function f.

Purity reflective: Runs in parallel when given a pure function f.

def exists(f: k -> (v -> Bool \ ef), m: MutMap[k, v, r]): Bool \ ef + r Source

Returns true if and only if at least one mapping in the mutable map m satisfies the predicate function f.

Returns false if m is the empty map.

def find(f: k -> (v -> Bool), m: MutMap[k, v, r]): Option[(k, v)] \ r Source

Alias for findLeft.

The function f must be pure.

def findLeft(f: k -> (v -> Bool), m: MutMap[k, v, r]): Option[(k, v)] \ r Source

Optionally returns the first mapping of the mutable map m that satisfies the predicate function f when searching from left to right.

The function f must be pure.

def findRight(f: k -> (v -> Bool), m: MutMap[k, v, r]): Option[(k, v)] \ r Source

Optionally returns the first mapping of the mutable map m that satisfies the predicate function f when searching from right to left.

The function f must be pure.

def foldLeft(f: b -> (v -> b \ ef), i: b, m: MutMap[k, v, r]): b \ ef + r Source

Applies f to a start value i and all values in the mutable map m going from left to right.

That is, the result is of the form: f(...f(f(i, v1), v2)..., vn).

def foldLeftWithKey(f: b -> (k -> (v -> b \ ef)), i: b, m: MutMap[k, v, r]): b \ ef + r Source

Applies f to a start value i and all key-value pairs in the mutable map m going from left to right.

That is, the result is of the form: f(...f(k2, f(k1, i, v1), v2)..., vn).

def foldRight(f: v -> (b -> b \ ef), s: b, m: MutMap[k, v, r]): b \ ef + r Source

Applies f to a start value s and all values in the mutable map 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: MutMap[k, v, r]): b \ ef + r Source

Applies f to a start value z and all values in the mutable map 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: MutMap[k, v, r]): b \ ef + r Source

Applies f to a start value s and all key-value pairs in the mutable map 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: MutMap[k, v, r]): b \ ef + r Source

Applies f to a start value z and all key-value pairs in the mutable map 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)), i: b, m: MutMap[k, v, r]): b \ ef + r Source

Alias for foldLeftWithKey.

def forAll(f: k -> (v -> Bool \ ef), m: MutMap[k, v, r]): Bool \ ef + r Source

Returns true if and only if all mappings in the mutable map m satisfy the predicate function f.

Returns true if m is the empty map.

def forEach(f: k -> (v -> Unit \ ef), m: MutMap[k, v, r]): Unit \ ef + r Source

Applies f to all the (key, value) pairs in the mutable map m.

def forEachWithIndex(f: Int32 -> (k -> (v -> Unit \ ef)), m: MutMap[k, v, r]): Unit \ ef + r Source

Apply the effectful function f to all the (key, value) pairs in the mutable map m along with that element's index.

def get(k: k, m: MutMap[k, v, r]): Option[v] \ r with Order[k] Source

Returns Some(v) if k -> v is in the mutable map m.

Otherwise returns None.

def getOrElsePut!(k: k, d: v, m: MutMap[k, v, r]): v \ r with Order[k] Source

Returns v if k -> v is in the mutable map m.

Otherwise updates the mutable map m with a new mapping k -> d and returns d.

def getWithDefault(k: k, d: v, m: MutMap[k, v, r]): v \ r with Order[k] Source

Returns v if k -> v is in the mutable map m.

Otherwise returns d.

def isEmpty(m: MutMap[k, v, r]): Bool \ r Source

Returns true if and only if m is the empty map.

def isProperSubmapOf(m1: MutMap[k, v, r1], m2: MutMap[k, v, r2]): Bool \ r1 + r2 with Order[k], Eq[v] Source

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

def isSubmapOf(m1: MutMap[k, v, r1], m2: MutMap[k, v, r2]): Bool \ r1 + r2 with Order[k], Eq[v] Source

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

def iterator(rc: Region[r1], m: MutMap[k, v, r2]): Iterator[(k, v), r1 + r2, r1] \ r1 + r2 Source

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

def iteratorKeys(rc: Region[r1], m: MutMap[k, v, r2]): Iterator[k, r1 + r2, r1] \ r1 + r2 Source

Returns an iterator over keys in m.

def iteratorValues(rc: Region[r1], m: MutMap[k, v, r2]): Iterator[v, r1 + r2, r1] \ r1 + r2 Source

Returns an iterator over values in m.

def joinKeys(sep: String, m: MutMap[k, v, r]): String \ r 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(sep: String, m: MutMap[k, v, r]): String \ r 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(f: k -> (v -> String \ ef), sep: String, m: MutMap[k, v, r]): String \ ef + r 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(m: MutMap[k, v, r]): Set[k] \ r with Order[k] Source

Returns the keys of the mutable map m.

def map(rc1: Region[r1], f: v1 -> v2 \ ef, m: MutMap[k, v1, r]): MutMap[k, v2, r1] \ ef + r + r1 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.

def mapWithKey(rc: Region[r1], f: k -> (v1 -> v2 \ ef), m: MutMap[k, v1, r]): MutMap[k, v2, r1] \ ef + r + r1 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(m: MutMap[k, v, r]): Option[(k, v)] \ r Source

Optionally finds k => v where k is the largest key according to the Order instance of k.

Returns None if m is empty.

def maximumKeyBy(cmp: k -> (k -> Comparison \ ef), m: MutMap[k, v, r]): Option[(k, v)] \ ef + r 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 f.

@Parallel
def maximumValue(m: MutMap[k, v, r]): Option[(k, v)] \ r with Order[v] Source

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

Returns None if m is empty.

def maximumValueBy(cmp: v -> (v -> Comparison \ ef), m: MutMap[k, v, r]): Option[(k, v)] \ ef + r 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(k: k, m: MutMap[k, v, r]): Bool \ r with Order[k] Source

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

def merge!(m1: MutMap[k, v, r1], m2: MutMap[k, v, r2]): Unit \ r1 + r2 with Order[k] Source

Merges the mutable map m1 into the mutable map m2 in a left-biased manner.

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

def mergeWith!(f: v -> (v -> v \ ef), m1: MutMap[k, v, r1], m2: MutMap[k, v, r2]): Unit \ ef + r1 + r2 with Order[k] Source

Merges the mutable map m1 into the mutable map m2 where key collisions are resolved with the merge function f.

def mergeWithKey!(f: k -> (v -> (v -> v \ ef)), m1: MutMap[k, v, r1], m2: MutMap[k, v, r2]): Unit \ ef + r1 + r2 with Order[k] Source

Merges the mutable map m1 into the mutable map m2 where key collisions are resolved with the merge function f, taking both the key and values.

def minimumKey(m: MutMap[k, v, r]): Option[(k, v)] \ r Source

Optionally finds k -> v where k is the smallest key according to the Order instance of k.

Returns None if m is empty.

def minimumKeyBy(cmp: k -> (k -> Comparison \ ef), m: MutMap[k, v, r]): Option[(k, v)] \ ef + r 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(m: MutMap[k, v, r]): Option[(k, v)] \ r with Order[v] Source

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

Returns None if m is empty.

def minimumValueBy(cmp: v -> (v -> Comparison \ ef), m: MutMap[k, v, r]): Option[(k, v)] \ ef + r 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 new(rc: Region[r]): MutMap[k, v, r] \ r Source

Returns a fresh empty mutable map.

def put!(k: k, v: v, m: MutMap[k, v, r]): Unit \ r with Order[k] Source

Updates the mutable map m with the binding k -> v. Replaces any existing binding.

def putWith!(f: v -> (v -> v \ ef), k: k, v: v, m: MutMap[k, v, r]): Unit \ ef + r with Order[k] Source

Updates the mutable map m with the binding k -> f(v, v1) if k -> v1 is in m.

Otherwise updates the mutable map m with the binding k -> v.

def query(p: k -> Comparison \ ef, m: MutMap[k, v, r]): List[(k, v)] \ ef + r Source

Extracts a range of key-value pairs from the mutable map m.

That is, the result is a list of all pairs (k, v) where p(k) returns Equal.

def queryWith(p: k -> Comparison \ ef1, f: k -> (v -> Unit \ ef2), m: MutMap[k, v, r]): Unit \ ef1 + ef2 + r Source

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

def reduceLeft(f: v -> (v -> v \ ef), m: MutMap[k, v, r]): Option[v] \ ef + r Source

Applies f to all values in the mutable map 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: MutMap[k, v, r]): Option[(k, v)] \ ef + r Source

Applies f to all mappings in the mutable map 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: MutMap[k, v, r]): Option[v] \ ef + r Source

Applies f to all values in the mutable map 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: MutMap[k, v, r]): Option[(k, v)] \ ef + r Source

Applies f to all mappings in the mutable map 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 refine!(f: v -> Bool, m: MutMap[k, v, r]): Unit \ r with Order[k] Source

Removes all mappings k -> v from the mutable map m where v does not satisfy the predicate function f.

The function f must be pure.

def refineWithKey!(f: k -> (v -> Bool), m: MutMap[k, v, r]): Unit \ r with Order[k] Source

Removes all mappings k -> v from the mutable map m where (k, v) does not satisfy the predicate function f.

The function f must be pure.

def remove!(k: k, m: MutMap[k, v, r]): Unit \ r with Order[k] Source

Removes the mapping k from the mutable map m.

Leaves the map unchanged if the mutable map m does not contain any mapping for k.

def sameElements(a: MutMap[k, v, r1], b: MutMap[k, v, r2]): Bool \ r1 + r2 with Order[k], Eq[v] Source

Returns true if MutMaps a and b have the same elements, i.e. are structurally equal.

def singleton(rc: Region[r], k: k, v: v): MutMap[k, v, r] \ r with Order[k] Source

Returns the singleton map where key k is mapped to value v.

def size(m: MutMap[k, v, r]): Int32 \ r Source

Returns the size of the mutable map m.

def sumKeys(m: MutMap[Int32, v, r]): Int32 \ r Source

Returns the sum of all keys in the map m.

def sumValues(m: MutMap[k, Int32, r]): Int32 \ r Source

Returns the sum of all values in the map m.

def sumWith(f: k -> (v -> Int32 \ ef), m: MutMap[k, v, r]): Int32 \ ef + r 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 toList(m: MutMap[k, v, r]): List[(k, v)] \ r Source

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

def toMap(m: MutMap[k, v, r]): Map[k, v] \ r Source

Returns the mutable map m as an immutable map.

def toMutDeque(rc1: Region[r1], m: MutMap[k, v, r2]): MutDeque[(k, v), r1] \ r2 + r1 Source

Returns m as a MutDeque.

def toSet(m: MutMap[k, v, r]): Set[(k, v)] \ r with Order[k], Order[v] Source

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

def toString(m: MutMap[k, v, r]): String \ r with ToString[k], ToString[v] Source

Returns a string representation of the given MutMap m.

def transform!(f: v -> v \ ef, m: MutMap[k, v, r]): Unit \ ef + r with Order[k] Source

Applies the function f to every value in the mutable map m.

def transformWithKey!(f: k -> (v -> v \ ef), m: MutMap[k, v, r]): Unit \ ef + r with Order[k] Source

Applies the function f to every value in the mutable map m.

def valuesOf(m: MutMap[k, v, r]): List[v] \ r Source

Returns the values of the mutable map m.