flix

0.65.0

MutHashMap

Definitions

def adjust(f: v -> v \ ef, k: k, m: MutHashMap[k, v, r]): Unit \ ef + r with Eq[k], Hash[k] Source

Updates the value at key k using function f if the key exists.

Does nothing if the key does not exist.

def adjustWithKey(f: k -> (v -> v \ ef), k: k, m: MutHashMap[k, v, r]): Unit \ ef + r with Eq[k], Hash[k] Source

Updates the value at key k using function f with key if the key exists.

Does nothing if the key does not exist.

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

Removes all entries from m.

def copy(rc: Region[r2], m: MutHashMap[k, v, r1]): MutHashMap[k, v, r2] \ r1 + r2 with Eq[k], Hash[k] Source

Returns a shallow copy of m in region rc2.

All key-value pairs are copied in insertion order.

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

Returns the number of key-value pairs in m that satisfy the predicate f.

def empty(rc: Region[r]): MutHashMap[k, v, r] \ r Source

Returns an empty MutHashMap.

def emptyWithCapacity(rc: Region[r], capacity: Int32): MutHashMap[k, v, r] \ r Source

Returns an empty mutable hash map with the given capacity.

The capacity is rounded up to the minimum capacity.

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

Returns true if at least one key-value pair in m satisfies the predicate f.

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

Returns the first key-value pair in m (in insertion order) that satisfies the predicate f.

Alias for findLeft.

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

Returns the first key-value pair in m (from left, in insertion order) that satisfies the predicate f.

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

Returns the first key-value pair in m (from right, in reverse insertion order) that satisfies the predicate f.

def first(m: MutHashMap[k, v, r]): Option[(k, v)] \ r Source

Returns the first key-value pair that was inserted into the mutable map m.

Returns None if the map is empty.

def firstKey(m: MutHashMap[k, v, r]): Option[k] \ r Source

Returns the first key that was inserted into the mutable map m.

Returns None if the map is empty.

def firstValue(m: MutHashMap[k, v, r]): Option[v] \ r Source

Returns the first value that was inserted into the mutable map m.

Returns None if the map is empty.

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

Applies f to a start value s and all values in m going from left to right (insertion order).

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

Applies f to a start value s and all key-value pairs in m going from left to right (insertion order).

def foldMap(f: v -> b \ ef, m: MutHashMap[k, v, r]): b \ ef + r with Monoid[b] Source

Returns the result of mapping each value and combining the results using a monoid.

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

Applies f to a start value s and all values in m going from right to left (reverse insertion order).

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

Applies f to a start value s and all key-value pairs in m going from right to left (reverse insertion order).

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

Returns true if all key-value pairs in m satisfy the predicate f.

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

Applies f to each key-value pair in m in insertion order.

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

Applies f to each key-value pair in m along with its index in insertion order.

def fromList(rc: Region[r], l: List[(k, v)]): MutHashMap[k, v, r] \ r with Eq[k], Hash[k] Source

Returns a new mutable hash map containing all key-value pairs from list l. If the list contains duplicate keys, the last occurrence wins.

def fromMap(rc: Region[r], m: Map[k, v]): MutHashMap[k, v, r] \ r with Order[k], Hash[k] Source

Returns a new mutable hash map containing all key-value pairs from immutable map m.

def get(k: k, m: MutHashMap[k, v, r]): Option[v] \ r with Eq[k], Hash[k] Source

Returns Some(v) if key k exists in m, otherwise None.

def getOrElsePut(k: k, default: v, m: MutHashMap[k, v, r]): v \ r with Eq[k], Hash[k] Source

Returns the value associated with key k in m.

If k does not exist, inserts k with value default and returns default.

def getWithDefault(k: k, default: v, m: MutHashMap[k, v, r]): v \ r with Eq[k], Hash[k] Source

Returns the value associated with key k, or default if not found.

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

Returns true if m is empty.

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

Returns an iterator over key-value pairs in m in insertion order.

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

Returns an iterator over keys in m in insertion order.

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

Returns an iterator over values in m in insertion order.

def joinKeys(sep: String, m: MutHashMap[k, v, r]): String \ r with ToString[k] Source

Returns a string formed by joining all keys in m with sep.

def joinValues(sep: String, m: MutHashMap[k, v, r]): String \ r with ToString[v] Source

Returns a string formed by joining all values in m with sep.

def joinWith(f: k -> (v -> String \ ef), sep: String, m: MutHashMap[k, v, r]): String \ ef + r Source

Returns a string formed by applying f to each key-value pair and joining with sep.

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

Returns the set of all keys in m.

def last(m: MutHashMap[k, v, r]): Option[(k, v)] \ r Source

