Module Reg.Map

type compare_key
type +'a t
include Ppx_compare_lib.Comparable.S1 with type +'a t := 'a t
val compare : 'a Base__Ppx_compare_lib.compare -> 'a t Base__Ppx_compare_lib.compare
include Ppx_compare_lib.Equal.S1 with type +'a t := 'a t
val equal : 'a Base__Ppx_compare_lib.equal -> 'a t Base__Ppx_compare_lib.equal
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
type ('a, 'compare_a) comparer := 'a -> 'a -> int
type 'compare_a compare
val compare_compare : ('compare_a -> 'compare_a -> int) -> 'compare_a compare -> 'compare_a compare -> int
val equal_compare : ('compare_a -> 'compare_a -> bool) -> 'compare_a compare -> 'compare_a compare -> bool
val sexp_of_compare : ('compare_a -> Sexplib0.Sexp.t) -> 'compare_a compare -> Sexplib0.Sexp.t
val compare_of_sexp : (Sexplib0.Sexp.t -> 'compare_a) -> Sexplib0.Sexp.t -> 'compare_a compare
val comparer : ('a, 'compare_a) comparer -> ('a t, 'compare_a compare) comparer
module Provide_of_sexp (_ : sig ... end) : sig ... end

Construct

val empty : 'a t
val singleton : Llair__.LlairExp.Reg.exp -> 'a -> 'a t
val add_exn : key:Llair__.LlairExp.Reg.exp -> data:'a -> 'a t -> 'a t
val add : key:Llair__.LlairExp.Reg.exp -> data:'a -> 'a t -> 'a t
val add_absent : key:Llair__.LlairExp.Reg.exp -> data:'a -> 'a t -> 'a t

Add a binding if the key is not already bound.

val add_multi : key:Llair__.LlairExp.Reg.exp -> data:'a -> 'a list t -> 'a list t
val remove : Llair__.LlairExp.Reg.exp -> 'a t -> 'a t
val merge : 'a t -> 'b t -> f: (Llair__.LlairExp.Reg.exp -> [ `Left of 'a | `Both of 'a * 'b | `Right of 'b ] -> 'c option) -> 'c t
val merge_endo : 'a t -> 'b t -> f: (Llair__.LlairExp.Reg.exp -> [ `Left of 'a | `Both of 'a * 'b | `Right of 'b ] -> 'a option) -> 'a t

Like merge, but specialized to require f to preserve the type of the left argument, which enables preserving == if f preserves == of every value.

val union : 'a t -> 'a t -> f:(Llair__.LlairExp.Reg.exp -> 'a -> 'a -> 'a option) -> 'a t
val union_absent : 'a t -> 'a t -> 'a t

union_absent m1 m2 contains all the bindings of m1 as well as those of m2 for keys not contained by m1. union_absent m1 m2 == m1 if no bindings from m2 are added.

val partition : 'a t -> f:(Llair__.LlairExp.Reg.exp -> 'a -> bool) -> 'a t * 'a t
val partition_map : 'a t -> f:(Llair__.LlairExp.Reg.exp -> 'a -> ('b, 'c) Either.t) -> 'b t * 'c t

Query

val is_empty : 'a t -> bool
val is_singleton : 'a t -> bool
val length : 'a t -> int
val only_binding : 'a t -> (Llair__.LlairExp.Reg.exp * 'a) option
val classify : 'a t -> (Llair__.LlairExp.Reg.exp, 'a) NS__.NS0.zero_one_many2
val choose : 'a t -> (Llair__.LlairExp.Reg.exp * 'a) option

Find an unspecified binding. Different bindings may be chosen for equivalent maps. O(1).

val choose_exn : 'a t -> Llair__.LlairExp.Reg.exp * 'a

Find an unspecified binding. Different bindings may be chosen for equivalent maps. O(1).

val min_binding : 'a t -> (Llair__.LlairExp.Reg.exp * 'a) option
val max_binding : 'a t -> (Llair__.LlairExp.Reg.exp * 'a) option
val max_binding_exn : 'a t -> Llair__.LlairExp.Reg.exp * 'a
val mem : Llair__.LlairExp.Reg.exp -> 'a t -> bool
val find : Llair__.LlairExp.Reg.exp -> 'a t -> 'a option
val find_exn : Llair__.LlairExp.Reg.exp -> 'a t -> 'a
val find_multi : Llair__.LlairExp.Reg.exp -> 'a list t -> 'a list
val find_update : Llair__.LlairExp.Reg.exp -> 'a t -> f:('a option -> 'a option) -> 'a option * 'a t

