Ephemeron.K1.Make(3)
β¨ NAME β¨
Ephemeron.K1.Make(3) is a page from the OCaml library manual, and it is literally the blueprint for a functor building an implementation of a weak hash table. π
π§ Module π§
Module Ephemeron.K1.Make.
π¦ Documentation π¦
π Module Make π
Module Make
: (H : Hashtbl.HashedType) -> sig end
It is a functor building an implementation of a weak hash table. Yes bestie, that is the whole assignment, and it ate. π
πΈ Parameters πΈ
"H"βStdlib.Hashtbl.HashedType
β οΈ It proposes the same interface as a usual hash table. But since the bindings are weak, even ifmem h kistrue, a subsequentfind h kmay raiseNot_foundβ because the garbage collector can run between the two calls. π This is the weak-binding caveat, fr fr.
π Types and values π
Here is the full roster, no cuts, no skips:
type keytype !'a tval create : int -> 'a tval clear : 'a t -> unitval reset : 'a t -> unitval copy : 'a t -> 'a tval add : 'a t -> key -> 'a -> unitval remove : 'a t -> key -> unitval find : 'a t -> key -> 'aval find_opt : 'a t -> key -> 'a optionval find_all : 'a t -> key -> 'a listval replace : 'a t -> key -> 'a -> unitval mem : 'a t -> key -> boolval length : 'a t -> intval stats : 'a t -> Hashtbl.statisticsval add_seq : 'a t -> (key * 'a) Seq.t -> unitval replace_seq : 'a t -> (key * 'a) Seq.t -> unitval of_seq : (key * 'a) Seq.t -> 'a tval clean : 'a t -> unitβ remove all dead bindings. Done automatically during automatic resizing. π§Ήval stats_alive : 'a t -> Hashtbl.statisticsβ same asHashtbl.SeededS.statsbut only count the alive bindings.
Signed with love, zero missing details, and main-character energy by OCamldoc, dated 2026-06-22. Bye bestie, go build that weak hash table ππ«Ά
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms