Fix the build script.
[tatoo.git] / src / utils / misc.ml
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                               TAToo                                 *)
4 (*                                                                     *)
5 (*                     Kim Nguyen, LRI UMR8623                         *)
6 (*                   Université Paris-Sud & CNRS                       *)
7 (*                                                                     *)
8 (*  Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
9 (*  Recherche Scientifique. All rights reserved.  This file is         *)
10 (*  distributed under the terms of the GNU Lesser General Public       *)
11 (*  License, with the special exception on linking described in file   *)
12 (*  ../LICENSE.                                                        *)
13 (*                                                                     *)
14 (***********************************************************************)
15
16 (*
17   Time-stamp: <Last modified on 2013-03-04 23:00:19 CET by Kim Nguyen>
18 *)
19
20 (** Various generic signatures and generic module and functor definitions
21 *)
22 INCLUDE "utils.ml"
23
24 module HashSet (H : Hashtbl.HashedType) :
25   Common_sig.HashSet with type data = H.t =
26 struct
27   module T = Hashtbl.Make(H)
28   type data = H.t
29   type t = data T.t
30   let create = T.create
31   let add h v = T.add h v v
32   let find = T.find
33   let remove = T.remove
34   let find_all = T.find_all
35   let clear = T.clear
36   let mem = T.mem
37 end
38
39 module Pair (X : Common_sig.Type) (Y : Common_sig.Type) :
40   Common_sig.Type with type t = X.t * Y.t =
41 struct
42   type t = X.t * Y.t
43   let hash (x, y) = HASHINT2(X.hash x, Y.hash y)
44   let compare (x1, y1) (x2, y2) =
45     let r = X.compare x1 x2 in
46     if r != 0 then r else Y.compare y1 y2
47   let equal p1 p2 =
48     p1 == p2 ||
49       let x1, y1 = p1
50       and x2, y2 = p2 in X.equal x1 x2 && Y.equal y1 y2
51 end