package capnp-rpc-net

  1. Overview
  2. Docs

Map

include Stdlib.Map.S with type key = t
type key = t
type !+'a t
val empty : 'a t
val add : key -> 'a -> 'a t -> 'a t
val add_to_list : key -> 'a -> 'a list t -> 'a list 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 cardinal : 'a t -> int
val bindings : 'a t -> (key * 'a) list
val min_binding_opt : 'a t -> (key * 'a) option
val max_binding_opt : 'a t -> (key * 'a) option
val choose_opt : 'a t -> (key * 'a) option
val find_opt : key -> 'a t -> 'a option
val find_first : (key -> bool) -> 'a t -> key * 'a
val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option
val find_last : (key -> bool) -> 'a t -> key * 'a
val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option
val iter : (key -> 'a -> unit) -> 'a t -> unit
val fold : (key -> 'a -> 'acc -> 'acc) -> 'a t -> 'acc -> 'acc
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
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 split : key -> 'a t -> 'a t * 'a option * 'a t
val is_empty : 'a t -> bool
val mem : key -> 'a t -> bool
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val for_all : (key -> 'a -> bool) -> 'a t -> bool
val exists : (key -> 'a -> bool) -> 'a t -> bool
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 find : key -> 'a t -> 'a option

find k m is the binding of k in m (if any).

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

get k m is like Map.S.find but raises Invalid_argument if k is not bound in m.

val min_binding : 'a t -> (key * 'a) option

min_binding m is the smallest binding of m (if any).

val get_min_binding : 'a t -> key * 'a

get_min_binding is like min_binding but

  • raises Invalid_argument

    on the empty map.

val max_binding : 'a t -> (key * 'a) option

max_binding m is the greatest binding of m (if any).

val get_max_binding : 'a t -> key * 'a

get_min_binding is like max_binding but

  • raises Invalid_argument

    on the empty map.

val choose : 'a t -> (key * 'a) option

choose m is a binding of m (if any). Equal bindings are chosen for equal maps.

val get_any_binding : 'a t -> key * 'a

get_any_binding is like choose but

  • raises Invalid_argument

    on the empty map.

Conversions

val to_list : 'a t -> (key * 'a) list

to_list m is the bindings of m in increasing key order.

val of_list : (key * 'a) list -> 'a t

of_list l is the map holding the bindings of l. If a key is bound more than once the last one takes over.

Pretty-printing

val pp : ?sep:(Stdlib.Format.formatter -> unit -> unit) -> (Stdlib.Format.formatter -> (key * 'a) -> unit) -> Stdlib.Format.formatter -> 'a t -> unit

pp ~sep pp_binding ppf m formats the bindings of m on ppf. Each binding is formatted with pp_binding and bindings are separated by sep (defaults to Format.pp_print_cut). If the map is empty leaves ppf untouched.

val dump : (Stdlib.Format.formatter -> (key * 'a) -> unit) -> Stdlib.Format.formatter -> 'a t -> unit

dump pp_binding prints an unspecified represention of m on ppf using pp_binding to print the bindings.