X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=ptset.ml;h=4fc92d6f053cbb168771565af6d8c7cb4c86f0c5;hb=d550133ad7afdf65c5e284c2bcf67a5bdde6faa7;hp=3fd3d39e26dc1b79b9b8b28e2a52a383c67f226b;hpb=2676d5a3bbb1e6f6a5af66477edfe3b4c849f4e7;p=SXSI%2Fxpathcomp.git diff --git a/ptset.ml b/ptset.ml index 3fd3d39..4fc92d6 100644 --- a/ptset.ml +++ b/ptset.ml @@ -36,7 +36,7 @@ struct let equal x y = match x,y with | Empty,Empty -> true - | Leaf k1, Leaf k2 -> H.equal k1 k2 + | Leaf k1, Leaf k2 -> k1 == k2 | Branch(b1,i1,l1,r1),Branch(b2,i2,l2,r2) -> b1 == b2 && i1 == i2 && (HNode.equal l1 l2) && @@ -82,7 +82,7 @@ struct let kid = H.uid k in let rec loop n = match HNode.node n with | Empty -> false - | Leaf j -> H.equal k j + | Leaf j -> k == j | Branch (p, _, l, r) -> if kid <= p then loop l else loop r in loop n @@ -145,7 +145,7 @@ END let kid = H.uid k in let rec ins n = match HNode.node n with | Empty -> leaf k - | Leaf j -> if H.equal 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) (H.uid j) n | Branch (p,m,t0,t1) -> if match_prefix kid p m then if zero_bit kid m then @@ -161,7 +161,7 @@ END let kid = H.uid k in let rec rmv n = match HNode.node n with | Empty -> empty - | Leaf j -> if H.equal k j then empty else n + | Leaf j -> if k == j then empty else n | Branch (p,m,t0,t1) -> if match_prefix kid p m then if zero_bit kid m then @@ -377,15 +377,25 @@ let from_list l = List.fold_left (fun acc e -> add e acc) empty l end -module Int : S with type elt = int - = - Make ( struct type t = int - type data = t - external hash : t -> int = "%identity" - external uid : t -> int = "%identity" - let equal : t -> t -> bool = (==) - external make : t -> int = "%identity" - external node : t -> int = "%identity" - - end - ) +module Int : sig + include S with type elt = int + val print : Format.formatter -> t -> unit +end + = +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 make : t -> int = "%identity" + external node : t -> int = "%identity" + + end + ) + let print ppf s = + Format.pp_print_string ppf "{ "; + iter (fun i -> Format.fprintf ppf "%i " i) s; + Format.pp_print_string ppf "}"; + Format.pp_print_flush ppf () + end