1Weak.S(3) OCaml library Weak.S(3)
2
3
4
6 Weak.S - The output signature of the functor Weak.Make.
7
9 Module type Weak.S
10
12 Module type S
13 = sig end
14
15
16 The output signature of the functor Weak.Make .
17
18
19
20
21
22
23 type data
24
25
26 The type of the elements stored in the table.
27
28
29
30 type t
31
32
33 The type of tables that contain elements of type data . Note that weak
34 hash tables cannot be marshaled using Pervasives.output_value or the
35 functions of the Marshal module.
36
37
38
39
40 val create : int -> t
41
42
43 create n creates a new empty weak hash table, of initial size n . The
44 table will grow as needed.
45
46
47
48
49 val clear : t -> unit
50
51 Remove all elements from the table.
52
53
54
55
56 val merge : t -> data -> data
57
58
59 merge t x returns an instance of x found in t if any, or else adds x to
60 t and return x .
61
62
63
64
65 val add : t -> data -> unit
66
67
68 add t x adds x to t . If there is already an instance of x in t , it
69 is unspecified which one will be returned by subsequent calls to find
70 and merge .
71
72
73
74
75 val remove : t -> data -> unit
76
77
78 remove t x removes from t one instance of x . Does nothing if there is
79 no instance of x in t .
80
81
82
83
84 val find : t -> data -> data
85
86
87 find t x returns an instance of x found in t . Raise Not_found if
88 there is no such element.
89
90
91
92
93 val find_all : t -> data -> data list
94
95
96 find_all t x returns a list of all the instances of x found in t .
97
98
99
100
101 val mem : t -> data -> bool
102
103
104 mem t x returns true if there is at least one instance of x in t ,
105 false otherwise.
106
107
108
109
110 val iter : (data -> unit) -> t -> unit
111
112
113 iter f t calls f on each element of t , in some unspecified order. It
114 is not specified what happens if f tries to change t itself.
115
116
117
118
119 val fold : (data -> 'a -> 'a) -> t -> 'a -> 'a
120
121
122 fold f t init computes (f d1 (... (f dN init))) where d1 ... dN are the
123 elements of t in some unspecified order. It is not specified what hap‐
124 pens if f tries to change t itself.
125
126
127
128
129 val count : t -> int
130
131 Count the number of elements in the table. count t gives the same
132 result as fold (fun _ n -> n+1) t 0 but does not delay the deallocation
133 of the dead elements.
134
135
136
137
138 val stats : t -> int * int * int * int * int * int
139
140 Return statistics on the table. The numbers are, in order: table
141 length, number of entries, sum of bucket lengths, smallest bucket
142 length, median bucket length, biggest bucket length.
143
144
145
146
147
148
149OCamldoc 2010-01-29 Weak.S(3)