package kcas_data

  1. Overview
  2. Docs

Transactions on hash tables.

val 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.

val 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.

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

clear is a synonym for reset.

val 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.

val 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.

val 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.

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

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

val 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.

val 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.

OCaml

Innovation. Community. Security.