package containers

  1. Overview
  2. Docs

Parameters

module X : ORDERED

Signature

type char_ = X.t
type key = X.t array
type 'a t
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 remove : key -> 'a t -> 'a t

Remove the key, if present

val find : key -> 'a t -> 'a option

Find the value associated with the key, if any

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

Same as find but can fail.

  • raises Not_found

    if the key is not present

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, or Some v if key is bound to v; if it returns None the key is removed, otherwise it returns Some y and key becomes bound to y

val fold : ('b -> key -> 'a -> 'b) -> 'b -> 'a t -> 'b

Fold on key/value bindings. Will use WORD.of_list to rebuild keys.

val iter : (key -> 'a -> unit) -> 'a t -> unit

Same as fold, but for effectful functions

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

Conversions
val to_list : 'a t -> (key * 'a) list
val of_list : (key * 'a) list -> 'a t
val to_seq : 'a t -> (key * 'a) sequence
val of_seq : (key * 'a) sequence -> 'a t
val to_seq_values : 'a t -> 'a sequence
val to_tree : 'a t -> [ `Char of char_ | `Val of 'a | `Switch ] ktree
Ranges
val above : key -> 'a t -> (key * 'a) sequence

All bindings whose key is bigger than (or equal to) the given key

val below : key -> 'a t -> (key * 'a) sequence

All bindings whose key is smaller or equal to the given key

OCaml

Innovation. Community. Security.