Library
Module
Module type
Parameter
Class
Class type
Adaptive Radix Tree in OCaml.
Implementation of Adaptive Radix Tree (trie), for efficient indexing in memory. Its lookup performance surpasses highly tuned, read-only search trees, while supporting very efficient insertions and deletions as well. ART is very space efficient and solves the problem of excessive worst-case space consumption, which plagues most radix tree, by adaptively choosing compact and efficient data structures for internal nodes. Even though, ART's performance is comparable to hash tables, it maintains the data in sorted order, which enables additional operations like range scan and prefix lookup.
The type of trees from type key
to type 'a
.
val key : string -> key
val unsafe_key : string -> key
val make : unit -> 'a t
make ()
creates a new, empty tree.
insert t k v
replaces the current binding of k
in t
by a binding of k
to v
. If k
is unbound in t
, a binding of k
to v
is added to t
.
find x t
returns the current binding of x
in t
, or raises Not_found
if no such binding exists.
find_opt x t
returns Some v
if the current value of x
in t
is v
, or None
if no binding for x
exists.
val is_empty : 'a t -> bool
is_empty tree
returns true
if tree
is empty. Otherwise, it returns false
.
Return the binding with the smallest key
in a given tree or raise Invalid_argument
if the tree is empty.
remove t k
removes the current binding of k
in t
. It raises Not_found
if k
is not bound in t
.
iter ~f a t
computes (f kN dN ... (f k1 d1 a) ...)
, where k1 ... kN
are the keys of all bindings in t
(in increasing order), and d1 ... dN
are the associated data.