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