Functor building an implementation of the weak hash set structure.
H.equal
can't be the physical equality, since only shallow
copies of the elements in the set are given to it.
type t
The type of tables that contain elements of type data
.
Note that weak hash sets cannot be marshaled using
Pervasives.output_value or the functions of the Marshal
module.
val create : int -> t
create n
creates a new empty weak hash set, of initial
size n
. The table will grow as needed.
add t x
adds x
to t
. If there is already an instance
of x
in t
, it is unspecified which one will be
returned by subsequent calls to find
and merge
.
iter f t
calls f
on each element of t
, in some unspecified
order. It is not specified what happens if f
tries to change
t
itself.
fold f t init
computes (f d1 (... (f dN init)))
where
d1 ... dN
are the elements of t
in some unspecified order.
It is not specified what happens if f
tries to change t
itself.
val count : t -> int
Count the number of elements in the table. count t
gives the
same result as fold (fun _ n -> n+1) t 0
but does not delay the
deallocation of the dead elements.
val stats : t -> int * int * int * int * int * int
Return statistics on the table. The numbers are, in order: table length, number of entries, sum of bucket lengths, smallest bucket length, median bucket length, biggest bucket length.