140 lines
2.2 KiB
HTML
140 lines
2.2 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Set</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Set</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"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Set - Sets over ordered types.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>Module</H2>
|
|
|
|
Module Set
|
|
<A NAME="lbAD"> </A>
|
|
<H2>Documentation</H2>
|
|
|
|
<P>
|
|
Module
|
|
<B>Set</B>
|
|
|
|
<BR> :
|
|
<B>sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
Sets over ordered types.
|
|
<P>
|
|
This module implements the set data structure, given a total ordering
|
|
function over the set elements. All operations over sets
|
|
are purely applicative (no side-effects).
|
|
The implementation uses balanced binary trees, and is therefore
|
|
reasonably efficient: insertion and membership take time
|
|
logarithmic in the size of the set, for instance.
|
|
<P>
|
|
The
|
|
<B>Set.Make</B>
|
|
|
|
functor constructs implementations for any type, given a
|
|
<B>compare</B>
|
|
|
|
function.
|
|
For instance:
|
|
<B>module IntPairs =</B>
|
|
|
|
|
|
|
|
<B>struct</B>
|
|
|
|
<B>type t = int * int</B>
|
|
|
|
<B>let compare (x0,y0) (x1,y1) =</B>
|
|
|
|
<B>match Stdlib.compare x0 x1 with</B>
|
|
|
|
<B>0 -> Stdlib.compare y0 y1</B>
|
|
|
|
<B>| c -> c</B>
|
|
|
|
<B>end</B>
|
|
|
|
<B>module PairsSet = Set.Make(IntPairs)</B>
|
|
|
|
|
|
|
|
<B>let m = PairsSet.(empty |> add (2,3) |> add (5,7) |> add (11,13))</B>
|
|
|
|
|
|
|
|
<B><P>
|
|
</B>
|
|
|
|
This creates a new module
|
|
<B>PairsSet</B>
|
|
|
|
, with a new type
|
|
<B>PairsSet.t</B>
|
|
|
|
of sets of
|
|
<B>int * int</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>module type OrderedType = </I>
|
|
|
|
<B>sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
Input signature of the functor
|
|
<B>Set.Make</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<I>module type S = </I>
|
|
|
|
<B>sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
Output signature of the functor
|
|
<B>Set.Make</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<I>module Make : </I>
|
|
|
|
<B>functor (Ord : OrderedType) -> sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
Functor building an implementation of the set structure
|
|
given a totally ordered type.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">Module</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:05:56 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|