X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=finiteCofinite.ml;h=dc924cb92c946a0d2de7050e2a26c40226964891;hb=0c2338bfcdae0df1c68112a10247dc4e68a483ff;hp=29ce60cf7638302c134d72ee36a620d63c579e28;hpb=6a7025fee3c050eff58baa536a14d80baf5c1b87;p=SXSI%2Fxpathcomp.git diff --git a/finiteCofinite.ml b/finiteCofinite.ml index 29ce60c..dc924cb 100644 --- a/finiteCofinite.ml +++ b/finiteCofinite.ml @@ -40,7 +40,7 @@ sig val choose : t -> elt val hash : t -> int val equal : t -> t -> bool - val uid : t -> int + val uid : t -> Uid.t val positive : t -> set val negative : t -> set val inj_positive : set -> t @@ -54,15 +54,15 @@ struct type node = Finite of E.t | CoFinite of E.t type set = E.t module Node = Hcons.Make(struct - type t = node - let equal a b = - match a,b with - (Finite(s1),Finite(s2)) - | (CoFinite(s1),CoFinite(s2)) -> E.equal s1 s2 - | _ -> false - let hash = function - Finite (s) -> HASHINT2(PRIME2,E.hash s) - | CoFinite(s) -> HASHINT2(PRIME7,E.hash s) + type t = node + let equal a b = + match a,b with + (Finite(s1),Finite(s2)) + | (CoFinite(s1),CoFinite(s2)) -> E.equal s1 s2 + | _ -> false + let hash = function + Finite (s) -> (E.hash s) lsl 1 + | CoFinite(s) -> ((E.hash s) lsl 1 ) lor 1 end) type t = Node.t let empty = Node.make (Finite E.empty) @@ -90,9 +90,11 @@ struct | CoFinite s -> not (E.mem x s) let singleton x = finite (E.singleton x) + let add e t = match t.Node.node with | Finite s -> finite (E.add e s) | CoFinite s -> cofinite (E.remove e s) + let remove e t = match t.Node.node with | Finite s -> finite (E.remove e s) | CoFinite s -> cofinite (E.add e s)