1Map(3) OCaml library Map(3)
2
3
4
6 Map - Association tables over ordered types.
7
9 Module Map
10
12 Module Map
13 : sig end
14
15
16 Association tables over ordered types.
17
18 This module implements applicative association tables, also known as
19 finite maps or dictionaries, given a total ordering function over the
20 keys. All operations over maps are purely applicative (no side-ef‐
21 fects). The implementation uses balanced binary trees, and therefore
22 searching and insertion take time logarithmic in the size of the map.
23
24 For instance:
25 module IntPairs =
26 struct
27 type t = int * int
28 let compare (x0,y0) (x1,y1) =
29 match Stdlib.compare x0 x1 with
30 0 -> Stdlib.compare y0 y1
31 | c -> c
32 end
33
34 module PairsMap = Map.Make(IntPairs)
35
36 let m = PairsMap.(empty |> add (0,1) "hello" |> add (1,0) "world")
37
38
39 This creates a new module PairsMap , with a new type 'a PairsMap.t of
40 maps from int * int to 'a . In this example, m contains string values
41 so its type is string PairsMap.t .
42
43
44
45
46
47 module type OrderedType = sig end
48
49
50 Input signature of the functor Map.Make .
51
52
53 module type S = sig end
54
55
56 Output signature of the functor Map.Make .
57
58
59 module Make : functor (Ord : OrderedType) -> sig end
60
61
62 Functor building an implementation of the map structure given a totally
63 ordered type.
64
65
66
67
68
69OCamldoc 2023-01-23 Map(3)