145 lines
2.3 KiB
HTML
145 lines
2.3 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Map</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Map</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>
|
|
|
|
Map - Association tables over ordered types.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>Module</H2>
|
|
|
|
Module Map
|
|
<A NAME="lbAD"> </A>
|
|
<H2>Documentation</H2>
|
|
|
|
<P>
|
|
Module
|
|
<B>Map</B>
|
|
|
|
<BR> :
|
|
<B>sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
Association tables over ordered types.
|
|
<P>
|
|
This module implements applicative association tables, also known as
|
|
finite maps or dictionaries, given a total ordering function
|
|
over the keys.
|
|
All operations over maps are purely applicative (no side-effects).
|
|
The implementation uses balanced binary trees, and therefore searching
|
|
and insertion take time logarithmic in the size of the map.
|
|
<P>
|
|
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 PairsMap = Map.Make(IntPairs)</B>
|
|
|
|
|
|
|
|
<B>let m = PairsMap.(empty |> add (0,1) hello |> add (1,0) world)</B>
|
|
|
|
|
|
|
|
<B><P>
|
|
</B>
|
|
|
|
This creates a new module
|
|
<B>PairsMap</B>
|
|
|
|
, with a new type
|
|
<B>'a PairsMap.t</B>
|
|
|
|
of maps from
|
|
<B>int * int</B>
|
|
|
|
to
|
|
<B>'a</B>
|
|
|
|
. In this example,
|
|
<B>m</B>
|
|
|
|
contains
|
|
<B>string</B>
|
|
|
|
values so its type is
|
|
<B>string PairsMap.t</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>module type OrderedType = </I>
|
|
|
|
<B>sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
Input signature of the functor
|
|
<B>Map.Make</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<I>module type S = </I>
|
|
|
|
<B>sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
Output signature of the functor
|
|
<B>Map.Make</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<I>module Make : </I>
|
|
|
|
<B>functor (Ord : OrderedType) -> sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
Functor building an implementation of the map 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:47 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|