Add a bullet symbol.
[tatoo.git] / src / 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 (** Various generic signatures and generic module and functor definitions
17 *)
18 INCLUDE "utils.ml"
19
20 module HashSet (H : Hashtbl.HashedType) :
21   Common_sig.HashSet with type data = H.t =
22 struct
23   module T = Hashtbl.Make(H)
24   type data = H.t
25   type t = data T.t
26   let create = T.create
27   let add h v = T.add h v v
28   let find = T.find
29   let remove = T.remove
30   let find_all = T.find_all
31   let clear = T.clear
32   let mem = T.mem
33 end
34
35 module Pair (X : Common_sig.Type) (Y : Common_sig.Type) :
36   Common_sig.Type with type t = X.t * Y.t =
37 struct
38   type t = X.t * Y.t
39   let hash (x, y) = HASHINT2(X.hash x, Y.hash y)
40   let compare (x1, y1) (x2, y2) =
41     let r = X.compare x1 x2 in
42     if r != 0 then r else Y.compare y1 y2
43   let equal p1 p2 =
44     p1 == p2 ||
45       let x1, y1 = p1
46       and x2, y2 = p2 in X.equal x1 x2 && Y.equal y1 y2
47 end
48
49 external int_of_bool : bool -> int = "%identity"