TMap

final class TMap[K, V]

Transactional map implemented on top of TRef and TArray. Resolves conflicts via chaining.

Companion:
object
class Object
trait Matchable
class Any

Value members

Concrete methods

def contains(k: K): USTM[Boolean]

Tests whether or not map contains a key.

Tests whether or not map contains a key.

def delete(k: K): USTM[Unit]

Removes binding for given key.

Removes binding for given key.

def deleteAll(ks: Iterable[K]): USTM[Unit]

Deletes all entries associated with the specified keys.

Deletes all entries associated with the specified keys.

def find[A](pf: PartialFunction[(K, V), A]): USTM[Option[A]]

Finds the key/value pair matching the specified predicate, and uses the provided function to extract a value out of it.

Finds the key/value pair matching the specified predicate, and uses the provided function to extract a value out of it.

def findAll[A](pf: PartialFunction[(K, V), A]): USTM[Chunk[A]]

Finds all the key/value pairs matching the specified predicate, and uses the provided function to extract values out them.

Finds all the key/value pairs matching the specified predicate, and uses the provided function to extract values out them.

def findAllSTM[R, E, A](pf: (K, V) => ZSTM[R, Option[E], A]): ZSTM[R, E, Chunk[A]]

Finds all the key/value pairs matching the specified predicate, and uses the provided effectful function to extract values out of them..

Finds all the key/value pairs matching the specified predicate, and uses the provided effectful function to extract values out of them..

def findSTM[R, E, A](f: (K, V) => ZSTM[R, Option[E], A]): ZSTM[R, E, Option[A]]

Finds the key/value pair matching the specified predicate, and uses the provided effectful function to extract a value out of it.

Finds the key/value pair matching the specified predicate, and uses the provided effectful function to extract a value out of it.

def fold[A](zero: A)(op: (A, (K, V)) => A): USTM[A]

Atomically folds using a pure function.

Atomically folds using a pure function.

def foldSTM[R, E, A](zero: A)(op: (A, (K, V)) => ZSTM[R, E, A]): ZSTM[R, E, A]

Atomically folds using a transactional function.

Atomically folds using a transactional function.

def foreach[R, E](f: (K, V) => ZSTM[R, E, Unit]): ZSTM[R, E, Unit]

Atomically performs transactional-effect for each binding present in map.

Atomically performs transactional-effect for each binding present in map.

def get(k: K): USTM[Option[V]]

Retrieves value associated with given key.

Retrieves value associated with given key.

def getOrElse(k: K, default: => V): USTM[V]

Retrieves value associated with given key or default value, in case the key isn't present.

Retrieves value associated with given key or default value, in case the key isn't present.

def isEmpty: USTM[Boolean]

Tests if the map is empty or not

Tests if the map is empty or not

def keys: USTM[List[K]]

Collects all keys stored in map.

Collects all keys stored in map.

def merge(k: K, v: V)(f: (V, V) => V): USTM[V]

If the key k is not already associated with a value, stores the provided value, otherwise merge the existing value with the new one using function f and store the result

If the key k is not already associated with a value, stores the provided value, otherwise merge the existing value with the new one using function f and store the result

def put(k: K, v: V): USTM[Unit]

Stores new binding into the map.

Stores new binding into the map.

def putIfAbsent(k: K, v: V): USTM[Unit]

Stores new binding in the map if it does not already exist.

Stores new binding in the map if it does not already exist.

def removeIf(p: (K, V) => Boolean): USTM[Chunk[(K, V)]]

Removes bindings matching predicate and returns the removed entries.

Removes bindings matching predicate and returns the removed entries.

def removeIfDiscard(p: (K, V) => Boolean): USTM[Unit]

Removes bindings matching predicate.

Removes bindings matching predicate.

def retainIf(p: (K, V) => Boolean): USTM[Chunk[(K, V)]]

Retains bindings matching predicate and returns removed bindings.

Retains bindings matching predicate and returns removed bindings.

def retainIfDiscard(p: (K, V) => Boolean): USTM[Unit]

Retains bindings matching predicate.

Retains bindings matching predicate.

def takeFirst[A](pf: PartialFunction[(K, V), A]): USTM[A]

Takes the first matching value, or retries until there is one.

Takes the first matching value, or retries until there is one.

def takeFirstSTM[R, E, A](pf: (K, V) => ZSTM[R, Option[E], A]): ZSTM[R, E, A]
def takeSome[A](pf: PartialFunction[(K, V), A]): USTM[NonEmptyChunk[A]]

Takes all matching values, or retries until there is at least one.

Takes all matching values, or retries until there is at least one.

def takeSomeSTM[R, E, A](pf: (K, V) => ZSTM[R, Option[E], A]): ZSTM[R, E, NonEmptyChunk[A]]

Takes all matching values, or retries until there is at least one.

Takes all matching values, or retries until there is at least one.

def toChunk: USTM[Chunk[(K, V)]]

Collects all bindings into a chunk.

Collects all bindings into a chunk.

def toList: USTM[List[(K, V)]]

Collects all bindings into a list.

Collects all bindings into a list.

def toMap: USTM[Map[K, V]]

Collects all bindings into a map.

Collects all bindings into a map.

def transform(f: (K, V) => (K, V)): USTM[Unit]

Atomically updates all bindings using a pure function.

Atomically updates all bindings using a pure function.

def transformSTM[R, E](f: (K, V) => ZSTM[R, E, (K, V)]): ZSTM[R, E, Unit]

Atomically updates all bindings using a transactional function.

Atomically updates all bindings using a transactional function.

def transformValues(f: V => V): USTM[Unit]

Atomically updates all values using a pure function.

Atomically updates all values using a pure function.

def transformValuesSTM[R, E](f: V => ZSTM[R, E, V]): ZSTM[R, E, Unit]

Atomically updates all values using a transactional function.

Atomically updates all values using a transactional function.

def updateWith(k: K)(f: Option[V] => Option[V]): USTM[Option[V]]

Updates the mapping for the specified key with the specified function, which takes the current value of the key as an input, if it exists, and either returns Some with a new value to indicate to update the value in the map or None to remove the value from the map. Returns Some with the updated value or None if the value was removed from the map.

Updates the mapping for the specified key with the specified function, which takes the current value of the key as an input, if it exists, and either returns Some with a new value to indicate to update the value in the map or None to remove the value from the map. Returns Some with the updated value or None if the value was removed from the map.

def values: USTM[List[V]]

Collects all values stored in map.

Collects all values stored in map.

Concrete fields

val size: USTM[Int]

Returns the number of bindings.

Returns the number of bindings.