1Weak.Make(3)                     OCaml library                    Weak.Make(3)
2
3
4

NAME

6       Weak.Make  -  Functor  building  an implementation of the weak hash set
7       structure.
8

Module

10       Module   Weak.Make
11

Documentation

13       Module Make
14        : functor (H : Hashtbl.HashedType) -> sig end
15
16
17       Functor building an implementation of  the  weak  hash  set  structure.
18       H.equal  can't  be  the physical equality, since only shallow copies of
19       the elements in the set are given to it.
20
21
22       Parameters:
23
24       "H"
25
26       Stdlib.Hashtbl.HashedType
27
28
29
30
31
32
33
34       type data
35
36
37       The type of the elements stored in the table.
38
39
40       type t
41
42
43       The type of tables that contain elements of type data .  Note that weak
44       hash  sets  cannot  be marshaled using output_value or the functions of
45       the Marshal module.
46
47
48
49       val create : int -> t
50
51
52       create n creates a new empty weak hash set, of initial size  n  .   The
53       table will grow as needed.
54
55
56
57       val clear : t -> unit
58
59       Remove all elements from the table.
60
61
62
63       val merge : t -> data -> data
64
65
66       merge t x returns an instance of x found in t if any, or else adds x to
67       t and return x .
68
69
70
71       val add : t -> data -> unit
72
73
74       add t x adds x to t .  If there is already an instance of x in t  ,  it
75       is  unspecified  which one will be returned by subsequent calls to find
76       and merge .
77
78
79
80       val remove : t -> data -> unit
81
82
83       remove t x removes from t one instance of x .  Does nothing if there is
84       no instance of x in t .
85
86
87
88       val find : t -> data -> data
89
90
91       find t x returns an instance of x found in t .
92
93
94       Raises Not_found if there is no such element.
95
96
97
98       val find_opt : t -> data -> data option
99
100
101       find_opt t x returns an instance of x found in t or None if there is no
102       such element.
103
104
105       Since 4.05
106
107
108
109       val find_all : t -> data -> data list
110
111
112       find_all t x returns a list of all the instances of x found in t .
113
114
115
116       val mem : t -> data -> bool
117
118
119       mem t x returns true if there is at least one instance  of  x  in  t  ,
120       false otherwise.
121
122
123
124       val iter : (data -> unit) -> t -> unit
125
126
127       iter  f t calls f on each element of t , in some unspecified order.  It
128       is not specified what happens if f tries to change t itself.
129
130
131
132       val fold : (data -> 'a -> 'a) -> t -> 'a -> 'a
133
134
135       fold f t init computes (f d1 (... (f dN init))) where d1 ... dN are the
136       elements of t in some unspecified order.  It is not specified what hap‐
137       pens if f tries to change t itself.
138
139
140
141       val count : t -> int
142
143       Count the number of elements in the table.  count t gives the same  re‐
144       sult  as  fold (fun _ n -> n+1) t 0 but does not delay the deallocation
145       of the dead elements.
146
147
148
149       val stats : t -> int * int * int * int * int * int
150
151       Return statistics on the table.   The  numbers  are,  in  order:  table
152       length,  number  of  entries,  sum  of  bucket lengths, smallest bucket
153       length, median bucket length, biggest bucket length.
154
155
156
157
158
159OCamldoc                          2022-07-22                      Weak.Make(3)
Impressum