Module CCTrie.Make
Parameters
Signature
val empty : 'a t
val is_empty : _ t -> bool
val add : key -> 'a -> 'a t -> 'a t
Add a binding to the trie (possibly erasing the previous one).
val find_exn : key -> 'a t -> 'a
Same as
find
but can fail.- raises Not_found
if the key is not present.
val longest_prefix : key -> 'a t -> key
longest_prefix k m
finds the longest prefix ofk
that leads to at least one path inm
(it does not mean that the prefix is bound to a value.Example: if
m
has keys "abc0" and "abcd", thenlongest_prefix "abc2" m
will return "abc".- since
- 0.17
val update : key -> ('a option -> 'a option) -> 'a t -> 'a t
Update the binding for the given key. The function is given
None
if the key is absent, orSome v
ifkey
is bound tov
; if it returnsNone
the key is removed, otherwise it returnsSome y
andkey
becomes bound toy
.
val fold : ('b -> key -> 'a -> 'b) -> 'b -> 'a t -> 'b
Fold on key/value bindings. Will use
WORD.of_list
to rebuild keys.
val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
Map values, giving both key and value. Will use
WORD.of_list
to rebuild keys.- since
- 0.17
val fold_values : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
More efficient version of
fold
, that doesn't keep keys.
val iter_values : ('a -> unit) -> 'a t -> unit
val merge : ('a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t
Merge two tries together. The function is used in case of conflicts, when a key belongs to both tries.
val size : _ t -> int
Number of bindings.