package olinq

  1. Overview
  2. Docs

Module OLinq_mapSource

Polymorphic Maps and Multimaps

Sourcetype 'a equal = 'a -> 'a -> bool
Sourcetype 'a ord = 'a -> 'a -> int
Sourcetype 'a hash = 'a -> int
Sourcetype 'a iter = ('a -> unit) -> unit

Basics

Sourcetype ('a, +'b) t = private {
  1. is_empty : unit -> bool;
  2. size : unit -> int;
  3. get_exn : 'a -> 'b;
  4. iter : ('a -> 'b -> unit) -> unit;
  5. fold : 'c. ('c -> 'a -> 'b -> 'c) -> 'c -> 'c;
  6. 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.

Sourcetype ('a, +'b) map = ('a, 'b) t
Sourceval get : ('a, 'b) t -> 'a -> 'b option
Sourceval get_exn : ('a, 'b) t -> 'a -> 'b
Sourceval mem : ('a, _) t -> 'a -> bool
Sourceval size : (_, _) t -> int
Sourceval to_iter : ('a, 'b) t -> ('a * 'b) iter
Sourceval to_iter_multimap : ('a, 'b list) t -> ('a * 'b) iter
Sourceval to_list : ('a, 'b) t -> ('a * 'b) list
Sourceval to_rev_list : ('a, 'b) t -> ('a * 'b) list
Sourceval fold : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> ('a, 'b) t -> 'acc

Fold on the items of the map

Sourceval fold_multimap : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> ('a, 'b list) t -> 'acc

Fold on the items of the multimap

Sourceval get_seq : 'a -> ('a, 'b) t -> 'b iter

Select a key from a map and wrap into iter

Sourceval iter : ('a, 'b) t -> ('a -> 'b -> unit) -> unit

View a multimap as a proper collection

Sourceval choose : ('a, 'b) t -> ('a * 'b) option

Build

Used to build new maps

Sourcemodule Build : sig ... end

Misc

Sourceval of_iter : ?src:'a Build.src -> ('a * 'b) iter -> ('a, 'b list) t
Sourceval of_list : ?src:'a Build.src -> ('a * 'b) list -> ('a, 'b list) t
Sourceval count_seq : ?src:'a Build.src -> 'a iter -> ('a, int) t
Sourceval map : ('b -> 'c) -> ('a, 'b) t -> ('a, 'c) t

Transform values

Sourceval reverse : ?src:'b Build.src -> ('a, 'b) t -> ('b, 'a list) t

Reverse relation of the map, as a multimap

Sourceval reverse_multimap : ?src:'b Build.src -> ('a, 'b list) t -> ('b, 'a list) t

Reverse relation of the multimap

Sourceval flatten : ('a, 'b iter) t -> ('a * 'b) iter

View a multimap as a collection of individual key/value pairs

Sourceval flatten_l : ('a, 'b list) t -> ('a * 'b) iter

View a multimap as a list of individual key/value pairs

OCaml

Innovation. Community. Security.