1Ephemeron.K1(3) OCaml library Ephemeron.K1(3)
2
3
4
6 Ephemeron.K1 - Ephemerons with one key.
7
9 Module Ephemeron.K1
10
12 Module K1
13 : sig end
14
15
16 Ephemerons with one key.
17
18
19
20
21
22 type ('k, 'd) t
23
24
25 an ephemeron with one key
26
27
28
29 val create : unit -> ('k, 'd) t
30
31
32 Ephemeron.K1.create () creates an ephemeron with one key. The data and
33 the key are empty
34
35
36
37 val get_key : ('k, 'd) t -> 'k option
38
39
40 Ephemeron.K1.get_key eph returns None if the key of eph is empty, Some
41 x (where x is the key) if it is full.
42
43
44
45 val get_key_copy : ('k, 'd) t -> 'k option
46
47
48 Ephemeron.K1.get_key_copy eph returns None if the key of eph is empty,
49 Some x (where x is a (shallow) copy of the key) if it is full. This
50 function has the same GC friendliness as Weak.get_copy
51
52 If the element is a custom block it is not copied.
53
54
55
56 val set_key : ('k, 'd) t -> 'k -> unit
57
58
59 Ephemeron.K1.set_key eph el sets the key of eph to be a (full) key to
60 el
61
62
63
64
65 val unset_key : ('k, 'd) t -> unit
66
67
68 Ephemeron.K1.unset_key eph el sets the key of eph to be an empty key.
69 Since there is only one key, the ephemeron starts behaving like a ref‐
70 erence on the data.
71
72
73
74 val check_key : ('k, 'd) t -> bool
75
76
77 Ephemeron.K1.check_key eph returns true if the key of the eph is full,
78 false if it is empty. Note that even if Ephemeron.K1.check_key eph re‐
79 turns true , a subsequent Ephemeron.K1.get_key eph can return None .
80
81
82
83 val blit_key : ('k, 'a) t -> ('k, 'b) t -> unit
84
85
86 Ephemeron.K1.blit_key eph1 eph2 sets the key of eph2 with the key of
87 eph1 . Contrary to using Ephemeron.K1.get_key followed by
88 Ephemeron.K1.set_key or Ephemeron.K1.unset_key this function does not
89 prevent the incremental GC from erasing the value in its current cycle.
90
91
92
93 val get_data : ('k, 'd) t -> 'd option
94
95
96 Ephemeron.K1.get_data eph returns None if the data of eph is empty,
97 Some x (where x is the data) if it is full.
98
99
100
101 val get_data_copy : ('k, 'd) t -> 'd option
102
103
104 Ephemeron.K1.get_data_copy eph returns None if the data of eph is
105 empty, Some x (where x is a (shallow) copy of the data) if it is full.
106 This function has the same GC friendliness as Weak.get_copy
107
108 If the element is a custom block it is not copied.
109
110
111
112 val set_data : ('k, 'd) t -> 'd -> unit
113
114
115 Ephemeron.K1.set_data eph el sets the data of eph to be a (full) data
116 to el
117
118
119
120
121 val unset_data : ('k, 'd) t -> unit
122
123
124 Ephemeron.K1.unset_data eph el sets the key of eph to be an empty key.
125 The ephemeron starts behaving like a weak pointer.
126
127
128
129 val check_data : ('k, 'd) t -> bool
130
131
132 Ephemeron.K1.check_data eph returns true if the data of the eph is
133 full, false if it is empty. Note that even if Ephemeron.K1.check_data
134 eph returns true , a subsequent Ephemeron.K1.get_data eph can return
135 None .
136
137
138
139 val blit_data : ('a, 'd) t -> ('b, 'd) t -> unit
140
141
142 Ephemeron.K1.blit_data eph1 eph2 sets the data of eph2 with the data of
143 eph1 . Contrary to using Ephemeron.K1.get_data followed by
144 Ephemeron.K1.set_data or Ephemeron.K1.unset_data this function does not
145 prevent the incremental GC from erasing the value in its current cycle.
146
147
148
149 val make : 'k -> 'd -> ('k, 'd) t
150
151
152 Ephemeron.K1.make k d creates an ephemeron with key k and data d .
153
154
155
156 val query : ('k, 'd) t -> 'k -> 'd option
157
158
159 Ephemeron.K1.query eph key returns Some x (where x is the ephemeron's
160 data) if key is physically equal to eph 's key, and None if eph is
161 empty or key is not equal to eph 's key.
162
163
164 module Make : functor (H : Hashtbl.HashedType) -> sig end
165
166
167 Functor building an implementation of a weak hash table
168
169
170 module MakeSeeded : functor (H : Hashtbl.SeededHashedType) -> sig end
171
172
173 Functor building an implementation of a weak hash table. The seed is
174 similar to the one of Hashtbl.MakeSeeded .
175
176
177 module Bucket : sig end
178
179
180
181
182
183
184
185OCamldoc 2022-07-22 Ephemeron.K1(3)