Weak.Make(3)
π NAME π
Weak.Make(3) β from the OCaml library, bestie! This is the functor that builds an implementation of the weak hash set structure. Literally iconic. π
π§© Module π§©
Module Weak.Make β yep, that's the module, and it's giving main character energy. β¨
π Documentation π
πΈ Module Make πΈ
Module Make
: (H : Hashtbl.HashedType) -> sig end
Okay so this functor builds an implementation of the weak hash set structure. Real talk: H.equal can't be the physical equality, since only shallow copies of the elements in the set are given to it. No cap. π
π«Ά Parameters π«Ά
"H"βStdlib.Hashtbl.HashedType. That's the parameter, bestie.type dataβ the type of the elements stored in the table. πtype tβ the type of tables that contain elements of typedata. Note that weak hash sets cannot be marshaled usingoutput_valueor the functions of theMarshalmodule. That's a hard no. πval create : int -> tβcreate ncreates a new empty weak hash set, of initial sizen. The table will grow as needed. β¨val clear : t -> unitβ remove all elements from the table. Clean slate vibes. π§Όval merge : t -> data -> dataβmerge t xreturns an instance ofxfound intif any, or else addsxtotand returnsx. π«Άval add : t -> data -> unitβadd t xaddsxtot. If there is already an instance ofxint, it is unspecified which one will be returned by subsequent calls tofindandmerge. So don't @ me about which twin you get. πval remove : t -> data -> unitβremove t xremoves fromtone instance ofx. Does nothing if there is no instance ofxint. π«‘val find : t -> data -> dataβfind t xreturns an instance ofxfound int. RaisesNot_foundif there is no such element. π¨val find_opt : t -> data -> data optionβfind_opt t xreturns an instance ofxfound intorNoneif there is no such element. Since 4.05. ποΈval find_all : t -> data -> data listβfind_all t xreturns a list of all the instances ofxfound int. All of them. Obsessed. πval mem : t -> data -> boolβmem t xreturnstrueif there is at least one instance ofxint,falseotherwise. βval iter : (data -> unit) -> t -> unitβiter f tcallsfon each element oft, in some unspecified order. It is not specified what happens ifftries to changetitself. β οΈval fold : (data -> 'acc -> 'acc) -> t -> 'acc -> 'accβfold f t initcomputes(f d1 (... (f dN init)))whered1 ... dNare the elements oftin some unspecified order. It is not specified what happens ifftries to changetitself. β οΈval count : t -> intβ count the number of elements in the table.count tgives the same result asfold (fun _ n -> n+1) t 0but does not delay the deallocation of the dead elements. π₯val stats : t -> int * int * int * int * int * intβ return statistics on the table. The numbers are, in order: table length, number of entries, sum of bucket lengths, smallest bucket length, median bucket length, biggest bucket length. π
Okay that's the whole manual, bestie! Footer check: source is OCamldoc, date is 2026-06-22, and this page is for Weak.Make(3). Slay and goodbye. πβ¨π
π¦ 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