@@ -38,7 +38,7 @@ let partition0 = N.partition0
38
38
let length0 = N. length0
39
39
let toList0 = N. toList0
40
40
41
- let rec add0 ~ cmp x data (t : _ t0 ) =
41
+ let rec add0 (t : _ t0 ) x data ~ cmp =
42
42
match N. toOpt t with (* TODO: test case with the same key *)
43
43
None ->
44
44
N. (return @@ node ~left: empty ~key: x ~value: data ~right: empty ~h: 1 )
@@ -48,41 +48,41 @@ let rec add0 ~cmp x data (t : _ t0) =
48
48
if c = 0 then
49
49
N. (return @@ node ~left: l ~key: x ~value: data ~right: r ~h: (h n))
50
50
else if c < 0 then
51
- N. (bal (add0 ~cmp x data l ) k v r)
51
+ N. (bal (add0 ~cmp l x data ) k v r)
52
52
else
53
- N. (bal l k v (add0 ~cmp x data r ))
53
+ N. (bal l k v (add0 ~cmp r x data ))
54
54
55
- let rec findOpt0 ~ cmp x n =
55
+ let rec findOpt0 n x ~ cmp =
56
56
match N. toOpt n with
57
57
None -> None
58
58
| Some n (* Node(l, v, d, r, _) *) ->
59
59
let v = N. key n in
60
60
let c = (Bs_Cmp. getCmp cmp) x v [@ bs] in
61
61
if c = 0 then Some (N. value n)
62
- else findOpt0 ~cmp x (if c < 0 then N. left n else N. right n)
62
+ else findOpt0 ~cmp (if c < 0 then N. left n else N. right n) x
63
63
64
- let rec findAssert0 ~ cmp x n =
64
+ let rec findAssert0 n x ~ cmp =
65
65
match N. toOpt n with
66
66
| None ->
67
67
[% assert " Not_found" ]
68
68
| Some n (* Node(l, v, d, r, _)*) ->
69
69
let v = N. key n in
70
70
let c = (Bs_Cmp. getCmp cmp) x v [@ bs] in
71
71
if c = 0 then N. value n
72
- else findAssert0 ~cmp x (if c < 0 then N. left n else N. right n)
72
+ else findAssert0 ~cmp (if c < 0 then N. left n else N. right n) x
73
73
74
- let rec findWithDefault0 ~ cmp ~ def x n =
74
+ let rec findWithDefault0 n x def ~ cmp =
75
75
match N. toOpt n with
76
76
None ->
77
77
def
78
78
| Some n (* Node(l, v, d, r, _)*) ->
79
79
let v = N. key n in
80
80
let c = (Bs_Cmp. getCmp cmp) x v [@ bs] in
81
81
if c = 0 then N. value n
82
- else findWithDefault0 ~cmp ~def x (if c < 0 then N. left n else N. right n)
82
+ else findWithDefault0 ~cmp (if c < 0 then N. left n else N. right n) x def
83
83
84
84
85
- let rec mem0 ~ cmp x n =
85
+ let rec mem0 x n ~ cmp =
86
86
match N. toOpt n with
87
87
None ->
88
88
false
@@ -92,7 +92,7 @@ let rec mem0 ~cmp x n =
92
92
c = 0 || mem0 ~cmp x (if c < 0 then N. left n else N. right n)
93
93
94
94
95
- let rec remove0 ~ cmp x n =
95
+ let rec remove0 n x ~ cmp =
96
96
match N. toOpt n with
97
97
None ->
98
98
n
@@ -108,9 +108,9 @@ let rec remove0 ~cmp x n =
108
108
let r = N. removeMinAuxWithRef rn kr vr in
109
109
N. bal l ! kr ! vr r
110
110
else if c < 0 then
111
- N. (bal (remove0 ~cmp x l ) v (value n) r)
111
+ N. (bal (remove0 ~cmp l x ) v (value n) r)
112
112
else
113
- N. (bal l v (value n) (remove0 ~cmp x r ))
113
+ N. (bal l v (value n) (remove0 ~cmp r x ))
114
114
115
115
let rec splitAux ~cmp x (n : _ N.node ) : _ t0 * _ option * _ t0 =
116
116
let l,v,d,r = N. (left n , key n, value n, right n) in
@@ -138,17 +138,17 @@ let split0 ~cmp x n =
138
138
| Some n (* Node(l, v, d, r, _) *) ->
139
139
splitAux ~cmp x n
140
140
141
- let rec merge0 ~ cmp f s1 s2 =
141
+ let rec merge0 s1 s2 f ~ cmp =
142
142
match N. (toOpt s1, toOpt s2) with
143
143
(None, None) -> N. empty
144
144
| Some n (* (Node (l1, v1, d1, r1, h1), _) *) , _ when N. h n > = N. height s2 ->
145
145
let l1, v1, d1, r1 = N. (left n, key n, value n, right n) in
146
146
let (l2, d2, r2) = split0 ~cmp v1 s2 in
147
- N. concatOrJoin (merge0 ~cmp f l1 l2) v1 (f v1 (Some d1) d2 [@ bs]) (merge0 ~cmp f r1 r2)
147
+ N. concatOrJoin (merge0 ~cmp l1 l2 f ) v1 (f v1 (Some d1) d2 [@ bs]) (merge0 ~cmp r1 r2 f )
148
148
| _ , Some n (* Node (l2, v2, d2, r2, h2)*) ->
149
149
let l2,v2,d2,r2 = N. (left n, key n, value n, right n) in
150
150
let (l1, d1, r1) = split0 ~cmp v2 s1 in
151
- N. concatOrJoin (merge0 ~cmp f l1 l2) v2 (f v2 d1 (Some d2) [@ bs]) (merge0 ~cmp f r1 r2)
151
+ N. concatOrJoin (merge0 ~cmp l1 l2 f ) v2 (f v2 d1 (Some d2) [@ bs]) (merge0 ~cmp r1 r2 f )
152
152
| _ ->
153
153
assert false
154
154
@@ -194,7 +194,7 @@ let ofArray0 ~cmp (xs : _ array) : _ t0 =
194
194
let result = ref N. empty in
195
195
for i = 0 to Array. length xs - 1 do
196
196
let k, v = (Bs_Array. unsafe_get xs i) in
197
- result := add0 ~cmp k v ! result
197
+ result := add0 ~cmp ! result k v
198
198
done ;
199
199
! result
200
200
@@ -253,10 +253,10 @@ let mapi map f =
253
253
254
254
255
255
256
- let add (type k ) (type v ) (type id ) key data (map : (k,v,id) t ) =
256
+ let add (type k ) (type v ) (type id ) (map : (k,v,id) t ) key data =
257
257
let dict,map = B. (dict map, data map) in
258
258
let module X = (val dict) in
259
- B. bag ~dict ~data: (add0 ~cmp: X. cmp key data map )
259
+ B. bag ~dict ~data: (add0 ~cmp: X. cmp map key data )
260
260
261
261
262
262
let ofArray (type k ) (type v ) (type id ) (dict : (k,id) Bs_Cmp.t ) data =
@@ -267,31 +267,31 @@ let ofArray (type k) (type v) (type id) (dict : (k,id) Bs_Cmp.t) data =
267
267
268
268
269
269
270
- let findOpt (type k ) (type v ) (type id ) x (map : (k,v,id) t ) =
270
+ let findOpt (type k ) (type v ) (type id ) (map : (k,v,id) t ) x =
271
271
let dict,map = B. (dict map, data map) in
272
272
let module X = (val dict) in
273
- findOpt0 ~cmp: X. cmp x map
273
+ findOpt0 ~cmp: X. cmp map x
274
274
275
- let findAssert (type k ) (type v ) (type id ) x (map : (k,v,id) t ) =
275
+ let findAssert (type k ) (type v ) (type id ) (map : (k,v,id) t ) x =
276
276
let dict,map = B. (dict map, data map) in
277
277
let module X = (val dict) in
278
- findAssert0 ~cmp: X. cmp x map
278
+ findAssert0 ~cmp: X. cmp map x
279
279
280
- let findWithDefault (type k ) (type v ) (type id ) ~ def x (map : (k,v,id) t ) =
280
+ let findWithDefault (type k ) (type v ) (type id ) (map : (k,v,id) t ) x def =
281
281
let dict,map = B. (dict map, data map) in
282
282
let module X = (val dict) in
283
- findWithDefault0 ~cmp: X. cmp ~def x map
283
+ findWithDefault0 ~cmp: X. cmp map x def
284
284
285
285
286
- let mem (type k ) (type v ) (type id ) x (map : (k,v,id) t ) =
286
+ let mem (type k ) (type v ) (type id ) (map : (k,v,id) t ) x =
287
287
let dict,map = B. (dict map, data map) in
288
288
let module X = (val dict) in
289
289
mem0 ~cmp: X. cmp x map
290
290
291
- let remove (type k ) (type v ) (type id ) x (map : (k,v,id) t ) =
291
+ let remove (type k ) (type v ) (type id ) (map : (k,v,id) t ) x =
292
292
let dict,map = B. (dict map, data map) in
293
293
let module X = (val dict) in
294
- B. bag ~dict ~data: (remove0 ~cmp: X. cmp x map )
294
+ B. bag ~dict ~data: (remove0 ~cmp: X. cmp map x )
295
295
296
296
let split (type k ) (type v ) (type id ) x (map : (k,v,id) t ) =
297
297
let dict,map = B. (dict map, data map) in
@@ -306,11 +306,11 @@ let split (type k) (type v) (type id) x (map : (k,v,id) t) =
306
306
~data: r
307
307
308
308
309
- let merge (type k ) (type v ) (type id ) f (s1 : (k,v,id) t )
310
- (s2 : (k,_,id) t ) =
309
+ let merge (type k ) (type v ) (type id ) (s1 : (k,v,id) t )
310
+ (s2 : (k,_,id) t ) f =
311
311
let dict, s1_data, s2_data = B. (dict s1, data s1, data s2) in
312
312
let module X = (val dict) in
313
- B. bag ~data: (merge0 ~cmp: X. cmp f s1_data s2_data )
313
+ B. bag ~data: (merge0 ~cmp: X. cmp s1_data s2_data f )
314
314
~dict
315
315
316
316
0 commit comments