~ubuntu-branches/ubuntu/precise/ocaml-batteries/precise

« back to all changes in this revision

Viewing changes to src/batMultiPMap.mli

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Zacchiroli
  • Date: 2010-03-06 16:03:38 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100306160338-spvwiv3uc4jr28hw
Tags: 1.1.0-1
* New upstream release
  - major changes, "diet" version of the library
  - fix old FTBFS error, due to major code changes (Closes: #569455)
* Revamp packaging
  - adapt to new stuff shipped by upstream
  - switch from CDBS to dh
  - adapt dependencies (generally: reduce them)
* debian/patches/
  - remove old debian/patches/{debian-specific-installation-paths,
    debian-specific-info-on-doc-availability} as obsolete
  - new patch 0001-install-fix-for-bytecode-only-build: avoid
    installing *.a files with bytecode only compilation
* debian/libbatteries-ocaml-dev.links: remove file, shortend
  /usr/bin/ocaml-batteries to the top-level no longer exists
* remove debian/README.Debian (previous content is now obsolete)
* bump Standards-Version to 3.8.4 (no changes needed)
* debian/watch: update to match new upstream version convention
* debian/libbatteries-ocaml-{dev,doc}.{docs,examples}: ship only doc
  file from the root dir, other stuff is currently out of date
  (Closes: #514265)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(*
 
2
 * MultiPMap - Polymorphic maps with multiple associations
 
3
 * Copyright (C) 1996-2003 Xavier Leroy, Nicolas Cannasse, Markus Mottl
 
4
 * Copyright (C) 2008      David Teller, LIFO, Universite d'Orleans
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2.1 of the License, or (at your option) any later version,
 
10
 * with the special exception on linking described in file LICENSE.
 
11
 *
 
12
 * This library is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * Lesser General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this library; if not, write to the Free Software
 
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
20
 *)
 
21
 
 
22
(** 
 
23
    Polymorphic Multi-Map.
 
24
 
 
25
    This is a polymorphic multi-map, i.e. an association from 1 to many.
 
26
 
 
27
    @author Xavier Leroy
 
28
    @author Nicolas Cannasse
 
29
    @author Markus Mottle
 
30
    @author David Teller
 
31
*)
 
32
 
 
33
type ('a, 'b) t
 
34
 
 
35
val empty : ('a, 'b) t
 
36
(** The empty map, using [compare] as key comparison function. *)
 
37
 
 
38
val is_empty : ('a, 'b) t -> bool
 
39
(** returns true if the map is empty. *)
 
40
 
 
41
val create : ('a -> 'a -> int) -> ('b -> 'b -> int) -> ('a, 'b) t
 
42
(** creates a new empty map, using the provided function for key comparison.*)
 
43
 
 
44
val add : 'a -> 'b -> ('a, 'b) t -> ('a, 'b) t
 
45
(** [add x y m] returns a map containing the same bindings as
 
46
    [m], plus a binding of [x] to [y].*)
 
47
 
 
48
val find : 'a -> ('a, 'b) t -> 'b BatPSet.t
 
49
(** [find x m] returns the current binding of [x] in [m]*)
 
50
 
 
51
val remove_all : 'a -> ('a, 'b) t -> ('a, 'b) t
 
52
(** [remove_all x m] returns a map containing the same bindings as
 
53
    [m], except for [x] which is unbound in the returned map. *)
 
54
 
 
55
val remove : 'a -> 'b -> ('a, 'b) t -> ('a, 'b) t
 
56
(** [remove k d m] returns a map containing the same bindings as
 
57
    [m], except for [k] which is not bound to [d] anymore in the returned
 
58
    map. If [k] was not bound to [d], nothing is changed. If the operation
 
59
    removes the last binding of [k], then [k] is also removed from the set
 
60
    of keys.*)
 
61
 
 
62
val mem : 'a -> ('a, 'b) t -> bool
 
63
(** [mem x m] returns [true] if [m] contains at least a binding for [x],
 
64
    and [false] otherwise. *)
 
65
 
 
66
val iter : ('a -> 'b BatPSet.t-> unit) -> ('a, 'b) t -> unit
 
67
(** [iter f m] applies [f] to all bindings in map [m].
 
68
    [f] receives the key as first argument, and the associated value
 
69
    as second argument. The order in which the bindings are passed to
 
70
    [f] is unspecified. Only current bindings are presented to [f]:
 
71
    bindings hidden by more recent bindings are not passed to [f]. *)
 
72
 
 
73
val map : ('b BatPSet.t -> 'c BatPSet.t) -> (('b -> 'b -> int) -> ('c -> 'c -> int)) -> ('a, 'b) t -> ('a, 'c) t
 
74
(** [map f m] returns a map with same domain as [m], where the
 
75
    associated value [a] of all bindings of [m] has been
 
76
    replaced by the result of the application of [f] to [a].
 
77
    The order in which the associated values are passed to [f]
 
78
    is unspecified. *)
 
79
 
 
80
val mapi : ('a -> 'b BatPSet.t -> 'c BatPSet.t) -> (('b -> 'b -> int) -> ('c -> 'c -> int)) -> ('a, 'b) t -> ('a, 'c) t
 
81
(** Same as [map], but the function receives as arguments both the
 
82
    key and the associated value for each binding of the map. *)
 
83
 
 
84
val fold : ('b BatPSet.t -> 'c -> 'c) -> ('a , 'b) t -> 'c -> 'c
 
85
(** [fold f m a] computes [(f kN dN ... (f k1 d1 a)...)],
 
86
    where [k1 ... kN] are the keys of all bindings in [m],
 
87
    and [d1 ... dN] are the associated data.
 
88
    The order in which the bindings are presented to [f] is
 
89
    unspecified. *)
 
90
 
 
91
val foldi : ('a -> 'b BatPSet.t -> 'c -> 'c) -> ('a , 'b) t -> 'c -> 'c
 
92
(** Same as [fold], but the function receives as arguments both the
 
93
    key and the associated value for each binding of the map. *)
 
94
 
 
95
val enum : ('a, 'b) t -> ('a * 'b) BatEnum.t
 
96
(** creates an enumeration for this map. *)
 
97
 
 
98
val of_enum : ?keys:('a -> 'a -> int) -> ?data:('b -> 'b -> int) -> ('a * 'b) BatEnum.t -> ('a, 'b) t
 
99
(** creates a map from an enumeration, using the specified function
 
100
  for key comparison or [compare] by default. *)
 
101
 
 
102
(** {6 Boilerplate code}*)
 
103
 
 
104
(** {7 Printing}*)
 
105
  
 
106
val print : ?first:string -> ?last:string -> ?sep:string -> ('a BatInnerIO.output -> 'b -> unit) -> 
 
107
                                                            ('a BatInnerIO.output -> 'c -> unit) -> 
 
108
 'a BatInnerIO.output -> ('b, 'c) t -> unit