1
+ (* * Specalized when key type is `string`, more efficient than the generic type,
2
+ its compare behavior is fixed using the built-in comparison
3
+ *)
4
+
5
+ (* ```res prelude
6
+ type key = string
7
+ type t<'value>
8
+ ```
9
+ *)
10
+
1
11
# 2 " others/map.cppo.mli"
2
12
type key = string
3
13
# 8 "others/map.cppo.mli"
@@ -15,50 +25,43 @@ val cmp: 'v t -> 'v t -> ('v -> 'v -> int) -> int
15
25
16
26
val eqU : 'v t -> 'v t -> ('v -> 'v -> bool [@ bs]) -> bool
17
27
val eq : 'v t -> 'v t -> ('v -> 'v -> bool ) -> bool
18
- (* *
19
- `eq m1 m2` tests whether the maps `m1` and `m2` are
20
- equal, that is, contain equal keys and associate them with
21
- equal data.
22
- *)
28
+ (* * `eq(m1, m2)` tests whether the maps `m1` and `m2` are equal, that is,
29
+ contain equal keys and associate them with equal data. *)
23
30
24
31
val findFirstByU : 'v t -> (key -> 'v -> bool [@ bs]) -> (key * 'v ) option
25
32
val findFirstBy : 'v t -> (key -> 'v -> bool ) -> (key * 'v ) option
26
- (* *
27
- `findFirstBy m p` uses funcion `f` to find the first key value pair
28
- to match predicate `p`.
29
-
30
- ```
31
- let s0 = fromArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];;
32
- findFirstBy s0 (fun k v - > k = 4 ) = option (4, "4");;
33
- ```
33
+ (* * `findFirstBy(m, p)` uses function `f` to find the first key value pair to
34
+ match predicate `p`.
35
+
36
+ ```res example
37
+ let s0 = Belt.Map.String.fromArray([("4", 4), ("1", 1), ("2", 2), ("3", 3)])
38
+
39
+ Belt.Map.String.findFirstBy(s0, (k, _) = > k == "4" ) == Some(("4", 4))
40
+ ```
34
41
*)
35
42
36
43
val forEachU : 'v t -> (key -> 'v -> unit [@ bs]) -> unit
37
44
val forEach : 'v t -> (key -> 'v -> unit ) -> unit
38
- (* *
39
- `forEach m f` applies `f` to all bindings in map `m`.
40
- `f` receives the key as first argument, and the associated value
41
- as second argument. The bindings are passed to `f` in increasing
42
- order with respect to the ordering over the type of the keys.
43
- *)
45
+ (* * `forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the
46
+ key as first argument, and the associated value as second argument. The
47
+ bindings are passed to `f` in increasing order with respect to the ordering
48
+ over the type of the keys. *)
44
49
45
50
val reduceU : 'v t -> 'v2 -> ('v2 -> key -> 'v -> 'v2 [@ bs]) -> 'v2
46
51
val reduce : 'v t -> 'v2 -> ('v2 -> key -> 'v -> 'v2 ) -> 'v2
47
- (* *
48
- `reduce m a f` computes `(f kN dN ... (f k1 d1 a)...)`,
49
- where `k1 ... kN` are the keys of all bindings in `m`
50
- (in increasing order), and `d1 ... dN` are the associated data.
51
- *)
52
+ (* * `reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...), where k1 ...
53
+ kN)` are the keys of all bindings in `m` (in increasing order), and `d1 ...
54
+ dN` are the associated data. *)
52
55
53
56
val everyU : 'v t -> (key -> 'v -> bool [@ bs]) -> bool
54
57
val every : 'v t -> (key -> 'v -> bool ) -> bool
55
- (* * `every m p ` checks if all the bindings of the map
56
- satisfy the predicate `p`. Order unspecified *)
58
+ (* * `every(m, p) ` checks if all the bindings of the map satisfy the predicate
59
+ `p`. Order unspecified *)
57
60
58
61
val someU : 'v t -> (key -> 'v -> bool [@ bs]) -> bool
59
62
val some : 'v t -> (key -> 'v -> bool ) -> bool
60
- (* * `some m p ` checks if at least one binding of the map
61
- satisfy the predicate `p`. Order unspecified *)
63
+ (* * `some(m, p) ` checks if at least one binding of the map satisfy the
64
+ predicate `p`. Order unspecified *)
62
65
63
66
val size : 'v t -> int
64
67
@@ -99,22 +102,18 @@ val getWithDefault: 'v t -> key -> 'v -> 'v
99
102
val getExn : 'v t -> key -> 'v
100
103
101
104
val checkInvariantInternal : _ t -> unit
102
- (* *
103
- **raise** when invariant is not held
104
- *)
105
+ (* * **raise** when invariant is not held *)
105
106
106
107
val remove : 'v t -> key -> 'v t
107
- (* * `remove m x ` returns a map containing the same bindings as
108
- `m`, except for `x` which is unbound in the returned map. *)
108
+ (* * `remove(m, x) ` returns a map containing the same bindings as `m`, except
109
+ for `x` which is unbound in the returned map. *)
109
110
110
111
val removeMany : 'v t -> key array -> 'v t
111
112
112
113
val set : 'v t -> key -> 'v -> 'v t
113
- (* *
114
- `set m x y` returns a map containing the same bindings as
115
- `m`, plus a binding of `x` to `y`. If `x` was already bound
116
- in `m`, its previous binding disappears.
117
- *)
114
+ (* * `set(m, x, y)` returns a map containing the same bindings as `m`, plus a
115
+ binding of `x` to `y`. If `x` was already bound in `m`, its previous
116
+ binding disappears. *)
118
117
119
118
val updateU : 'v t -> key -> ('v option -> 'v option [@ bs]) -> 'v t
120
119
val update : 'v t -> key -> ('v option -> 'v option ) -> 'v t
@@ -127,11 +126,9 @@ val merge:
127
126
'v t -> 'v2 t ->
128
127
(key -> 'v option -> 'v2 option -> 'c option ) ->
129
128
'c t
130
- (* *
131
- `merge m1 m2 f` computes a map whose keys is a subset of keys of `m1`
132
- and of `m2`. The presence of each such binding, and the corresponding
133
- value, is determined with the function `f`.
134
- *)
129
+ (* * `merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1`
130
+ and of `m2`. The presence of each such binding, and the corresponding
131
+ value, is determined with the function `f`. *)
135
132
136
133
val mergeMany : 'v t -> (key * 'v ) array -> 'v t
137
134
@@ -144,8 +141,8 @@ val keep:
144
141
'v t ->
145
142
(key -> 'v -> bool ) ->
146
143
'v t
147
- (* * `keep m p ` returns the map with all the bindings in `m`
148
- that satisfy predicate `p`. *)
144
+ (* * `keep(m, p) ` returns the map with all the bindings in `m` that satisfy
145
+ predicate `p`. *)
149
146
150
147
val partitionU :
151
148
'v t ->
@@ -155,33 +152,23 @@ val partition:
155
152
'v t ->
156
153
(key -> 'v -> bool ) ->
157
154
'v t * 'v t
158
- (* *
159
- `partition m p` returns a pair of maps `(m1, m2)`, where
160
- `m1` contains all the bindings of `s` that satisfy the
161
- predicate `p`, and `m2` is the map with all the bindings of
162
- `s` that do not satisfy `p`.
163
- *)
155
+ (* * `partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains
156
+ all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map
157
+ with all the bindings of s that do not satisfy `p`. *)
164
158
165
159
val split : key -> 'v t -> 'v t * 'v option * 'v t
166
- (* *
167
- `split x m` returns a triple `(l, data, r)`, where
168
- `l` is the map with all the bindings of `m` whose key
169
- is strictly less than `x`;
170
- `r` is the map with all the bindings of `m` whose key
171
- is strictly greater than `x`;
172
- `data` is `None` if `m` contains no binding for `x`,
173
- or `Some v` if `m` binds `v` to `x`.
174
- *)
160
+ (* * `split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with
161
+ all the bindings of `m` whose key is strictly less than `x`; `r` is the map
162
+ with all the bindings of m whose key is strictly greater than `x`; `data`
163
+ is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v`
164
+ to `x`. *)
175
165
176
166
val mapU : 'v t -> ('v -> 'v2 [@ bs]) -> 'v2 t
177
167
val map : 'v t -> ('v -> 'v2 ) -> 'v2 t
178
- (* *
179
- `map m f` returns a map with same domain as `m`, where the
180
- associated value `a` of all bindings of `m` has been
181
- replaced by the result of the application of `f` to `a`.
182
- The bindings are passed to `f` in increasing order
183
- with respect to the ordering over the type of the keys.
184
- *)
168
+ (* * `map(m, f)` returns a map with same domain as `m`, where the associated
169
+ value `a` of all bindings of `m` has been replaced by the result of the
170
+ application of `f` to `a`. The bindings are passed to `f` in increasing
171
+ order with respect to the ordering over the type of the keys. *)
185
172
186
173
val mapWithKeyU : 'v t -> (key -> 'v -> 'v2 [@ bs]) -> 'v2 t
187
174
val mapWithKey : 'v t -> (key -> 'v -> 'v2 ) -> 'v2 t
0 commit comments