X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=blobdiff_plain;f=src%2Fmisc.ml;fp=src%2Fmisc.ml;h=f8156b0d22191f8cfe0da534b6b0458a61c2630c;hp=0000000000000000000000000000000000000000;hb=b00bff88c7902e828804c06b7f9dc55222fdc84e;hpb=03b6a364e7240ca827585e7baff225a0aaa33bc6 diff --git a/src/misc.ml b/src/misc.ml new file mode 100644 index 0000000..f8156b0 --- /dev/null +++ b/src/misc.ml @@ -0,0 +1,51 @@ +(***********************************************************************) +(* *) +(* TAToo *) +(* *) +(* Kim Nguyen, LRI UMR8623 *) +(* Université Paris-Sud & CNRS *) +(* *) +(* Copyright 2010-2012 Université Paris-Sud and Centre National de la *) +(* Recherche Scientifique. All rights reserved. This file is *) +(* distributed under the terms of the GNU Lesser General Public *) +(* License, with the special exception on linking described in file *) +(* ../LICENSE. *) +(* *) +(***********************************************************************) + +(* + Time-stamp: +*) + +(** Various generic signatures and generic module and functor definitions +*) +INCLUDE "utils.ml" + +module HashSet (H : Hashtbl.HashedType) : + Common_sig.HashSet with type data = H.t = +struct + module T = Hashtbl.Make(H) + type data = H.t + type t = data T.t + let create = T.create + let add h v = T.add h v v + let find = T.find + let remove = T.remove + let find_all = T.find_all + let clear = T.clear + let mem = T.mem +end + +module Pair (X : Common_sig.Type) (Y : Common_sig.Type) : + Common_sig.Type with type t = X.t * Y.t = +struct + type t = X.t * Y.t + let hash (x, y) = HASHINT2(X.hash x, Y.hash y) + let compare (x1, y1) (x2, y2) = + let r = X.compare x1 x2 in + if r != 0 then r else Y.compare y1 y2 + let equal p1 p2 = + p1 == p2 || + let x1, y1 = p1 + and x2, y2 = p2 in X.equal x1 x2 && Y.equal y1 y2 +end