|
rpm-build |
0f2925 |
(*
|
|
rpm-build |
0f2925 |
* PMap - Polymorphic maps
|
|
rpm-build |
0f2925 |
* Copyright (C) 1996-2003 Xavier Leroy, Nicolas Cannasse, Markus Mottl
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* This library is free software; you can redistribute it and/or
|
|
rpm-build |
0f2925 |
* modify it under the terms of the GNU Lesser General Public
|
|
rpm-build |
0f2925 |
* License as published by the Free Software Foundation; either
|
|
rpm-build |
0f2925 |
* version 2.1 of the License, or (at your option) any later version,
|
|
rpm-build |
0f2925 |
* with the special exception on linking described in file LICENSE.
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* This library is distributed in the hope that it will be useful,
|
|
rpm-build |
0f2925 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
rpm-build |
0f2925 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
rpm-build |
0f2925 |
* Lesser General Public License for more details.
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* You should have received a copy of the GNU Lesser General Public
|
|
rpm-build |
0f2925 |
* License along with this library; if not, write to the Free Software
|
|
rpm-build |
0f2925 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
rpm-build |
0f2925 |
*)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
(** Polymorphic Map.
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
This is a polymorphic map, similar to standard library [Map] module
|
|
rpm-build |
0f2925 |
but in a defunctorized style.
|
|
rpm-build |
0f2925 |
*)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
type ('a, 'b) t
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val empty : ('a, 'b) t
|
|
rpm-build |
0f2925 |
(** The empty map, using [compare] as key comparison function. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val is_empty : ('a, 'b) t -> bool
|
|
rpm-build |
0f2925 |
(** returns true if the map is empty. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val create : ('a -> 'a -> int) -> ('a, 'b) t
|
|
rpm-build |
0f2925 |
(** creates a new empty map, using the provided function for key comparison.*)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val add : 'a -> 'b -> ('a, 'b) t -> ('a, 'b) t
|
|
rpm-build |
0f2925 |
(** [add x y m] returns a map containing the same bindings as
|
|
rpm-build |
0f2925 |
[m], plus a binding of [x] to [y]. If [x] was already bound
|
|
rpm-build |
0f2925 |
in [m], its previous binding disappears. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val find : 'a -> ('a, 'b) t -> 'b
|
|
rpm-build |
0f2925 |
(** [find x m] returns the current binding of [x] in [m],
|
|
rpm-build |
0f2925 |
or raises [Not_found] if no such binding exists. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val remove : 'a -> ('a, 'b) t -> ('a, 'b) t
|
|
rpm-build |
0f2925 |
(** [remove x m] returns a map containing the same bindings as
|
|
rpm-build |
0f2925 |
[m], except for [x] which is unbound in the returned map. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val mem : 'a -> ('a, 'b) t -> bool
|
|
rpm-build |
0f2925 |
(** [mem x m] returns [true] if [m] contains a binding for [x],
|
|
rpm-build |
0f2925 |
and [false] otherwise. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val exists : 'a -> ('a, 'b) t -> bool
|
|
rpm-build |
0f2925 |
(** same as [mem]. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val iter : ('a -> 'b -> unit) -> ('a, 'b) t -> unit
|
|
rpm-build |
0f2925 |
(** [iter f m] applies [f] to all bindings in map [m].
|
|
rpm-build |
0f2925 |
[f] receives the key as first argument, and the associated value
|
|
rpm-build |
0f2925 |
as second argument. The order in which the bindings are passed to
|
|
rpm-build |
0f2925 |
[f] is unspecified. Only current bindings are presented to [f]:
|
|
rpm-build |
0f2925 |
bindings hidden by more recent bindings are not passed to [f]. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val map : ('b -> 'c) -> ('a, 'b) t -> ('a, 'c) t
|
|
rpm-build |
0f2925 |
(** [map f m] returns a map with same domain as [m], where the
|
|
rpm-build |
0f2925 |
associated value [a] of all bindings of [m] has been
|
|
rpm-build |
0f2925 |
replaced by the result of the application of [f] to [a].
|
|
rpm-build |
0f2925 |
The order in which the associated values are passed to [f]
|
|
rpm-build |
0f2925 |
is unspecified. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val mapi : ('a -> 'b -> 'c) -> ('a, 'b) t -> ('a, 'c) t
|
|
rpm-build |
0f2925 |
(** Same as [map], but the function receives as arguments both the
|
|
rpm-build |
0f2925 |
key and the associated value for each binding of the map. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val fold : ('b -> 'c -> 'c) -> ('a , 'b) t -> 'c -> 'c
|
|
rpm-build |
0f2925 |
(** [fold f m a] computes [(f kN dN ... (f k1 d1 a)...)],
|
|
rpm-build |
0f2925 |
where [k1 ... kN] are the keys of all bindings in [m],
|
|
rpm-build |
0f2925 |
and [d1 ... dN] are the associated data.
|
|
rpm-build |
0f2925 |
The order in which the bindings are presented to [f] is
|
|
rpm-build |
0f2925 |
unspecified. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val foldi : ('a -> 'b -> 'c -> 'c) -> ('a , 'b) t -> 'c -> 'c
|
|
rpm-build |
0f2925 |
(** Same as [fold], but the function receives as arguments both the
|
|
rpm-build |
0f2925 |
key and the associated value for each binding of the map. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val enum : ('a, 'b) t -> ('a * 'b) Enum.t
|
|
rpm-build |
0f2925 |
(** creates an enumeration for this map. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
val of_enum : ?cmp:('a -> 'a -> int) -> ('a * 'b) Enum.t -> ('a, 'b) t
|
|
rpm-build |
0f2925 |
(** creates a map from an enumeration, using the specified function
|
|
rpm-build |
0f2925 |
for key comparison or [compare] by default. *)
|