1Set(3)                             OCamldoc                             Set(3)
2
3
4

NAME

6       Set - Sets over ordered types.
7

Module

9       Module   Set
10

Documentation

12       Module Set
13        : sig end
14
15
16       Sets over ordered types.
17
18       This  module  implements the set data structure, given a total ordering
19       function over the set elements. All operations  over  sets  are  purely
20       applicative (no side-effects).  The implementation uses balanced binary
21       trees, and is therefore reasonably efficient: insertion and  membership
22       take time logarithmic in the size of the set, for instance.
23
24       The  Set.Make  functor constructs implementations for any type, given a
25       compare function.  For instance: module IntPairs = struct type t =  int
26       * int let compare (x0,y0) (x1,y1) = match Pervasives.compare x0 x1 with
27       0 ->  Pervasives.compare  y0  y1  |  c  ->  c  end  module  PairsSet  =
28       Set.Make(IntPairs) let m = PairsSet.(empty |> add (2,3) |> add (5,7) |>
29       add (11,13))
30
31       This creates a new module PairsSet , with a new type PairsSet.t of sets
32       of int * int .
33
34
35
36
37
38       module type OrderedType = sig end
39
40
41       Input signature of the functor Set.Make .
42
43
44       module type S = sig end
45
46
47       Output signature of the functor Set.Make .
48
49
50       module Make : functor (Ord : OrderedType) -> sig end
51
52
53       Functor building an implementation of the set structure given a totally
54       ordered type.
55
56
57
58
59
602018-04-14                          source:                             Set(3)
Impressum