man-pages/man3/Weak.S.3o.html
2021-03-31 01:06:50 +01:00

370 lines
4.1 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Weak.S</TITLE>
</HEAD><BODY>
<H1>Weak.S</H1>
Section: OCaml library (3o)<BR>Updated: 2020-01-30<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
Weak.S - The output signature of the functor Weak.Make.
<A NAME="lbAC">&nbsp;</A>
<H2>Module type</H2>
Module type Weak.S
<A NAME="lbAD">&nbsp;</A>
<H2>Documentation</H2>
<P>
Module type
<B>S</B>
<BR>&nbsp;=&nbsp;
<B>sig end</B>
<P>
<P>
The output signature of the functor
<B>Weak.Make</B>
.
<P>
<P>
<P>
<P>
<P>
<I>type data </I>
<P>
<P>
The type of the elements stored in the table.
<P>
<P>
<I>type t </I>
<P>
<P>
The type of tables that contain elements of type
<B>data</B>
.
Note that weak hash sets cannot be marshaled using
<B>output_value</B>
or the functions of the
<B>Marshal</B>
module.
<P>
<P>
<P>
<I>val create </I>
:
<B>int -&gt; t</B>
<P>
<P>
<B>create n</B>
creates a new empty weak hash set, of initial
size
<B>n</B>
. The table will grow as needed.
<P>
<P>
<P>
<I>val clear </I>
:
<B>t -&gt; unit</B>
<P>
Remove all elements from the table.
<P>
<P>
<P>
<I>val merge </I>
:
<B>t -&gt; data -&gt; data</B>
<P>
<P>
<B>merge t x</B>
returns an instance of
<B>x</B>
found in
<B>t</B>
if any,
or else adds
<B>x</B>
to
<B>t</B>
and return
<B>x</B>
.
<P>
<P>
<P>
<I>val add </I>
:
<B>t -&gt; data -&gt; unit</B>
<P>
<P>
<B>add t x</B>
adds
<B>x</B>
to
<B>t</B>
. If there is already an instance
of
<B>x</B>
in
<B>t</B>
, it is unspecified which one will be
returned by subsequent calls to
<B>find</B>
and
<B>merge</B>
.
<P>
<P>
<P>
<I>val remove </I>
:
<B>t -&gt; data -&gt; unit</B>
<P>
<P>
<B>remove t x</B>
removes from
<B>t</B>
one instance of
<B>x</B>
. Does
nothing if there is no instance of
<B>x</B>
in
<B>t</B>
.
<P>
<P>
<P>
<I>val find </I>
:
<B>t -&gt; data -&gt; data</B>
<P>
<P>
<B>find t x</B>
returns an instance of
<B>x</B>
found in
<B>t</B>
.
Raise
<B>Not_found</B>
if there is no such element.
<P>
<P>
<P>
<I>val find_opt </I>
:
<B>t -&gt; data -&gt; data option</B>
<P>
<P>
<B>find_opt t x</B>
returns an instance of
<B>x</B>
found in
<B>t</B>
or
<B>None</B>
if there is no such element.
<P>
<P>
<B>Since</B>
4.05
<P>
<P>
<P>
<I>val find_all </I>
:
<B>t -&gt; data -&gt; data list</B>
<P>
<P>
<B>find_all t x</B>
returns a list of all the instances of
<B>x</B>
found in
<B>t</B>
.
<P>
<P>
<P>
<I>val mem </I>
:
<B>t -&gt; data -&gt; bool</B>
<P>
<P>
<B>mem t x</B>
returns
<B>true</B>
if there is at least one instance
of
<B>x</B>
in
<B>t</B>
, false otherwise.
<P>
<P>
<P>
<I>val iter </I>
:
<B>(data -&gt; unit) -&gt; t -&gt; unit</B>
<P>
<P>
<B>iter f t</B>
calls
<B>f</B>
on each element of
<B>t</B>
, in some unspecified
order. It is not specified what happens if
<B>f</B>
tries to change
<B>t</B>
itself.
<P>
<P>
<P>
<I>val fold </I>
:
<B>(data -&gt; 'a -&gt; 'a) -&gt; t -&gt; 'a -&gt; 'a</B>
<P>
<P>
<B>fold f t init</B>
computes
<B>(f d1 (... (f dN init)))</B>
where
<B>d1 ... dN</B>
are the elements of
<B>t</B>
in some unspecified order.
It is not specified what happens if
<B>f</B>
tries to change
<B>t</B>
itself.
<P>
<P>
<P>
<I>val count </I>
:
<B>t -&gt; int</B>
<P>
Count the number of elements in the table.
<B>count t</B>
gives the
same result as
<B>fold (fun _ n -&gt; n+1) t 0</B>
but does not delay the
deallocation of the dead elements.
<P>
<P>
<P>
<I>val stats </I>
:
<B>t -&gt; int * int * int * int * int * int</B>
<P>
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.
<P>
<P>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">Module type</A><DD>
<DT id="3"><A HREF="#lbAD">Documentation</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:06:00 GMT, March 31, 2021
</BODY>
</HTML>