Coccinelle release 1.0.0-rc14
[bpt/coccinelle.git] / bundles / extlib / extlib-1.5.2 / extHashtbl.mli
1 (*
2 * ExtHashtbl - extra functions over hashtables.
3 * Copyright (C) 2003 Nicolas Cannasse
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version,
9 * with the special exception on linking described in file LICENSE.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *)
20
21 (** Extra functions over hashtables. *)
22
23 module Hashtbl :
24 (** The wrapper module *)
25 sig
26
27 type ('a,'b) t = ('a,'b) Hashtbl.t
28 (** The type of a hashtable. *)
29
30 (** {6 New Functions} *)
31
32 val exists : ('a,'b) t -> 'a -> bool
33 (** [exists h k] returns true is at least one item with key [k] is
34 found in the hashtable. *)
35
36 val keys : ('a,'b) t -> 'a Enum.t
37 (** Return an enumeration of all the keys of a hashtable.
38 If the key is in the Hashtable multiple times, all occurrences
39 will be returned. *)
40
41 val values : ('a,'b) t -> 'b Enum.t
42 (** Return an enumeration of all the values of a hashtable. *)
43
44 val enum : ('a, 'b) t -> ('a * 'b) Enum.t
45 (** Return an enumeration of (key,value) pairs of a hashtable. *)
46
47 val of_enum : ('a * 'b) Enum.t -> ('a, 'b) t
48 (** Create a hashtable from a (key,value) enumeration. *)
49
50 val find_default : ('a,'b) t -> 'a -> 'b -> 'b
51 (** Find a binding for the key, and return a default
52 value if not found *)
53
54 val find_option : ('a,'b) Hashtbl.t -> 'a -> 'b option
55 (** Find a binding for the key, or return [None] if no
56 value is found *)
57
58 val remove_all : ('a,'b) t -> 'a -> unit
59 (** Remove all bindings for the given key *)
60
61 val map : ('b -> 'c) -> ('a,'b) t -> ('a,'c) t
62 (** [map f x] creates a new hashtable with the same
63 keys as [x], but with the function [f] applied to
64 all the values *)
65
66 val length : ('a,'b) t -> int
67 (** Return the number of elements inserted into the Hashtbl
68 (including duplicates) *)
69
70 (** {6 Older Functions} *)
71
72 (** Please refer to the Ocaml Manual for documentation of these
73 functions. (note : functor support removed to avoid code
74 duplication). *)
75
76 val create : int -> ('a, 'b) t
77 val clear : ('a, 'b) t -> unit
78 val add : ('a, 'b) t -> 'a -> 'b -> unit
79 val copy : ('a, 'b) t -> ('a, 'b) t
80 val find : ('a, 'b) t -> 'a -> 'b
81 val find_all : ('a, 'b) t -> 'a -> 'b list
82 val mem : ('a, 'b) t -> 'a -> bool
83 val remove : ('a, 'b) t -> 'a -> unit
84 val replace : ('a, 'b) t -> 'a -> 'b -> unit
85 val iter : ('a -> 'b -> unit) -> ('a, 'b) t -> unit
86 val fold : ('a -> 'b -> 'c -> 'c) -> ('a, 'b) t -> 'c -> 'c
87 val hash : 'a -> int
88
89 end