jon.recoil.org

Module Lmap.Make

Parameters

Signature

type key = T.t
type +'a t
val empty : 'a t
val is_empty : 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t

The key should not already exist in the map; this is not checked.

val singleton : key -> 'a -> 'a t
val disjoint_union : 'a t -> 'a t -> 'a t

Unlike disjoint_union on maps, the disjointness is not checked.

val disjoint_union_many : 'a t list -> 'a t

The given maps must be pairwise disjoint, which is not checked.

val iter : (key -> 'a -> unit) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val fold_left_map : ('a -> key -> 'b -> 'a * 'c) -> 'a -> 'b t -> 'a * 'c t

Simultaneously map over the elements and accumulate a value. The arguments are ordered so as to make the order preservation as explicit as possible (the accumulator is produced from the values _before_ the key and value being passed).

val filter : (key -> 'a -> bool) -> 'a t -> 'a t
val keys : _ t -> key list
val data : 'a t -> 'a list
val bindings : 'a t -> (key * 'a) list
val of_list : (key * 'a) list -> 'a t

Keys in the list must be distinct, which is not checked.

val find : key -> 'a t -> 'a
val find_opt : key -> 'a t -> 'a option
val get_singleton : 'a t -> (key * 'a) option
val get_singleton_exn : 'a t -> key * 'a
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
val map_sharing : ('a -> 'a) -> 'a t -> 'a t
val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t
val to_seq : 'a t -> (key * 'a) Stdlib.Seq.t
val for_all_with_fixed_arg : (key -> 'a -> 'b -> bool) -> 'a t -> 'b -> bool
val exists : (key -> 'a -> bool) -> 'a t -> bool
val choose : 'a t -> key * 'a

Returns an unspecified binding from the map

val add_seq : (key * 'a) Stdlib.Seq.t -> 'a t -> 'a t

Keys in the sequence must be distinct from each other and from keys already in the map; neither of these conditions is checked.

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

Keys in the sequence must be distinct, which is not checked.

val print : (Stdlib.Format.formatter -> 'a -> unit) -> Stdlib.Format.formatter -> 'a t -> unit
val invariant : 'a t -> unit

Check that there are no duplicates in the list, calling Misc.fatal_errorf if a duplicate is found.