10 val equal : t -> t -> bool
11 val stats : unit -> unit
18 type t = private { id : Uid.t;
25 val equal : t -> t -> bool
26 val stats : unit -> unit
29 module Make (H : Hashtbl.HashedType) : S with type data = H.t =
31 let uid_make,uid_current,uid_set = Uid.make_maker()
33 type t = { id : Uid.t;
39 let equal t1 t2 = t1 == t2
40 module WH = Weak.Make( struct
44 let equal a b = a == b || H.equal a.node b.node
46 let pool = WH.create MED_H_SIZE
48 exception Found of Uid.t
50 let first_free_id () =
51 let mx = Uid.to_int (uid_current()) + 1 in
52 let a = Array.create mx Uid.dummy in
53 WH.iter (fun cell -> a.(Uid.to_int cell.id) <- (Uid.of_int 0)) pool;
55 for i = 0 to mx - 1 do
56 if a.(i) == Uid.dummy then raise (Found (Uid.of_int i));
64 let cell = { id = Uid.dummy; key = H.hash x; node = x } in
69 let cell = { id = uid_make(); key = H.hash x; node = x } in
75 Printf.eprintf "Hconsing statistics";
76 let l = WH.fold (fun cell acc -> (Uid.to_int cell.id)::acc) pool [] in
77 let l = List.sort compare l in
78 List.iter (fun id -> Printf.eprintf "%i\n" id) l