find_update k f m is (found, m') where found is find k m and find k m' is f found and find h m' is find h m for all other h.

val find_and_remove : Llair__.LlairExp.Reg.exp -> 'a t -> 'a option * 'a t

Find and remove the binding for a key.

val find_or_add : Llair__.LlairExp.Reg.exp -> 'a -> 'a t -> 'a option * 'a t

Find the value bound to the given key if there is one, or otherwise add a binding for the given key and value.

val find_or_add_lazy : Llair__.LlairExp.Reg.exp -> 'a t -> f:(unit -> 'a) -> [> `Added of 'a | `Found of 'a ] * 'a t

Find the value bound to the given key if there is one, or otherwise add a binding for the given key with value f ().

val pop_min_binding : 'a t -> (Llair__.LlairExp.Reg.exp * 'a * 'a t) option

Find and remove binding with minimum key. O(log n).

Transform

val update : Llair__.LlairExp.Reg.exp -> 'a t -> f:('a option -> 'a option) -> 'a t
val map : 'a t -> f:('a -> 'b) -> 'b t
val mapi : 'a t -> f:(key:Llair__.LlairExp.Reg.exp -> data:'a -> 'b) -> 'b t
val map_endo : 'a t -> f:('a -> 'a) -> 'a t

Like map, but specialized to require f to be an endofunction, which enables preserving == if f preserves == of every value.

val filter_mapi : 'a t -> f:(key:Llair__.LlairExp.Reg.exp -> data:'a -> 'b option) -> 'b t

Traverse

val iter : 'a t -> f:('a -> unit) -> unit
val iteri : 'a t -> f:(key:Llair__.LlairExp.Reg.exp -> data:'a -> unit) -> unit
val existsi : 'a t -> f:(key:Llair__.LlairExp.Reg.exp -> data:'a -> bool) -> bool
val for_alli : 'a t -> f:(key:Llair__.LlairExp.Reg.exp -> data:'a -> bool) -> bool
val fold : 'a t -> 's -> f:(key:Llair__.LlairExp.Reg.exp -> data:'a -> 's -> 's) -> 's
val fold_until : 'a t -> 's -> f: (key:Llair__.LlairExp.Reg.exp -> data:'a -> 's -> [ `Continue of 's | `Stop of 'b ]) -> finish:('s -> 'b) -> 'b

Convert

val keys : 'a t -> (Llair__.LlairExp.Reg.exp -> unit) -> unit
val values : 'a t -> ('a -> unit) -> unit
val to_iter : 'a t -> ((Llair__.LlairExp.Reg.exp * 'a) -> unit) -> unit
val to_list : 'a t -> (Llair__.LlairExp.Reg.exp * 'a) list
val of_iter : (((Llair__.LlairExp.Reg.exp * 'a) -> unit) -> unit) -> 'a t
val of_list : (Llair__.LlairExp.Reg.exp * 'a) list -> 'a t
val symmetric_diff : 'a t -> 'b t -> eq:('a -> 'b -> bool) -> ((Llair__.LlairExp.Reg.exp * [> `Left of 'a | `Unequal of 'a * 'b | `Right of 'b ]) -> unit) -> unit

Pretty-print

val pp : (Stdlib.Format.formatter -> Llair__.LlairExp.Reg.exp -> unit) -> (Stdlib.Format.formatter -> 'a -> unit) -> Stdlib.Format.formatter -> 'a t -> unit
val pp_diff : ?pre:(unit, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> ?suf:(unit, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> ?sep:(unit, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> (Stdlib.Format.formatter -> Llair__.LlairExp.Reg.exp -> unit) -> (Stdlib.Format.formatter -> 'a -> unit) -> (Stdlib.Format.formatter -> ('a * 'a) -> unit) -> eq:('a -> 'a -> bool) -> Stdlib.Format.formatter -> ('a t * 'a t) -> unit