Returns the last key-value pair that was inserted into the mutable map m.

Returns None if the map is empty.

def lastKey(m: MutHashMap[k, v, r]): Option[k] \ r Source

Returns the last key that was inserted into the mutable map m.

Returns None if the map is empty.

def lastValue(m: MutHashMap[k, v, r]): Option[v] \ r Source

Returns the last value that was inserted into the mutable map m.

Returns None if the map is empty.

def map(rc: Region[r2], f: v1 -> v2 \ ef, m: MutHashMap[k, v1, r1]): MutHashMap[k, v2, r2] \ ef + r1 + r2 with Eq[k], Hash[k] Source

Returns a new mutable hash map with values transformed by function f.

Keys and insertion order are preserved.

def mapWithKey(rc: Region[r2], f: k -> (v1 -> v2 \ ef), m: MutHashMap[k, v1, r1]): MutHashMap[k, v2, r2] \ ef + r1 + r2 with Eq[k], Hash[k] Source

Returns a new mutable hash map with values transformed by function f with access to keys.

Keys and insertion order are preserved.

def memberOf(k: k, m: MutHashMap[k, v, r]): Bool \ r with Eq[k], Hash[k] Source

Returns true if key k exists in m.

def nonEmpty(m: MutHashMap[k, v, r]): Bool \ r Source

Returns true if m is non-empty.

def put(k: k, v: v, m: MutHashMap[k, v, r]): Unit \ r with Eq[k], Hash[k] Source

Inserts key k with value v into m.

If the key already exists, updates its value (does not change insertion order).

def putWith(f: v -> (v -> v \ ef), k: k, v: v, m: MutHashMap[k, v, r]): Unit \ ef + r with Eq[k], Hash[k] Source

Inserts key k with value v into m, using combiner function f if key exists.

If key exists with value oldV, updates to f(v, oldV).

Otherwise, inserts k => v.

def putWithKey(f: k -> (v -> (v -> v \ ef)), k: k, v: v, m: MutHashMap[k, v, r]): Unit \ ef + r with Eq[k], Hash[k] Source

Inserts key k with value v into m, using combiner function f with key if key exists.

If key exists with value oldV, updates to f(k, v, oldV).

Otherwise, inserts k => v.

def refine(f: v -> Bool \ ef, m: MutHashMap[k, v, r]): Unit \ ef + r with Eq[k], Hash[k] Source

Removes all entries from m where f(value) returns false.

def refineWithKey(f: k -> (v -> Bool \ ef), m: MutHashMap[k, v, r]): Unit \ ef + r with Eq[k], Hash[k] Source

Removes all entries from m where f(key, value) returns false.

def remove(k: k, m: MutHashMap[k, v, r]): Unit \ r with Eq[k], Hash[k] Source

Removes key k from m.

def singleton(rc: Region[r], k: k, v: v): MutHashMap[k, v, r] \ r with Eq[k], Hash[k] Source

Returns a mutable hash map with a single key-value pair k => v.

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

Returns the number of entries in m.

def toArray(rc: Region[r2], m: MutHashMap[k, v, r]): Array[(k, v), r2] \ r + r2 Source

Returns an array of all key-value pairs in m in insertion order.

def toList(m: MutHashMap[k, v, r]): List[(k, v)] \ r Source

Returns a list of all key-value pairs in m in insertion order.

def toMap(m: MutHashMap[k, v, r]): Map[k, v] \ r with Order[k] Source

Returns an immutable map containing all key-value pairs from m.

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

Returns a set containing all key-value pairs from m.

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

Returns a string representation of m.

def toVector(m: MutHashMap[k, v, r]): Vector[(k, v)] \ r Source

Returns a vector of all key-value pairs in m in insertion order.

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

Transforms all values in m in-place using function f.

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

Transforms all values in m in-place using function f with access to keys.

def update(f: v -> Option[v] \ ef, k: k, m: MutHashMap[k, v, r]): Unit \ ef + r with Eq[k], Hash[k] Source

Updates or removes the value at key k based on function f.

If key exists and f(oldValue) = Some(newValue), updates to newValue.

If key exists and f(oldValue) = None, removes the entry.

Does nothing if the key does not exist.

def updateWithKey(f: k -> (v -> Option[v] \ ef), k: k, m: MutHashMap[k, v, r]): Unit \ ef + r with Eq[k], Hash[k] Source

Updates or removes the value at key k based on function f with key.

If key exists and f(k, oldValue) = Some(newValue), updates to newValue.

If key exists and f(k, oldValue) = None, removes the entry.

Does nothing if the key does not exist.

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

Returns a list of all values in m in insertion order.