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

.sp
Output signature of the functor 
.B Map\&.Make
\&.
.sp

.sp

.sp
.sp
.I type key 

.sp
The type of the map keys\&.
.sp

.sp
.I type 
.B +'a
.I t 

.sp
The type of maps from type 
.B key
to type 
.B 'a
\&.
.sp

.sp

.I val empty 
: 
.B 'a t
.sp
The empty map\&.
.sp

.sp

.I val is_empty 
: 
.B 'a t -> bool
.sp
Test whether a map is empty or not\&.
.sp

.sp

.I val add 
: 
.B key -> 'a -> 'a t -> 'a t
.sp

.B add x y m
returns a map containing the same bindings as
.B m
, plus a binding of 
.B x
to 
.B y
\&. If 
.B x
was already bound
in 
.B m
, its previous binding disappears\&.
.sp

.sp

.I val find 
: 
.B key -> 'a t -> 'a
.sp

.B find x m
returns the current binding of 
.B x
in 
.B m
,
or raises 
.B Not_found
if no such binding exists\&.
.sp

.sp

.I val remove 
: 
.B key -> 'a t -> 'a t
.sp

.B remove x m
returns a map containing the same bindings as
.B m
, except for 
.B x
which is unbound in the returned map\&.
.sp

.sp

.I val mem 
: 
.B key -> 'a t -> bool
.sp

.B mem x m
returns 
.B true
if 
.B m
contains a binding for 
.B x
,
and 
.B false
otherwise\&.
.sp

.sp

.I val iter 
: 
.B (key -> 'a -> unit) -> 'a t -> unit
.sp

.B iter f m
applies 
.B f
to all bindings in map 
.B m
\&.
.B f
receives the key as first argument, and the associated value
as second argument\&.  The bindings are passed to 
.B f
in increasing
order with respect to the ordering over the type of the keys\&.
Only current bindings are presented to 
.B f
:
bindings hidden by more recent bindings are not passed to 
.B f
\&.
.sp

.sp

.I val map 
: 
.B ('a -> 'b) -> 'a t -> 'b t
.sp

.B map f m
returns a map with same domain as 
.B m
, where the
associated value 
.B a
of all bindings of 
.B m
has been
replaced by the result of the application of 
.B f
to 
.B a
\&.
The bindings are passed to 
.B f
in increasing order
with respect to the ordering over the type of the keys\&.
.sp

.sp

.I val mapi 
: 
.B (key -> 'a -> 'b) -> 'a t -> 'b t
.sp
Same as 
.B Map\&.S\&.map
, but the function receives as arguments both the
key and the associated value for each binding of the map\&.
.sp

.sp

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

.B fold f m a
computes 
.B (f kN dN \&.\&.\&. (f k1 d1 a)\&.\&.\&.)
,
where 
.B k1 \&.\&.\&. kN
are the keys of all bindings in 
.B m
(in increasing order), and 
.B d1 \&.\&.\&. dN
are the associated data\&.
.sp

.sp

.I val compare 
: 
.B ('a -> 'a -> int) -> 'a t -> 'a t -> int
.sp
Total ordering between maps\&.  The first argument is a total ordering
used to compare data associated with equal keys in the two maps\&.
.sp

.sp

.I val equal 
: 
.B ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
.sp

.B equal cmp m1 m2
tests whether the maps 
.B m1
and 
.B m2
are
equal, that is, contain equal keys and associate them with
equal data\&.  
.B cmp
is the equality predicate used to compare
the data associated with the keys\&.
.sp

.sp
