.TH "Weak.S" 3 2008-04-15 OCamldoc "OCaml library"
.SH NAME
Weak.S \- The output signature of the functor Weak.Make.
.SH Module type
Module type   Weak.S
.SH Documentation
.sp
Module type
.BI "S"
 = 
.B sig  end

.sp
The output signature of the functor 
.B Weak\&.Make
\&.
.sp

.sp

.sp
.sp
.I type data 

.sp
The type of the elements stored in the table\&.
.sp

.sp
.I type t 

.sp
The type of tables that contain elements of type 
.B data
\&.
Note that weak hash tables cannot be marshaled using
.B Pervasives\&.output_value
or the functions of the 
.B Marshal
module\&.
.sp

.sp

.I val create 
: 
.B int -> t
.sp

.B create n
creates a new empty weak hash table, of initial
size 
.B n
\&.  The table will grow as needed\&.
.sp

.sp

.I val clear 
: 
.B t -> unit
.sp
Remove all elements from the table\&.
.sp

.sp

.I val merge 
: 
.B t -> data -> data
.sp

.B merge t x
returns an instance of 
.B x
found in 
.B t
if any,
or else adds 
.B x
to 
.B t
and return 
.B x
\&.
.sp

.sp

.I val add 
: 
.B t -> data -> unit
.sp

.B add t x
adds 
.B x
to 
.B t
\&.  If there is already an instance
of 
.B x
in 
.B t
, it is unspecified which one will be
returned by subsequent calls to 
.B find
and 
.B merge
\&.
.sp

.sp

.I val remove 
: 
.B t -> data -> unit
.sp

.B remove t x
removes from 
.B t
one instance of 
.B x
\&.  Does
nothing if there is no instance of 
.B x
in 
.B t
\&.
.sp

.sp

.I val find 
: 
.B t -> data -> data
.sp

.B find t x
returns an instance of 
.B x
found in 
.B t
\&.
Raise 
.B Not_found
if there is no such element\&.
.sp

.sp

.I val find_all 
: 
.B t -> data -> data list
.sp

.B find_all t x
returns a list of all the instances of 
.B x
found in 
.B t
\&.
.sp

.sp

.I val mem 
: 
.B t -> data -> bool
.sp

.B mem t x
returns 
.B true
if there is at least one instance
of 
.B x
in 
.B t
, false otherwise\&.
.sp

.sp

.I val iter 
: 
.B (data -> unit) -> t -> unit
.sp

.B iter f t
calls 
.B f
on each element of 
.B t
, in some unspecified
order\&.  It is not specified what happens if 
.B f
tries to change
.B t
itself\&.
.sp

.sp

.I val fold 
: 
.B (data -> 'a -> 'a) -> t -> 'a -> 'a
.sp

.B fold f t init
computes 
.B (f d1 (\&.\&.\&. (f dN init)))
where
.B d1 \&.\&.\&. dN
are the elements of 
.B t
in some unspecified order\&.
It is not specified what happens if 
.B f
tries to change 
.B t
itself\&.
.sp

.sp

.I val count 
: 
.B t -> int
.sp
Count the number of elements in the table\&.  
.B count t
gives the
same result as 
.B fold (fun _ n -> n+1) t 0
but does not delay the
deallocation of the dead elements\&.
.sp

.sp

.I val stats 
: 
.B t -> int * int * int * int * int * int
.sp
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\&.
.sp

.sp
