Ephemeron.K2.Make(3)
π NAME π
Ephemeron.K2.Make β functor building an implementation of a weak hash table π
β¨
This is the Ephemeron.K2.Make(3) page from the OCaml library, and she's lowkey iconic.
π§© Module π§©
Module Ephemeron.K2.Make
π Documentation π
πΈ Module Make
: (H1 : Hashtbl.HashedType) (H2 : Hashtbl.HashedType) -> sig end
Functor building an implementation of a weak hash table.
Parameters:
"H1"βStdlib.Hashtbl.HashedType"H2"βStdlib.Hashtbl.HashedType
Okay bestie, the tea β: she proposes the same interface as a usual hash table. But β and this is the plot twist β the bindings are weak. So even if mem h k is true, a subsequent find h k may raise Not_found because the garbage collector can run between the two. Literally the GC can pop in between, no cap. ππ
Here's the exact roster, no edits, no omissions, periodt:
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 π
That's the whole page, bestie! π Shoutout to OCamldoc for the source/version and the date stamp 2026-06-22 β this iconic little manual page is Ephemeron.K2.Make(3) and it ate. ππ«Ά
π¦ 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