X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=ptset.ml;h=68f7e2eda8c9a78e30deeb005cf299b606712ceb;hb=9f227961ae2219728e4cdd56e4d4c4e7165e4306;hp=4fc92d6f053cbb168771565af6d8c7cb4c86f0c5;hpb=04639fe524ee20f7f84c8b08387312d714c9bd56;p=SXSI%2Fxpathcomp.git diff --git a/ptset.ml b/ptset.ml index 4fc92d6..68f7e2e 100644 --- a/ptset.ml +++ b/ptset.ml @@ -14,14 +14,14 @@ sig val is_singleton : t -> bool val mem_union : t -> t -> t val hash : t -> int - val uid : t -> int + val uid : t -> Uid.t val uncons : t -> elt*t val from_list : elt list -> t val make : data -> t val node : t -> data end -module Make ( H : Hcons.S ) : S with type elt = H.t = +module Make ( H : Hcons.SA ) : S with type elt = H.t = struct type elt = H.t type 'a node = @@ -44,8 +44,8 @@ struct | _ -> false let hash = function | Empty -> 0 - | Leaf i -> HASHINT2(HALF_MAX_INT,H.uid i) - | Branch (b,i,l,r) -> HASHINT4(b,i,HNode.uid l, HNode.uid r) + | Leaf i -> HASHINT2(HALF_MAX_INT,Uid.to_int (H.uid i)) + | Branch (b,i,l,r) -> HASHINT4(b,i,Uid.to_int l.HNode.id, Uid.to_int r.HNode.id) end ;; @@ -79,7 +79,7 @@ struct | _ -> false let mem (k:elt) n = - let kid = H.uid k in + let kid = Uid.to_int (H.uid k) in let rec loop n = match HNode.node n with | Empty -> false | Leaf j -> k == j @@ -142,10 +142,10 @@ END let match_prefix k p m = (mask k m) == p let add k t = - let kid = H.uid k in + let kid = Uid.to_int (H.uid k) in let rec ins n = match HNode.node n with | Empty -> leaf k - | Leaf j -> if j == k then n else join kid (leaf k) (H.uid j) n + | Leaf j -> if j == k then n else join kid (leaf k) (Uid.to_int (H.uid j)) n | Branch (p,m,t0,t1) -> if match_prefix kid p m then if zero_bit kid m then @@ -158,7 +158,7 @@ END ins t let remove k t = - let kid = H.uid k in + let kid = Uid.to_int(H.uid k) in let rec rmv n = match HNode.node n with | Empty -> empty | Leaf j -> if k == j then empty else n @@ -177,7 +177,7 @@ END let equal a b = HNode.equal a b - let compare a b = (HNode.uid a) - (HNode.uid b) + let compare a b = (Uid.to_int (HNode.uid a)) - (Uid.to_int (HNode.uid b)) let rec merge s t = if (equal s t) (* This is cheap thanks to hash-consing *) @@ -386,8 +386,8 @@ struct include Make ( struct type t = int type data = t external hash : t -> int = "%identity" - external uid : t -> int = "%identity" - let equal : t -> t -> bool = (==) + external uid : t -> Uid.t = "%identity" + external equal : t -> t -> bool = "%eq" external make : t -> int = "%identity" external node : t -> int = "%identity"