X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=hlist.ml;h=0e50d617f8b4b44ad33e1be88c141a10def72214;hb=a6a05531716a001b369e018c9d2c87ce532ef163;hp=e5a4aa54818e3da6cd5099440977f74f6b4315c4;hpb=c5f06d325240c808a9be4d71e20fc01969420bb3;p=SXSI%2Fxpathcomp.git diff --git a/hlist.ml b/hlist.ml index e5a4aa5..0e50d61 100644 --- a/hlist.ml +++ b/hlist.ml @@ -13,7 +13,7 @@ module type S = sig type data = Data.t type t = Node.t val hash : t -> int - val uid : t -> int + val uid : t -> Uid.t val make : data -> t val equal : t -> t -> bool val nil : t @@ -27,6 +27,8 @@ module type S = sig val rev : t -> t val rev_map : (elt -> elt) -> t -> t val length : t -> int + + val with_id : Uid.t -> t end module Make ( H : Hcons.SA ) : S with type elt = H.t = @@ -44,15 +46,15 @@ struct | _ -> false let hash = function | Nil -> 0 - | Cons(a,aa) -> HASHINT3(PRIME3,H.uid a, aa.Node.id) + | Cons(a,aa) -> HASHINT3(PRIME3,Uid.to_int (H.uid a),Uid.to_int( aa.Node.id)) end type data = Data.t type t = Node.t let make = Node.make - let node = Node.node - let hash = Node.hash + let node x = x.Node.node + let hash x = x.Node.key let equal = Node.equal - let uid = Node.uid + let uid x= x.Node.id let nil = Node.make Nil let cons a b = Node.make (Cons(a,b)) let hd = function { Node.node = Cons(a,_) } -> a | _ -> failwith "hd" @@ -82,4 +84,7 @@ struct let rev l = fold cons l nil let rev_map f l = fold (fun x acc -> cons (f x) acc) l nil let length l = fold (fun _ c -> c+1) l 0 + + + let with_id = Node.with_id end