1Ephemeron.K2.Make(3) OCaml library Ephemeron.K2.Make(3)
2
3
4
6 Ephemeron.K2.Make - Functor building an implementation of a weak hash
7 table
8
10 Module Ephemeron.K2.Make
11
13 Module Make
14 : functor (H1 : Hashtbl.HashedType) (H2 : Hashtbl.HashedType) -> sig
15 end
16
17
18 Functor building an implementation of a weak hash table
19
20
21 Parameters:
22
23 "H1"
24
25 Stdlib.Hashtbl.HashedType
26
27
28
29 "H2"
30
31 Stdlib.Hashtbl.HashedType
32
33
34
35
36
37
38
39
40
41 Propose the same interface as usual hash table. However since the bind‐
42 ings are weak, even if mem h k is true, a subsequent find h k may raise
43 Not_found because the garbage collector can run between the two.
44
45 Moreover, the table shouldn't be modified during a call to iter . Use
46 filter_map_inplace in this case.
47
48 type key
49
50
51
52
53 type 'a t
54
55
56
57
58
59 val create : int -> 'a t
60
61
62
63
64 val clear : 'a t -> unit
65
66
67
68
69 val reset : 'a t -> unit
70
71
72
73
74 val copy : 'a t -> 'a t
75
76
77
78
79 val add : 'a t -> key -> 'a -> unit
80
81
82
83
84 val remove : 'a t -> key -> unit
85
86
87
88
89 val find : 'a t -> key -> 'a
90
91
92
93
94 val find_opt : 'a t -> key -> 'a option
95
96
97
98
99 val find_all : 'a t -> key -> 'a list
100
101
102
103
104 val replace : 'a t -> key -> 'a -> unit
105
106
107
108
109 val mem : 'a t -> key -> bool
110
111
112
113
114 val iter : (key -> 'a -> unit) -> 'a t -> unit
115
116
117
118
119 val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit
120
121
122
123
124 val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
125
126
127
128
129 val length : 'a t -> int
130
131
132
133
134 val stats : 'a t -> Hashtbl.statistics
135
136
137
138
139 val to_seq : 'a t -> (key * 'a) Seq.t
140
141
142
143
144 val to_seq_keys : 'a t -> key Seq.t
145
146
147
148
149 val to_seq_values : 'a t -> 'a Seq.t
150
151
152
153
154 val add_seq : 'a t -> (key * 'a) Seq.t -> unit
155
156
157
158
159 val replace_seq : 'a t -> (key * 'a) Seq.t -> unit
160
161
162
163
164 val of_seq : (key * 'a) Seq.t -> 'a t
165
166
167
168
169 val clean : 'a t -> unit
170
171 remove all dead bindings. Done automatically during automatic resizing.
172
173
174
175 val stats_alive : 'a t -> Hashtbl.statistics
176
177 same as Hashtbl.SeededS.stats but only count the alive bindings
178
179
180
181
182
183OCamldoc 2023-01-23 Ephemeron.K2.Make(3)