flix

0.54.0

DelayMap

enum DelayMap[k: Type, v: Type] with SendableSource
case DMap(RedBlackTree[k, Lazy[v]])

Instances

instance Eq[DelayMap[k, v]] with Eq[k], Eq[v]Source
instance Foldable[DelayMap[k]]Source
instance Functor[DelayMap[k]]Source
instance Indexable[DelayMap[k, v]] with Order[k]Source
instance Iterable[DelayMap[k, v]]Source
instance Order[DelayMap[k, v]] with Order[k], Order[v]Source
instance Sendable[DelayMap[k, v]] with Sendable[k], Sendable[v]Source
instance ToString[DelayMap[k, v]] with ToString[k], ToString[v]Source

Definitions

@Experimental @LazyWhenPure
def adjust(f: v -> v \ ef, k: k, m: DelayMap[k, v]): DelayMap[k, v] \ ef with Order[k] Source

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

Purity reflective: Applies f lazily if f is pure.

@Experimental @LazyWhenPure
def adjustWithKey(f: k -> (v -> v \ ef), k: k, m: DelayMap[k, v]): DelayMap[k, v] \ ef with Order[k] Source

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

Purity reflective: Applies f lazily if f is pure.

@Experimental @ParallelWhenPure
def count(f: k -> (v -> Bool \ ef), m: DelayMap[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.

@Experimental
def empty(): DelayMap[k, v] Source

Returns the empty map.

@Experimental
def filter(f: v -> Bool \ ef, m: DelayMap[k, v]): DelayMap[k, v] \ ef with Order[k] Source

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

@Experimental
def filterWithKey(f: k -> (v -> Bool \ ef), m: DelayMap[k, v]): DelayMap[k, v] \ ef with Order[k] Source

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

@Experimental
def foldLeft(f: b -> (v -> b \ ef), s: b, m: DelayMap[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).

@Experimental
def foldLeftWithKey(f: b -> (k -> (v -> b \ ef)), s: b, m: DelayMap[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).

@Experimental
def foldRight(f: v -> (b -> b \ ef), s: b, m: DelayMap[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))).

@Experimental
def foldRightWithCont(f: v -> ((Unit -> b \ ef) -> b \ ef), z: b, m: DelayMap[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.

@Experimental
def foldRightWithKey(f: k -> (v -> (b -> b \ ef)), s: b, m: DelayMap[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))).

@Experimental
def foldRightWithKeyCont(f: k -> (v -> ((Unit -> b \ ef) -> b \ ef)), s: b, m: DelayMap[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))). A foldRightWithKeyCont allows early termination by not calling the continuation.

@Experimental
def forEach(f: k -> (v -> Unit \ ef), m: DelayMap[k, v]): Unit \ ef Source

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

@Experimental
def forEachWithIndex(f: Int32 -> (k -> (v -> Unit \ ef)), m: DelayMap[k, v]): Unit \ ef Source

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

@Experimental @Parallel
def forceAll(m: DelayMap[k, v]): Unit Source

Forces all values in m.

@Experimental
def get(k: k, m: DelayMap[k, v]): Option[v] with Order[k] Source

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

Otherwise returns None.

@Experimental
def getWithDefault(k: k, d: v, m: DelayMap[k, v]): v with Order[k] Source

Returns v if k => v is in m.

Otherwise, returns d.

@Experimental
def insert(k: k, v: v, m: DelayMap[k, v]): DelayMap[k, v] with Order[k] Source

Returns m with k => v.

@Experimental @LazyWhenPure
def insertWith(f: v -> (v -> v \ ef), k: k, v: v, m: DelayMap[k, v]): DelayMap[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.

@Experimental @LazyWhenPure
def insertWithKey(f: k -> (v -> (v -> v \ ef)), k: k, v: v, m: DelayMap[k, v]): DelayMap[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.

@Experimental
def isEmpty(m: DelayMap[k, v]): Bool Source

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

@Experimental
def iterator(rc: Region[r], m: DelayMap[a, b]): Iterator[(a, b), r, r] \ r Source

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

@Experimental
def joinKeys(sep: String, m: DelayMap[k, v]): String with ToString[k] Source

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

@Experimental
def joinValues(sep: String, m: DelayMap[k, v]): String with ToString[v] Source

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

@Experimental
def joinWith(f: k -> (v -> String \ ef), sep: String, m: DelayMap[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.

@Experimental
def keysOf(m: DelayMap[k, v]): Set[k] with Order[k] Source

Returns the keys of m.

@Experimental @ParallelWhenPure @LazyWhenPure
def map(f: v1 -> v2 \ ef, m: DelayMap[k, v1]): DelayMap[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. - Applies f lazily if f is pure.

@Experimental @ParallelWhenPure @LazyWhenPure
def mapWithKey(f: k -> (v1 -> v2 \ ef), m: DelayMap[k, v1]): DelayMap[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. - Applies f lazily if f is pure.

@Experimental
def maximumKey(m: DelayMap[k, v]): Option[(k, v)] Source

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

Returns None if m is empty.

@Experimental @ParallelWhenPure
def maximumKeyBy(cmp: k -> (k -> Comparison \ ef), m: DelayMap[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.

@Experimental @Parallel
def maximumValue(m: DelayMap[k, v]): Option[(k, v)] with Order[v] Source

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

Returns None if m is empty.

@Experimental @ParallelWhenPure
def maximumValueBy(cmp: v -> (v -> Comparison \ ef), m: DelayMap[k, v]): Option[(k, v)] \ ef Source

Optionally finds k => v where k 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.

@Experimental
def memberOf(k: k, m: DelayMap[k, v]): Bool with Order[k] Source

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

@Experimental
def minimumKey(m: DelayMap[k, v]): Option[(k, v)] Source

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

Returns None if m is empty.

@Experimental @ParallelWhenPure
def minimumKeyBy(cmp: k -> (k -> Comparison \ ef), m: DelayMap[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.

@Experimental @Parallel
def minimumValue(m: DelayMap[k, v]): Option[(k, v)] with Order[v] Source

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

Returns None if m is empty.

@Experimental @ParallelWhenPure
def minimumValueBy(cmp: v -> (v -> Comparison \ ef), m: DelayMap[k, v]): Option[(k, v)] \ ef Source

Optionally finds k => v where k 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.

@Experimental
def nonEmpty(m: DelayMap[k, v]): Bool Source

Returns true if and only if m is a non-empty map.

@Experimental
def reduceLeft(f: v -> (v -> v \ ef), m: DelayMap[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.

@Experimental
def reduceLeftWithKey(f: k -> (v -> (k -> (v -> (k, v) \ ef))), m: DelayMap[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.

@Experimental
def reduceRight(f: v -> (v -> v \ ef), m: DelayMap[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 DelayMap.

@Experimental
def reduceRightWithKey(f: k -> (v -> (k -> (v -> (k, v) \ ef))), m: DelayMap[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 DelayMap.

@Experimental
def remove(k: k, m: DelayMap[k, v]): DelayMap[k, v] with Order[k] Source

Removes the mapping k from the map m.

@Experimental
def singleton(k: k, v: v): DelayMap[k, v] with Order[k] Source

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

@Experimental
def size(m: DelayMap[k, v]): Int32 Source

Returns the number of keys in m.

@Experimental @Parallel
def sumKeys(m: DelayMap[Int32, v]): Int32 Source

Returns the sum of all values in m.

@Experimental @Parallel
def sumValues(m: DelayMap[k, Int32]): Int32 Source

Returns the sum of all values in m.

@Experimental @ParallelWhenPure
def sumWith(f: k -> (v -> Int32 \ ef), m: DelayMap[k, v]): Int32 \ ef Source

Returns the sum of all key-value pairs k => v in m according to the function f.

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

@Experimental
def toDelayList(m: DelayMap[k, v]): DelayList[(k, v)] Source

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

@Experimental
def toList(m: DelayMap[k, v]): List[(k, v)] Source

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

@Experimental @Parallel
def toMap(m: DelayMap[k, v]): Map[k, v] Source

Returns m as a Map, i.e. every value is forced.

@Experimental
def toMutDeque(rc: Region[r], m: DelayMap[k, v]): MutDeque[(k, v), r] \ r Source

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

@Experimental @Parallel
def toMutMap(rc: Region[r], m: DelayMap[k, v]): MutMap[k, v, r] \ r Source

Returns m as a mutable map.

@Experimental
def toSet(m: DelayMap[k, v]): Set[(k, v)] with Order[k], Order[v] Source

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

@Experimental
def toString(m: DelayMap[k, v]): String with ToString[k], ToString[v] Source

Returns a string representation of the given DelayMap m.

@Experimental @Lazy
def union(m1: DelayMap[k, v], m2: DelayMap[k, v]): DelayMap[k, v] 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.

@Experimental @LazyWhenPure
def unionWith(f: v -> (v -> v \ ef), m1: DelayMap[k, v], m2: DelayMap[k, v]): DelayMap[k, v] \ ef with Order[k] Source

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

Purity reflective: Applies f lazily if f is pure.

@Experimental @LazyWhenPure
def unionWithKey(f: k -> (v -> (v -> v \ ef)), m1: DelayMap[k, v], m2: DelayMap[k, v]): DelayMap[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.

Purity reflective: Applies f lazily if f is pure.

@Experimental @LazyWhenPure
def update(f: v -> Option[v] \ ef, k: k, m: DelayMap[k, v]): DelayMap[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.

Purity reflective: Applies f lazily if f is pure.

@Experimental @LazyWhenPure
def updateWithKey(f: k -> (v -> Option[v] \ ef), k: k, m: DelayMap[k, v]): DelayMap[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.

Purity reflective: Applies f lazily if f is pure.

@Experimental
def valuesOf(m: DelayMap[k, v]): List[v] Source

Returns the values of m.