.TH "Ephemeron.K1" 3o 2023-09-18 OCamldoc "OCaml library" .SH NAME Ephemeron.K1 \- Ephemerons with one key. .SH Module Module Ephemeron.K1 .SH Documentation .sp Module .BI "K1" : .B sig end .sp Ephemerons with one key\&. .sp .sp .sp .I type .B ('k, 'd) .I t .sp an ephemeron with one key .sp .I val create : .B unit -> ('k, 'd) t .sp .ft B Ephemeron\&.K1\&.create () .ft R creates an ephemeron with one key\&. The data and the key are empty .sp .I val get_key : .B ('k, 'd) t -> 'k option .sp .ft B Ephemeron\&.K1\&.get_key eph .ft R returns .ft B None .ft R if the key of .ft B eph .ft R is empty, .ft B Some x .ft R (where .ft B x .ft R is the key) if it is full\&. .sp .I val get_key_copy : .B ('k, 'd) t -> 'k option .sp .ft B Ephemeron\&.K1\&.get_key_copy eph .ft R returns .ft B None .ft R if the key of .ft B eph .ft R is empty, .ft B Some x .ft R (where .ft B x .ft R is a (shallow) copy of the key) if it is full\&. This function has the same GC friendliness as .ft B Weak\&.get_copy .ft R .sp If the element is a custom block it is not copied\&. .sp .I val set_key : .B ('k, 'd) t -> 'k -> unit .sp .ft B Ephemeron\&.K1\&.set_key eph el .ft R sets the key of .ft B eph .ft R to be a (full) key to .ft B el .ft R .sp .I val unset_key : .B ('k, 'd) t -> unit .sp .ft B Ephemeron\&.K1\&.unset_key eph el .ft R sets the key of .ft B eph .ft R to be an empty key\&. Since there is only one key, the ephemeron starts behaving like a reference on the data\&. .sp .I val check_key : .B ('k, 'd) t -> bool .sp .ft B Ephemeron\&.K1\&.check_key eph .ft R returns .ft B true .ft R if the key of the .ft B eph .ft R is full, .ft B false .ft R if it is empty\&. Note that even if .ft B Ephemeron\&.K1\&.check_key eph .ft R returns .ft B true .ft R , a subsequent .ft B Ephemeron\&.K1\&.get_key .ft R .ft B eph .ft R can return .ft B None .ft R \&. .sp .I val blit_key : .B ('k, 'a) t -> ('k, 'b) t -> unit .sp .ft B Ephemeron\&.K1\&.blit_key eph1 eph2 .ft R sets the key of .ft B eph2 .ft R with the key of .ft B eph1 .ft R \&. Contrary to using .ft B Ephemeron\&.K1\&.get_key .ft R followed by .ft B Ephemeron\&.K1\&.set_key .ft R or .ft B Ephemeron\&.K1\&.unset_key .ft R this function does not prevent the incremental GC from erasing the value in its current cycle\&. .sp .I val get_data : .B ('k, 'd) t -> 'd option .sp .ft B Ephemeron\&.K1\&.get_data eph .ft R returns .ft B None .ft R if the data of .ft B eph .ft R is empty, .ft B Some x .ft R (where .ft B x .ft R is the data) if it is full\&. .sp .I val get_data_copy : .B ('k, 'd) t -> 'd option .sp .ft B Ephemeron\&.K1\&.get_data_copy eph .ft R returns .ft B None .ft R if the data of .ft B eph .ft R is empty, .ft B Some x .ft R (where .ft B x .ft R is a (shallow) copy of the data) if it is full\&. This function has the same GC friendliness as .ft B Weak\&.get_copy .ft R .sp If the element is a custom block it is not copied\&. .sp .I val set_data : .B ('k, 'd) t -> 'd -> unit .sp .ft B Ephemeron\&.K1\&.set_data eph el .ft R sets the data of .ft B eph .ft R to be a (full) data to .ft B el .ft R .sp .I val unset_data : .B ('k, 'd) t -> unit .sp .ft B Ephemeron\&.K1\&.unset_data eph el .ft R sets the key of .ft B eph .ft R to be an empty key\&. The ephemeron starts behaving like a weak pointer\&. .sp .I val check_data : .B ('k, 'd) t -> bool .sp .ft B Ephemeron\&.K1\&.check_data eph .ft R returns .ft B true .ft R if the data of the .ft B eph .ft R is full, .ft B false .ft R if it is empty\&. Note that even if .ft B Ephemeron\&.K1\&.check_data eph .ft R returns .ft B true .ft R , a subsequent .ft B Ephemeron\&.K1\&.get_data .ft R .ft B eph .ft R can return .ft B None .ft R \&. .sp .I val blit_data : .B ('a, 'd) t -> ('b, 'd) t -> unit .sp .ft B Ephemeron\&.K1\&.blit_data eph1 eph2 .ft R sets the data of .ft B eph2 .ft R with the data of .ft B eph1 .ft R \&. Contrary to using .ft B Ephemeron\&.K1\&.get_data .ft R followed by .ft B Ephemeron\&.K1\&.set_data .ft R or .ft B Ephemeron\&.K1\&.unset_data .ft R this function does not prevent the incremental GC from erasing the value in its current cycle\&. .sp .I val make : .B 'k -> 'd -> ('k, 'd) t .sp .ft B Ephemeron\&.K1\&.make k d .ft R creates an ephemeron with key .ft B k .ft R and data .ft B d .ft R \&. .sp .I val query : .B ('k, 'd) t -> 'k -> 'd option .sp .ft B Ephemeron\&.K1\&.query eph key .ft R returns .ft B Some x .ft R (where .ft B x .ft R is the ephemeron\&'s data) if .ft B key .ft R is physically equal to .ft B eph .ft R \&'s key, and .ft B None .ft R if .ft B eph .ft R is empty or .ft B key .ft R is not equal to .ft B eph .ft R \&'s key\&. .sp .I module Make : .B functor (H : Hashtbl.HashedType) -> sig end .sp Functor building an implementation of a weak hash table .sp .I module MakeSeeded : .B functor (H : Hashtbl.SeededHashedType) -> sig end .sp Functor building an implementation of a weak hash table\&. The seed is similar to the one of .ft B Hashtbl\&.MakeSeeded .ft R \&. .sp .I module Bucket : .B sig end .sp .sp