type data = H.tThe type of the elements stored in the table.
type tThe type of tables that contain elements of type
data. Note that weak hash sets cannot be marshaled usingStdlib.output_valueor the functions of theMarshalmodule.
val create : int -> tcreate ncreates a new empty weak hash set, of initial sizen. The table will grow as needed.
val clear : t -> unitRemove all elements from the table.
val merge : t -> data -> datamerge t xreturns an instance ofxfound intif any, or else addsxtotand returnx.
val add : t -> data -> unitadd t xaddsxtot. If there is already an instance ofxint, it is unspecified which one will be returned by subsequent calls tofindandmerge.
val remove : t -> data -> unitremove t xremoves fromtone instance ofx. Does nothing if there is no instance ofxint.
val find : t -> data -> datafind t xreturns an instance ofxfound int. RaiseNot_foundif there is no such element.
val find_opt : t -> data -> data optionfind_opt t xreturns an instance ofxfound intorNoneif there is no such element.- since
- 4.05
val find_all : t -> data -> data listfind_all t xreturns a list of all the instances ofxfound int.
val mem : t -> data -> boolmem t xreturnstrueif there is at least one instance ofxint, false otherwise.
val iter : (data -> unit) -> t -> unititer f tcallsfon each element oft, in some unspecified order. It is not specified what happens ifftries to changetitself.
val fold : (data -> 'a -> 'a) -> t -> 'a -> 'afold 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 -> intCount 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 * intReturn 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.