Module CCHashTrie.Make

Functors

Parameters

K : KEY

Signature

type key = K.t
type 'a t
val empty : 'a t
val is_empty : _ t -> bool
val singleton : key -> 'a -> 'a t
val add : key -> 'a -> 'a t -> 'a t
val mem : key -> _ t -> bool
val get : key -> 'a t -> 'a option
val get_exn : key -> 'a t -> 'a
raises Not_found

if key not present.

val remove : key -> 'a t -> 'a t

Remove the key, if present.

val update : key -> f:('a option -> 'a option) -> 'a t -> 'a t

update k ~f m calls f (Some v) if get k m = Some v, f None otherwise. Then, if f returns Some v' it binds k to v', if f returns None it removes k.

val add_mut : id:Transient.t -> key -> 'a -> 'a t -> 'a t

add_mut ~id k v m behaves like add k v m, except it will mutate in place whenever possible. Changes done with an id might affect all versions of the structure obtained with the same id (but not other versions).

raises Transient.Frozen

if id is frozen.

val remove_mut : id:Transient.t -> key -> 'a t -> 'a t

Same as remove, but modifies in place whenever possible.

raises Transient.Frozen

if id is frozen.

val update_mut : id:Transient.t -> key -> f:('a option -> 'a option) -> 'a t -> 'a t

Same as update but with mutability.

raises Transient.Frozen

if id is frozen.

val cardinal : _ t -> int
val choose : 'a t -> (key * 'a) option
val choose_exn : 'a t -> key * 'a
raises Not_found

if not pair was found.

val iter : f:(key -> 'a -> unit) -> 'a t -> unit
val fold : f:('b -> key -> 'a -> 'b) -> x:'b -> 'a t -> 'b

Conversions

val to_list : 'a t -> (key * 'a) list
val add_list : 'a t -> (key * 'a) list -> 'a t
val add_list_mut : id:Transient.t -> 'a t -> (key * 'a) list -> 'a t
raises Frozen

if the ID is frozen.

val of_list : (key * 'a) list -> 'a t
val add_seq : 'a t -> (key * 'a) sequence -> 'a t
val add_seq_mut : id:Transient.t -> 'a t -> (key * 'a) sequence -> 'a t
raises Frozen

if the ID is frozen.

val of_seq : (key * 'a) sequence -> 'a t
val to_seq : 'a t -> (key * 'a) sequence
val add_gen : 'a t -> (key * 'a) gen -> 'a t
val add_gen_mut : id:Transient.t -> 'a t -> (key * 'a) gen -> 'a t
raises Frozen

if the ID is frozen.

val of_gen : (key * 'a) gen -> 'a t
val to_gen : 'a t -> (key * 'a) gen

IO

val pp : key printer -> 'a printer -> 'a t printer

Renamed from val print.

since
2.0
val as_tree : 'a t -> [ `L of int * (key * 'a) list | `N ] ktree

For debugging purpose: explore the structure of the tree, with `L (h,l) being a leaf (with shared hash h) and `N an inner node.