package phashtbl

  1. Overview
  2. Docs
type ('a, 'b) t
val open_new : filename -> ('a, 'b) t

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

val open_existing : filename -> ('a, '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 : ('a, 'b) t -> unit

close pht closes the previously opened pht.

val mem : ('a, 'b) t -> 'a -> bool

mem pht key checks if key is bound in pht.

val add : ('a, 'b) t -> 'a -> 'b -> unit

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

val replace : ('a, 'b) t -> 'a -> '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 : ('a, 'b) t -> 'a -> unit

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

val find : ('a, 'b) t -> 'a -> 'b

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

val iter : ('a -> 'b -> unit) -> ('a, 'b) t -> unit

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

val fold : ('a -> 'b -> 'c -> 'c) -> ('a, 'b) t -> 'c -> 'c

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