Module OLinq_map

module OLinq_map: sig .. end

Polymorphic Maps and Multimaps



type 'a equal = 'a -> 'a -> bool 
type 'a ord = 'a -> 'a -> int 
type 'a hash = 'a -> int 
type 'a sequence = ('a -> unit) -> unit 

Basics


type ('a, 'b) t = private {
   is_empty : unit -> bool;
   size : unit -> int;
   get_exn : 'a -> 'b;
   iter : ('a -> 'b -> unit) -> unit;
   fold : 'c. ('c -> 'a -> 'b -> 'c) -> 'c -> 'c;
   choose : unit -> ('a * 'b) option;
}
Map from keys of type 'a to values of type 'b the type might change, it is exposed merely for variance checks w.r.t GADTs. Do not access fields directly.
type ('a, 'b) map = ('a, 'b) t 
val get : ('a, 'b) t -> 'a -> 'b option
val get_exn : ('a, 'b) t -> 'a -> 'b
val mem : ('a, 'b) t -> 'a -> bool
val size : ('a, 'b) t -> int
val to_seq : ('a, 'b) t -> ('a * 'b) sequence
val to_seq_multimap : ('a, 'b list) t -> ('a * 'b) sequence
val to_list : ('a, 'b) t -> ('a * 'b) list
val to_rev_list : ('a, 'b) t -> ('a * 'b) list
val fold : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> ('a, 'b) t -> 'acc
Fold on the items of the map
val fold_multimap : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> ('a, 'b list) t -> 'acc
Fold on the items of the multimap
val get_seq : 'a -> ('a, 'b) t -> 'b sequence
Select a key from a map and wrap into sequence
val iter : ('a, 'b) t -> ('a -> 'b -> unit) -> unit
View a multimap as a proper collection
val choose : ('a, 'b) t -> ('a * 'b) option

Build

Used to build new maps

module Build: sig .. end

Misc


val of_seq : ?src:'a Build.src ->
('a * 'b) sequence -> ('a, 'b list) t
val of_list : ?src:'a Build.src -> ('a * 'b) list -> ('a, 'b list) t
val count_seq : ?src:'a Build.src -> 'a sequence -> ('a, int) t
val map : ('b -> 'c) -> ('a, 'b) t -> ('a, 'c) t
Transform values
val reverse : ?src:'b Build.src ->
('a, 'b) t -> ('b, 'a list) t
Reverse relation of the map, as a multimap
val reverse_multimap : ?src:'b Build.src ->
('a, 'b list) t -> ('b, 'a list) t
Reverse relation of the multimap
val flatten : ('a, 'b sequence) t -> ('a * 'b) sequence
View a multimap as a collection of individual key/value pairs
val flatten_l : ('a, 'b list) t -> ('a * 'b) sequence
View a multimap as a list of individual key/value pairs