package art

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module ArtSource

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.

Sourcetype 'a t

The type of trees from type key to type 'a.

Sourcetype key = private string

The type of the tree keys. A null-terminated string.

Sourceval key : string -> key
Sourceval unsafe_key : string -> key
Sourceval make : unit -> 'a t

make () creates a new, empty tree.

Sourceval insert : 'a t -> key -> 'a -> unit

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.

Sourceval find : 'a t -> key -> 'a

find x t returns the current binding of x in t, or raises Not_found if no such binding exists.

Sourceval find_opt : 'a t -> key -> 'a option

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.

Sourceval pp : 'a Fmt.t -> 'a t Fmt.t
Sourceval is_empty : 'a t -> bool

is_empty tree returns true if tree is empty. Otherwise, it returns false.

Sourceval minimum : 'a t -> key * 'a

Return the binding with the smallest key in a given tree or raise Invalid_argument if the tree is empty.

Sourceval maximum : 'a t -> key * 'a

Same as minimum, but returns the binding with the largest key in the given tree.

Sourceval remove : 'a t -> key -> unit

remove t k removes the current binding of k in t. It raises Not_found if k is not bound in t.

Sourceval iter : f:(key -> 'a -> 'acc -> 'acc) -> 'acc -> 'a t -> 'acc

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.

Sourceval of_seq : (key * 'a) Seq.t -> 'a t

Build a tree from the given bindings.

Sourceval to_seq : 'a t -> (key * 'a) Seq.t

Iterate on the whole map, in increasing order of keys.

OCaml

Innovation. Community. Security.