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 module Make : functor (H : Hashtbl.HashedType) -> sig end
149
150
151 Functor building an implementation of a weak hash table
152
153
154 module MakeSeeded : functor (H : Hashtbl.SeededHashedType) -> sig end
155
156
157 Functor building an implementation of a weak hash table. The seed is
158 similar to the one of Hashtbl.MakeSeeded .
159
160
161
162
163
164OCamldoc 2022-02-04 Ephemeron.K1(3)