package phashtbl

  1. Overview
  2. Docs
type 'b t
val open_new : filename -> 'b t

open_new filename creates a new persistent hashtbl. dbm will create filename.dir and filename.pag files.

val open_existing : filename -> 'b t

open_existing filename opens an existing persistent hashtbl for reading and writing. The files filename.dir and filename.pag must already exist.

val close : 'b t -> unit

close pht closes the previously opened pht.

val mem : 'b t -> string -> bool

mem pht key checks if key is bound in pht.

val add : 'b t -> string -> 'b -> unit

add pht key value binds key to value in pht. Raises Dbm_error if key is already bound in pht.

val replace : 'b t -> string -> 'b -> unit

replace pht key value binds key to value in pht. If pht already contains a binding for key, that previous binding is discarded and replaced by value.

val remove : 'b t -> string -> unit

remove pht key removes key and its bound value from pht. If key is unbound in pht, raises Dbm_error.

val find : 'b t -> string -> 'b

find pht key finds the value bound to key in pht or raises Not_found if key is unbound.

val iter : (string -> 'b -> unit) -> 'b t -> unit

iter f pht calls f key value on each (key, value) binding from pht.

val fold : (string -> 'b -> 'c -> 'c) -> 'b t -> 'c -> 'c

fold f pht init folds f over pht with init as the initial accumulator.