X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=blobdiff_plain;f=src%2Futils%2Fmisc.ml;fp=src%2Futils%2Fmisc.ml;h=960ec468aa003c6e73c49bb63a056742ceb0c6cc;hp=0000000000000000000000000000000000000000;hb=30bc0bb1291426e5e26eb2dee1ffc41e4c246349;hpb=d9c0e4863807eaf472e875a4bad35cfefe985c95 diff --git a/src/utils/misc.ml b/src/utils/misc.ml new file mode 100644 index 0000000..960ec46 --- /dev/null +++ b/src/utils/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) : + Sigs.AUX.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 : Sigs.AUX.Type) (Y : Sigs.AUX.Type) : + Sigs.AUX.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