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 if mem h k is true, a subsequent find h k may raise Not_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 key
  • type !'a t
  • val create : int -> 'a t
  • val clear : 'a t -> unit
  • val reset : 'a t -> unit
  • val copy : 'a t -> 'a t
  • val add : 'a t -> key -> 'a -> unit
  • val remove : 'a t -> key -> unit
  • val find : 'a t -> key -> 'a
  • val find_opt : 'a t -> key -> 'a option
  • val find_all : 'a t -> key -> 'a list
  • val replace : 'a t -> key -> 'a -> unit
  • val mem : 'a t -> key -> bool
  • val length : 'a t -> int
  • val stats : 'a t -> Hashtbl.statistics
  • val add_seq : 'a t -> (key * 'a) Seq.t -> unit
  • val replace_seq : 'a t -> (key * 'a) Seq.t -> unit
  • val of_seq : (key * 'a) Seq.t -> 'a t
  • val clean : 'a t -> unit β€” remove all dead bindings. Done automatically during automatic resizing. 🧹
  • val stats_alive : 'a t -> Hashtbl.statistics β€” same as Hashtbl.SeededS.stats but 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