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