package kcas_data

  1. Overview
  2. Docs

Module Hashtbl.TxSource

Transactions on hash tables.

Sourceval length : ('k, 'v) t -> int Kcas.Tx.t

length t returns the number of bindings in the hash table t.

⚠️ The returned value may be greater than the number of distinct keys in the hash table.

Sourceval reset : ('k, 'v) t -> unit Kcas.Tx.t

reset t remove all bindings from the hash table t and shrinks the capacity of the table back to the minimum.

Sourceval clear : ('k, 'v) t -> unit Kcas.Tx.t

clear is a synonym for reset.

Sourceval remove : ('k, 'v) t -> 'k -> unit Kcas.Tx.t

remove t k removes the most recent existing binding of key k, if any, from the hash table t thereby revealing the earlier binding of k, if any.

Sourceval add : ('k, 'v) t -> 'k -> 'v -> unit Kcas.Tx.t

add t k v adds a binding of key k to value v to the hash table shadowing the previous binding of the key k, if any.

⚠️ Consider using replace instead of add.

Sourceval replace : ('k, 'v) t -> 'k -> 'v -> unit Kcas.Tx.t

replace t k v adds a binding of key k to value v or replaces the most recent existing binding of key k in the hash table t.

Sourceval mem : ('k, 'v) t -> 'k -> bool Kcas.Tx.t

mem t k is equivalent to Option.is_some (find_opt t k).

Sourceval find_opt : ('k, 'v) t -> 'k -> 'v option Kcas.Tx.t

find_opt t k returns the current binding of key k in the hash table t, or None if no such binding exists.

Sourceval find_all : ('k, 'v) t -> 'k -> 'v list Kcas.Tx.t

find_all t k returns a list of all the bindings of the key k in the hash table in reverse order of their introduction.