package tezos-base

  1. Overview
  2. Docs

This module implements a sized-map data-structure.

This module has the same interface as Stdlib.Map but with a different performance trade-off:

The cardinal function is much more efficient, but all other functions are a little bit slower. You should use this module if you need to call the cardinal function often. You should stick to Stdlib.Map otherwise.

Parameters

Signature

All the types and functions from the underlying Maps are supported.

The functions merge and union are less efficient than TzLwtreslib.Map.S.merge and TzLwtreslib.Map.S.union which should be considered instead, especially in case there are called several times. to_map and of_map can be used for this purpose.

include Tezos_error_monad.TzLwtreslib.Map.S with type key = Map.key
type key = Map.key
type !+'a t
val empty : 'a t
val is_empty : 'a t -> bool
val mem : key -> 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t
val update : key -> ('a option -> 'a option) -> 'a t -> 'a t
val singleton : key -> 'a -> 'a t
val remove : key -> 'a t -> 'a t
val merge : (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t
val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val iter_e : (key -> 'a -> (unit, 'trace) Stdlib.result) -> 'a t -> (unit, 'trace) Stdlib.result
val iter_s : (key -> 'a -> unit Lwt.t) -> 'a t -> unit Lwt.t
val iter_p : (key -> 'a -> unit Lwt.t) -> 'a t -> unit Lwt.t
val iter_es : (key -> 'a -> (unit, 'trace) Stdlib.result Lwt.t) -> 'a t -> (unit, 'trace) Stdlib.result Lwt.t
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val fold_e : (key -> 'a -> 'b -> ('b, 'trace) Stdlib.result) -> 'a t -> 'b -> ('b, 'trace) Stdlib.result
val fold_s : (key -> 'a -> 'b -> 'b Lwt.t) -> 'a t -> 'b -> 'b Lwt.t
val fold_es : (key -> 'a -> 'b -> ('b, 'trace) Stdlib.result Lwt.t) -> 'a t -> 'b -> ('b, 'trace) Stdlib.result Lwt.t
val for_all : (key -> 'a -> bool) -> 'a t -> bool
val exists : (key -> 'a -> bool) -> 'a t -> bool
val filter : (key -> 'a -> bool) -> 'a t -> 'a t
val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t
val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t
val cardinal : 'a t -> int
val bindings : 'a t -> (key * 'a) list
val min_binding : 'a t -> (key * 'a) option
val min_binding_opt : 'a t -> (key * 'a) option
val max_binding : 'a t -> (key * 'a) option
val max_binding_opt : 'a t -> (key * 'a) option
val choose : 'a t -> (key * 'a) option
val choose_opt : 'a t -> (key * 'a) option
val split : key -> 'a t -> 'a t * 'a option * 'a t
val find : key -> 'a t -> 'a option
val find_opt : key -> 'a t -> 'a option
val find_first : (key -> bool) -> 'a t -> (key * 'a) option
val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option
val find_last : (key -> bool) -> 'a t -> (key * 'a) option
val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
val to_seq : 'a t -> (key * 'a) Stdlib.Seq.t
val to_rev_seq : 'a t -> (key * 'a) Stdlib.Seq.t
val to_seq_from : key -> 'a t -> (key * 'a) Stdlib.Seq.t
val add_seq : (key * 'a) Stdlib.Seq.t -> 'a t -> 'a t
val of_seq : (key * 'a) Stdlib.Seq.t -> 'a t
val iter_ep : (key -> 'a -> (unit, 'error Tezos_error_monad.TzTrace.trace) Stdlib.result Lwt.t) -> 'a t -> (unit, 'error Tezos_error_monad.TzTrace.trace) Stdlib.result Lwt.t
val to_map : 'a t -> 'a Map.t

to_map t returns the map of the sizedmap t

val of_map : 'a Map.t -> 'a t

of_map m returns the sizedmap of the map m

OCaml

Innovation. Community. Security.