@@ -27,9 +27,15 @@ module Int = Belt_MutableMapInt
27
27
module String = Belt_MutableMapString
28
28
29
29
30
- (* * A ** mutable** sorted map module which allows customize _compare_ behavior.
30
+ (* * A mutable sorted map module which allows customize compare behavior.
31
31
32
- Same as Belt.Map, but mutable.
32
+ Same as `Belt.Map`, but mutable.
33
+ *)
34
+
35
+ (* ```res prelude
36
+ type t<'k, 'v, 'id>
37
+ type id<'key, 'id> = Belt_Id.comparable<'key, 'id>
38
+ ```
33
39
*)
34
40
35
41
type ('k,'v,'id) t
@@ -50,52 +56,46 @@ val cmp:
50
56
('k , 'a , 'id ) t ->
51
57
('a -> 'a -> int ) ->
52
58
int
53
- (* * `cmp m1 m2 cmp`
54
- First compare by size, if size is the same,
55
- compare by key, value pair
56
- *)
59
+ (* * `cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by
60
+ key, value pair. *)
57
61
58
62
val eqU : ('k , 'a , 'id ) t -> ('k , 'a , 'id ) t -> ('a -> 'a -> bool [@ bs]) -> bool
59
63
val eq : ('k , 'a , 'id ) t -> ('k , 'a , 'id ) t -> ('a -> 'a -> bool ) -> bool
60
- (* * `eq m1 m2 eqf` tests whether the maps `m1` and `m2` are
61
- equal, that is, contain equal keys and associate them with
62
- equal data. `eqf` is the equality predicate used to compare
63
- the data associated with the keys. *)
64
+ (* * `eq(m1, m2, eqf)` tests whether the maps `m1` and `m2` are equal, that is,
65
+ contain equal keys and associate them with equal data. `eqf` is the
66
+ equality predicate used to compare the data associated with the keys. *)
64
67
65
68
val forEachU : ('k , 'a , 'id ) t -> ('k -> 'a -> unit [@ bs]) -> unit
66
69
val forEach : ('k , 'a , 'id ) t -> ('k -> 'a -> unit ) -> unit
67
- (* * `forEach m f ` applies `f` to all bindings in map `m`.
68
- `f` receives the 'k as first argument, and the associated value
69
- as second argument. The bindings are passed to `f` in increasing
70
- order with respect to the ordering over the type of the keys. *)
70
+ (* * `forEach(m, f) ` applies f to all bindings in map `m`. `f` receives the `'k`
71
+ as first argument, and the associated value as second argument. The
72
+ bindings are passed to `f` in increasing order with respect to the ordering
73
+ over the type of the keys. *)
71
74
72
75
val reduceU : ('k , 'a , 'id ) t -> 'b -> ('b -> 'k -> 'a -> 'b [@ bs]) -> 'b
73
76
val reduce : ('k , 'a , 'id ) t -> 'b -> ('b -> 'k -> 'a -> 'b ) -> 'b
74
- (* * `reduce m a f` computes `(f kN dN ... (f k1 d1 a)...)`,
75
- where `k1 ... kN` are the keys of all bindings in `m `
76
- (in increasing order), and `d1 ... dN` are the associated data. *)
77
+ (* * `reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a)) ...)`, where`k1 ...
78
+ kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN `
79
+ are the associated data. *)
77
80
78
81
val everyU : ('k , 'a , 'id ) t -> ('k -> 'a -> bool [@ bs]) -> bool
79
82
val every : ('k , 'a , 'id ) t -> ('k -> 'a -> bool ) -> bool
80
- (* * `every m p` checks if all the bindings of the map
81
- satisfy the predicate `p`.
82
- *)
83
+ (* * `every(m, p)` checks if all the bindings of the map satisfy the predicate
84
+ `p`. *)
83
85
84
86
85
87
val someU : ('k , 'a , 'id ) t -> ('k -> 'a -> bool [@ bs]) -> bool
86
88
val some : ('k , 'a , 'id ) t -> ('k -> 'a -> bool ) -> bool
87
- (* * `some m p` checks if at least one binding of the map
88
- satisfy the predicate `p`.
89
- *)
89
+ (* * `some(m, p)` checks if at least one binding of the map satisfy the
90
+ predicate `p`. *)
90
91
91
92
val size : ('k , 'a , 'id ) t -> int
92
93
93
94
94
95
val toList : ('k , 'a , 'id ) t -> ('k * 'a ) list
95
- (* * In increasing order*)
96
+ (* * In increasing order. *)
96
97
97
98
val toArray : ('k , 'a , 'id ) t -> ('k * 'a ) array
98
- (* * In increasing order*)
99
99
100
100
val fromArray : ('k * 'a ) array -> id :('k ,'id ) id -> ('k ,'a,'id) t
101
101
val keysToArray : ('k , _ , _ ) t -> 'k array
@@ -114,23 +114,20 @@ val getWithDefault:
114
114
('k , 'a , 'id ) t -> 'k -> 'a -> 'a
115
115
val getExn : ('k , 'a , 'id ) t -> 'k -> 'a
116
116
val checkInvariantInternal : _ t -> unit
117
- (* *
118
- **raise** when invariant is not held
119
- *)
117
+ (* * Raise when invariant is not held. *)
120
118
121
119
122
120
(* ***************************************************************************)
123
121
124
122
(* TODO: add functional `merge, partition, keep, split`*)
125
123
126
124
val remove : ('k , 'a , 'id ) t -> 'k -> unit
127
- (* * `remove m x` do the in-place modification,
128
- *)
125
+ (* * `remove(m, x)` do the in-place modification. *)
129
126
130
127
val removeMany : ('k , 'a , 'id ) t -> 'k array -> unit
131
128
132
129
val set : ('k , 'a , 'id ) t -> 'k -> 'a -> unit
133
- (* * `set m x y ` do the in-place modification *)
130
+ (* * `set(m, x, y) ` do the in-place modification *)
134
131
135
132
val updateU : ('k , 'a , 'id ) t -> 'k -> ('a option -> 'a option [@ bs]) -> unit
136
133
val update : ('k , 'a , 'id ) t -> 'k -> ('a option -> 'a option ) -> unit
@@ -139,14 +136,10 @@ val mergeMany: ('k, 'a, 'id) t -> ('k * 'a) array -> unit
139
136
140
137
val mapU : ('k , 'a , 'id ) t -> ('a -> 'b [@ bs]) -> ('k ,'b,'id ) t
141
138
val map : ('k , 'a , 'id ) t -> ('a -> 'b ) -> ('k ,'b,'id ) t
142
- (* * `map m f` returns a map with same domain as `m`, where the
143
- associated value `a` of all bindings of `m` has been
144
- replaced by the result of the application of `f` to `a`.
145
- The bindings are passed to `f` in increasing order
146
- with respect to the ordering over the type of the keys. *)
139
+ (* * `map(m, f)` returns a map with same domain as `m`, where the associated
140
+ value a of all bindings of `m` has been replaced by the result of the
141
+ application of `f` to `a`. The bindings are passed to `f` in increasing
142
+ order with respect to the ordering over the type of the keys. *)
147
143
148
144
val mapWithKeyU : ('k , 'a , 'id ) t -> ('k -> 'a -> 'b [@ bs]) -> ('k , 'b , 'id ) t
149
145
val mapWithKey : ('k , 'a , 'id ) t -> ('k -> 'a -> 'b ) -> ('k , 'b , 'id ) t
150
-
151
-
152
-
0 commit comments