30
30
31
31
For example:
32
32
{[
33
- type t = int
33
+ type t = int
34
34
module I0 =
35
35
(val Belt.Id.hashableU
36
36
~hash:(fun[\@bs] (a : t) -> a & 0xff_ff)
@@ -75,13 +75,13 @@ module Int = Belt_HashMapInt
75
75
76
76
77
77
(* * Specalized when key type is [string], more efficient
78
- than the gerneic type *)
78
+ than the gerneic type *)
79
79
module String = Belt_HashMapString
80
80
81
81
82
82
83
83
84
- type ('key,'value,'id) t
84
+ type ('key,'value,'id) t
85
85
(* * The type of hash tables from type ['key] to type ['value]. *)
86
86
87
87
type ('a, 'id) id = ('a , 'id ) Belt_Id .hashable
@@ -93,32 +93,30 @@ val make: hintSize:int -> id:('key, 'id) id -> ('key,'value,'id) t
93
93
val clear : ('key , 'value , 'id ) t -> unit
94
94
(* * Empty a hash table. *)
95
95
96
- val isEmpty : _ t -> bool
96
+ val isEmpty : _ t -> bool
97
97
98
98
val set : ('key , 'value , 'id ) t -> 'key -> 'value -> unit
99
99
(* * [set tbl k v] if [k] does not exist,
100
100
add the binding [k,v], otherwise, update the old value with the new
101
101
[v]
102
102
*)
103
-
103
+
104
104
val copy : ('key , 'value , 'id ) t -> ('key , 'value , 'id ) t
105
-
105
+
106
106
val get : ('key , 'value , 'id ) t -> 'key -> 'value option
107
107
108
-
108
+
109
109
val has : ('key , 'value , 'id ) t -> 'key -> bool
110
110
(* * [has tbl x] checks if [x] is bound in [tbl]. *)
111
111
112
112
val remove : ('key , 'value , 'id ) t -> 'key -> unit
113
113
114
- val forEachU : ('key , 'value , 'id ) t -> ('key -> 'value -> unit [@ bs]) -> unit
115
114
val forEach : ('key , 'value , 'id ) t -> ('key -> 'value -> unit ) -> unit
116
115
(* * [forEach tbl f] applies [f] to all bindings in table [tbl].
117
116
[f] receives the key as first argument, and the associated value
118
117
as second argument. Each binding is presented exactly once to [f].
119
118
*)
120
119
121
- val reduceU : ('key , 'value , 'id ) t -> 'c -> ('c -> 'key -> 'value -> 'c [@ bs]) -> 'c
122
120
val reduce : ('key , 'value , 'id ) t -> 'c -> ('c -> 'key -> 'value -> 'c ) -> 'c
123
121
(* * [reduce tbl init f] computes
124
122
[(f kN dN ... (f k1 d1 init)...)],
@@ -133,11 +131,10 @@ val reduce: ('key, 'value, 'id ) t -> 'c -> ('c -> 'key -> 'value -> 'c) -> 'c
133
131
*)
134
132
135
133
136
- val keepMapInPlaceU : ('key , 'value , 'id ) t -> ('key -> 'value -> 'value option [@ bs]) -> unit
137
134
val keepMapInPlace : ('key , 'value , 'id ) t -> ('key -> 'value -> 'value option ) -> unit
138
135
139
136
140
- val size : _ t -> int
137
+ val size : _ t -> int
141
138
(* * [size tbl] returns the number of bindings in [tbl].
142
139
It takes constant time. *)
143
140
@@ -146,14 +143,23 @@ val size: _ t -> int
146
143
147
144
148
145
149
- val toArray : ('key , 'value , 'id ) t -> ('key * 'value ) array
150
- val keysToArray : ('key , _ , _ ) t -> 'key array
151
- val valuesToArray : (_ ,'value,_) t -> 'value array
152
- val fromArray : ('key * 'value ) array -> id :('key ,'id ) id -> ('key , 'value , 'id ) t
146
+ val toArray : ('key , 'value , 'id ) t -> ('key * 'value ) array
147
+ val keysToArray : ('key , _ , _ ) t -> 'key array
148
+ val valuesToArray : (_ ,'value,_) t -> 'value array
149
+ val fromArray : ('key * 'value ) array -> id :('key ,'id ) id -> ('key , 'value , 'id ) t
153
150
val mergeMany : ('key , 'value , 'id ) t -> ('key * 'value ) array -> unit
154
151
val getBucketHistogram : _ t -> int array
155
152
val logStats : _ t -> unit
156
153
157
- val ofArray : ('key * 'value ) array -> id :('key ,'id ) id -> ('key , 'value , 'id ) t
154
+ val ofArray : ('key * 'value ) array -> id :('key ,'id ) id -> ('key , 'value , 'id ) t
158
155
[@@ ocaml.deprecated "Use fromArray instead" ]
159
156
157
+
158
+ (* * {1 Uncurried version} *)
159
+
160
+
161
+ val forEachU : ('key , 'value , 'id ) t -> ('key -> 'value -> unit [@ bs]) -> unit
162
+
163
+ val reduceU : ('key , 'value , 'id ) t -> 'c -> ('c -> 'key -> 'value -> 'c [@ bs]) -> 'c
164
+
165
+ val keepMapInPlaceU : ('key , 'value , 'id ) t -> ('key -> 'value -> 'value option [@ bs]) -> unit
0 commit comments