forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBelt_Map.html
712 lines (526 loc) · 40.6 KB
/
Belt_Map.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../api_static/tomorrow-night.css">
<link rel="stylesheet" href="../api_static/style.css" type="text/css">
<script src="../api_static//highlight.pack.js"></script>
<script src="../api_static//script.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<meta charset="utf8">
<link rel="previous" href="Belt_List.html"><link rel="next" href="Belt_MapDict.html">
<title> Belt_Map </title></head>
<body>
<nav class="module-index"><ul><li><a href="Belt.html">Belt</a></li>
<li><a href="Belt_Array.html">Belt_Array</a></li>
<li><a href="Belt_Debug.html">Belt_Debug</a></li>
<li><a href="Belt_Float.html">Belt_Float</a></li>
<li><a href="Belt_HashMap.html">Belt_HashMap</a></li>
<li><a href="Belt_HashMapInt.html">Belt_HashMapInt</a></li>
<li><a href="Belt_HashMapString.html">Belt_HashMapString</a></li>
<li><a href="Belt_HashSet.html">Belt_HashSet</a></li>
<li><a href="Belt_HashSetInt.html">Belt_HashSetInt</a></li>
<li><a href="Belt_HashSetString.html">Belt_HashSetString</a></li>
<li><a href="Belt_Id.html">Belt_Id</a></li>
<li><a href="Belt_Int.html">Belt_Int</a></li>
<li><a href="Belt_List.html">Belt_List</a></li>
<li><a href="Belt_Map.html">Belt_Map</a></li>
<li><a href="Belt_MapDict.html">Belt_MapDict</a></li>
<li><a href="Belt_MapInt.html">Belt_MapInt</a></li>
<li><a href="Belt_MapString.html">Belt_MapString</a></li>
<li><a href="Belt_MutableMap.html">Belt_MutableMap</a></li>
<li><a href="Belt_MutableMapInt.html">Belt_MutableMapInt</a></li>
<li><a href="Belt_MutableMapString.html">Belt_MutableMapString</a></li>
<li><a href="Belt_MutableQueue.html">Belt_MutableQueue</a></li>
<li><a href="Belt_MutableSet.html">Belt_MutableSet</a></li>
<li><a href="Belt_MutableSetInt.html">Belt_MutableSetInt</a></li>
<li><a href="Belt_MutableSetString.html">Belt_MutableSetString</a></li>
<li><a href="Belt_MutableStack.html">Belt_MutableStack</a></li>
<li><a href="Belt_Option.html">Belt_Option</a></li>
<li><a href="Belt_Range.html">Belt_Range</a></li>
<li><a href="Belt_Result.html">Belt_Result</a></li>
<li><a href="Belt_Set.html">Belt_Set</a></li>
<li><a href="Belt_SetDict.html">Belt_SetDict</a></li>
<li><a href="Belt_SetInt.html">Belt_SetInt</a></li>
<li><a href="Belt_SetString.html">Belt_SetString</a></li>
<li><a href="Belt_SortArray.html">Belt_SortArray</a></li>
<li><a href="Belt_SortArrayInt.html">Belt_SortArrayInt</a></li>
<li><a href="Belt_SortArrayString.html">Belt_SortArrayString</a></li>
<li><a href="Belt_internalAVLset.html">Belt_internalAVLset</a></li>
<li><a href="Belt_internalAVLtree.html">Belt_internalAVLtree</a></li>
<li><a href="Belt_internalBuckets.html">Belt_internalBuckets</a></li>
<li><a href="Belt_internalBucketsType.html">Belt_internalBucketsType</a></li>
<li><a href="Belt_internalMapInt.html">Belt_internalMapInt</a></li>
<li><a href="Belt_internalMapString.html">Belt_internalMapString</a></li>
<li><a href="Belt_internalSetBuckets.html">Belt_internalSetBuckets</a></li>
<li><a href="Belt_internalSetInt.html">Belt_internalSetInt</a></li>
<li><a href="Belt_internalSetString.html">Belt_internalSetString</a></li>
<li><a href="Dom.html">Dom</a></li>
<li><a href="Dom_storage.html">Dom_storage</a></li>
<li><a href="Dom_storage2.html">Dom_storage2</a></li>
<li><a href="Js.html">Js</a></li>
<li><a href="Js_array.html">Js_array</a></li>
<li><a href="Js_array2.html">Js_array2</a></li>
<li><a href="Js_cast.html">Js_cast</a></li>
<li><a href="Js_console.html">Js_console</a></li>
<li><a href="Js_date.html">Js_date</a></li>
<li><a href="Js_dict.html">Js_dict</a></li>
<li><a href="Js_exn.html">Js_exn</a></li>
<li><a href="Js_float.html">Js_float</a></li>
<li><a href="Js_global.html">Js_global</a></li>
<li><a href="Js_int.html">Js_int</a></li>
<li><a href="Js_json.html">Js_json</a></li>
<li><a href="Js_list.html">Js_list</a></li>
<li><a href="Js_mapperRt.html">Js_mapperRt</a></li>
<li><a href="Js_math.html">Js_math</a></li>
<li><a href="Js_null.html">Js_null</a></li>
<li><a href="Js_null_undefined.html">Js_null_undefined</a></li>
<li><a href="Js_obj.html">Js_obj</a></li>
<li><a href="Js_option.html">Js_option</a></li>
<li><a href="Js_promise.html">Js_promise</a></li>
<li><a href="Js_re.html">Js_re</a></li>
<li><a href="Js_result.html">Js_result</a></li>
<li><a href="Js_string.html">Js_string</a></li>
<li><a href="Js_string2.html">Js_string2</a></li>
<li><a href="Js_typed_array.html">Js_typed_array</a></li>
<li><a href="Js_typed_array2.html">Js_typed_array2</a></li>
<li><a href="Js_types.html">Js_types</a></li>
<li><a href="Js_undefined.html">Js_undefined</a></li>
<li><a href="Js_vector.html">Js_vector</a></li>
<li><a href="Node.html">Node</a></li>
<li><a href="Node_buffer.html">Node_buffer</a></li>
<li><a href="Node_child_process.html">Node_child_process</a></li>
<li><a href="Node_fs.html">Node_fs</a></li>
<li><a href="Node_module.html">Node_module</a></li>
<li><a href="Node_path.html">Node_path</a></li>
<li><a href="Node_process.html">Node_process</a></li></ul></nav>
<div class="navbar"><a class="pre" href="Belt_List.html" title="Belt_List">Previous</a>
<a class="up" href="index.html" title="Index">Up</a>
<a class="post" href="Belt_MapDict.html" title="Belt_MapDict">Next</a>
</div>
<h1>Module <a href="type_Belt_Map.html">Belt_Map</a></h1>
<pre><span id="MODULEBelt_Map"><span class="keyword">module</span> Belt_Map</span>: <code class="code">sig</code> <a href="Belt_Map.html">..</a> <code class="code">end</code></pre><div class="info module top">
<div class="not-examples">
A <i>immutable</i> sorted map module which allows customize <i>compare</i> behavior.
The implementation uses balanced binary trees, and therefore searching
and insertion take time logarithmic in the size of the map.
For more info on this module's usage of identity, `make` and others, please see
the top level documentation of Belt, <b>A special encoding for collection safety</b>.
Example usage:<br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> module PairComparator = Belt.Id.MakeComparable(struct
type t = int * int
let cmp (a0, a1) (b0, b1) =
match Pervasives.compare a0 b0 with
| 0 -> Pervasives.compare a1 b1
| c -> c
end)
let myMap = Belt.Map.make ~id:(module PairComparator)
let myMap2 = Belt.Map.set myMap (1, 2) "myValue"
</code></pre>
The API documentation below will assume a predeclared comparator module for integers, IntCmp </pre>
</div>
</div>
<hr width="100%">
<pre><span id="MODULEInt"><span class="keyword">module</span> <a href="Belt_Map.Int.html">Int</a></span>: <code class="type"><a href="Belt_MapInt.html">Belt_MapInt</a></code></pre> <div class="info">
<div class="not-examples">
Specalized when key type is <code class="code">int</code>, more efficient
than the generic type, its compare behavior is fixed using the built-in comparison<br>
</div>
</div>
<pre><span id="MODULEString"><span class="keyword">module</span> <a href="Belt_Map.String.html">String</a></span>: <code class="type"><a href="Belt_MapString.html">Belt_MapString</a></code></pre> <div class="info">
<div class="not-examples">
specalized when key type is <code class="code">string</code>, more efficient
than the generic type, its compare behavior is fixed using the built-in comparison<br>
</div>
</div>
<pre><span id="MODULEDict"><span class="keyword">module</span> <a href="Belt_Map.Dict.html">Dict</a></span>: <code class="type"><a href="Belt_MapDict.html">Belt_MapDict</a></code></pre> <div class="info">
<div class="not-examples">
This module seprate identity from data, it is a bit more verboe but slightly
more efficient due to the fact that there is no need to pack identity and data back
after each operation
<b>Advanced usage only</b><br>
</div>
</div>
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">('key, 'value, 'identity)</code> t</span> </pre>
<div class="info ">
<div class="not-examples">
<code class="code">('key, 'identity) t</code>
<code class="code">'key</code> is the field type
<code class="code">'value</code> is the element type
<code class="code">'identity</code> the identity of the collection<br>
</div>
</div>
<pre><span id="TYPEid"><span class="keyword">type</span> <code class="type">('key, 'id)</code> id</span> = <code class="type">('key, 'id) <a href="Belt_Id.html#TYPEcomparable">Belt_Id.comparable</a></code> </pre>
<div class="info ">
<div class="not-examples">
The identity needed for making an empty map<br>
</div>
</div>
<pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type">id:('k, 'id) <a href="Belt_Map.html#TYPEid">id</a> -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">make ~id</code> creates a new map by taking in the comparator<br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> let m = Belt.Map.make ~id:(module IntCmp)
</code></pre> </pre>
</div>
</div>
<pre><span id="VALisEmpty"><span class="keyword">val</span> isEmpty</span> : <code class="type">('a, 'b, 'c) <a href="Belt_Map.html#TYPEt">t</a> -> bool</code></pre><div class="info ">
<div class="not-examples">
<code class="code">isEmpty m</code> checks whether a map m is empty<br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> isEmpty (fromArray [|1,"1"|] ~id:(module IntCmp)) = false
</code></pre> </pre>
</div>
</div>
<pre><span id="VALhas"><span class="keyword">val</span> has</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'k -> bool</code></pre><div class="info ">
<div class="not-examples">
<code class="code">has m k</code> checks whether m has the key k<br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> has (fromArray [|1,"1"|] ~id:(module IntCmp)) 1 = true
</code></pre> </pre>
</div>
</div>
<pre><span id="VALcmpU"><span class="keyword">val</span> cmpU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('v -> 'v -> int [@bs]) -> int</code></pre>
<pre><span id="VALcmp"><span class="keyword">val</span> cmp</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('v -> 'v -> int) -> int</code></pre><div class="info ">
<div class="not-examples">
<code class="code">cmp m0 m1 vcmp</code>
Total ordering of map given total ordering of value function.
It will compare size first and each element following the order one by one.<br>
</div>
</div>
<pre><span id="VALeqU"><span class="keyword">val</span> eqU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('v -> 'v -> bool [@bs]) -> bool</code></pre>
<pre><span id="VALeq"><span class="keyword">val</span> eq</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('v -> 'v -> bool) -> bool</code></pre><div class="info ">
<div class="not-examples">
<code class="code">eq m1 m2 veq</code> tests whether the maps <code class="code">m1</code> and <code class="code">m2</code> are
equal, that is, contain equal keys and associate them with
equal data. <code class="code">veq</code> is the equality predicate used to compare
the data associated with the keys.<br>
</div>
</div>
<pre><span id="VALfindFirstByU"><span class="keyword">val</span> findFirstByU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k -> 'v -> bool [@bs]) -> ('k * 'v) option</code></pre>
<pre><span id="VALfindFirstBy"><span class="keyword">val</span> findFirstBy</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k -> 'v -> bool) -> ('k * 'v) option</code></pre><div class="info ">
<div class="not-examples">
<code class="code">findFirstBy m p</code> uses funcion <code class="code">f</code> to find the first key value pair
to match predicate <code class="code">p</code>.<br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> let s0 = fromArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];;
findFirstBy s0 (fun k v -> k = 4 ) = option (4, "4");;
</code></pre> </pre>
</div>
</div>
<pre><span id="VALforEachU"><span class="keyword">val</span> forEachU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k -> 'v -> unit [@bs]) -> unit</code></pre>
<pre><span id="VALforEach"><span class="keyword">val</span> forEach</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k -> 'v -> unit) -> unit</code></pre><div class="info ">
<div class="not-examples">
<code class="code">forEach m f</code> applies <code class="code">f</code> to all bindings in map <code class="code">m</code>.
<code class="code">f</code> receives the 'k as first argument, and the associated value
as second argument. The bindings are passed to <code class="code">f</code> in increasing
order with respect to the ordering over the type of the keys.<br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> let s0 = fromArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];;
let acc = ref [] ;;
forEach s0 (fun k v -> acc := (k,v) :: !acc);;
!acc = [4,"4"; 3,"3"; 2,"2"; 1,"1"]
</code></pre> </pre>
</div>
</div>
<pre><span id="VALreduceU"><span class="keyword">val</span> reduceU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'acc -> ('acc -> 'k -> 'v -> 'acc [@bs]) -> 'acc</code></pre>
<pre><span id="VALreduce"><span class="keyword">val</span> reduce</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'acc -> ('acc -> 'k -> 'v -> 'acc) -> 'acc</code></pre><div class="info ">
<div class="not-examples">
<code class="code">reduce m a f</code> computes <code class="code">(f kN dN ... (f k1 d1 a)...)</code>,
where <code class="code">k1 ... kN</code> are the keys of all bindings in <code class="code">m</code>
(in increasing order), and <code class="code">d1 ... dN</code> are the associated data.<br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> let s0 = fromArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];;
reduce s0 [] (fun acc k v -> (k,v) acc ) = [4,"4";3,"3";2,"2";1,"1"];;
</code></pre> </pre>
</div>
</div>
<pre><span id="VALeveryU"><span class="keyword">val</span> everyU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k -> 'v -> bool [@bs]) -> bool</code></pre>
<pre><span id="VALevery"><span class="keyword">val</span> every</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k -> 'v -> bool) -> bool</code></pre><div class="info ">
<div class="not-examples">
<code class="code">every m p</code> checks if all the bindings of the map
satisfy the predicate <code class="code">p</code>. Order unspecified<br>
</div>
</div>
<pre><span id="VALsomeU"><span class="keyword">val</span> someU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k -> 'v -> bool [@bs]) -> bool</code></pre>
<pre><span id="VALsome"><span class="keyword">val</span> some</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k -> 'v -> bool) -> bool</code></pre><div class="info ">
<div class="not-examples">
<code class="code">some m p</code> checks if at least one binding of the map
satisfy the predicate <code class="code">p</code>. Order unspecified<br>
</div>
</div>
<pre><span id="VALsize"><span class="keyword">val</span> size</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> int</code></pre><div class="info ">
<div class="not-examples">
<code class="code">size s</code><br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> size (fromArray [2,"2"; 2,"1"; 3,"3"] ~id:(module IntCmp)) = 2 ;;
</code></pre> </pre>
</div>
</div>
<pre><span id="VALtoArray"><span class="keyword">val</span> toArray</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k * 'v) array</code></pre><div class="info ">
<div class="not-examples">
<code class="code">toArray s</code><br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> toArray (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) = [1,"1";2,"2";3,"3"]
</code></pre> </pre>
</div>
</div>
<pre><span id="VALtoList"><span class="keyword">val</span> toList</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k * 'v) list</code></pre><div class="info ">
<div class="not-examples">
In increasing order
<b>See</b> <a href="Belt_Map.html#VALtoArray"><code class="code">Belt_Map.toArray</code></a><br>
</div>
</div>
<pre><span id="VALfromArray"><span class="keyword">val</span> fromArray</span> : <code class="type">('k * 'v) array -> id:('k, 'id) <a href="Belt_Map.html#TYPEid">id</a> -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">fromArray kvs ~id</code><br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> toArray (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) = [1,"1";2,"2";3,"3"]
</code></pre> </pre>
</div>
</div>
<pre><span id="VALkeysToArray"><span class="keyword">val</span> keysToArray</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'k array</code></pre><div class="info ">
<div class="not-examples">
<code class="code">keysToArray s</code><br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> keysToArray (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) =
[|1;2;3|];;
</code></pre> </pre>
</div>
</div>
<pre><span id="VALvaluesToArray"><span class="keyword">val</span> valuesToArray</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'v array</code></pre><div class="info ">
<div class="not-examples">
<code class="code">valuesToArray s</code><br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> valuesToArray (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) =
[|"1";"2";"3"|];;
</code></pre> </pre>
</div>
</div>
<pre><span id="VALminKey"><span class="keyword">val</span> minKey</span> : <code class="type">('k, 'a, 'b) <a href="Belt_Map.html#TYPEt">t</a> -> 'k option</code></pre><div class="info ">
<div class="not-examples">
<code class="code">minKey s</code><br>
<div class="tag"> <li><b>Returns</b> the minimum key, None if not exist</li>
</div>
</div>
</div>
<pre><span id="VALminKeyUndefined"><span class="keyword">val</span> minKeyUndefined</span> : <code class="type">('k, 'a, 'b) <a href="Belt_Map.html#TYPEt">t</a> -> 'k <a href="Js.html#TYPEundefined">Js.undefined</a></code></pre><div class="info ">
<div class="not-examples">
<b>See</b> <a href="Belt_Map.html#VALminKey"><code class="code">Belt_Map.minKey</code></a><br>
</div>
</div>
<pre><span id="VALmaxKey"><span class="keyword">val</span> maxKey</span> : <code class="type">('k, 'a, 'b) <a href="Belt_Map.html#TYPEt">t</a> -> 'k option</code></pre><div class="info ">
<div class="not-examples">
<code class="code">maxKey s</code><br>
<div class="tag"> <li><b>Returns</b> the maximum key, None if not exist</li>
</div>
</div>
</div>
<pre><span id="VALmaxKeyUndefined"><span class="keyword">val</span> maxKeyUndefined</span> : <code class="type">('k, 'a, 'b) <a href="Belt_Map.html#TYPEt">t</a> -> 'k <a href="Js.html#TYPEundefined">Js.undefined</a></code></pre><div class="info ">
<div class="not-examples">
<b>See</b> <a href="Belt_Map.html#VALmaxKey"><code class="code">Belt_Map.maxKey</code></a><br>
</div>
</div>
<pre><span id="VALminimum"><span class="keyword">val</span> minimum</span> : <code class="type">('k, 'v, 'a) <a href="Belt_Map.html#TYPEt">t</a> -> ('k * 'v) option</code></pre><div class="info ">
<div class="not-examples">
<code class="code">minimum s</code><br>
<div class="tag"> <li><b>Returns</b> the minimum key value pair, None if not exist</li>
</div>
</div>
</div>
<pre><span id="VALminUndefined"><span class="keyword">val</span> minUndefined</span> : <code class="type">('k, 'v, 'a) <a href="Belt_Map.html#TYPEt">t</a> -> ('k * 'v) <a href="Js.html#TYPEundefined">Js.undefined</a></code></pre><div class="info ">
<div class="not-examples">
<b>See</b> <a href="Belt_Map.html#VALminimum"><code class="code">Belt_Map.minimum</code></a><br>
</div>
</div>
<pre><span id="VALmaximum"><span class="keyword">val</span> maximum</span> : <code class="type">('k, 'v, 'a) <a href="Belt_Map.html#TYPEt">t</a> -> ('k * 'v) option</code></pre><div class="info ">
<div class="not-examples">
<code class="code">maximum s</code><br>
<div class="tag"> <li><b>Returns</b> the maximum key value pair, None if not exist</li>
</div>
</div>
</div>
<pre><span id="VALmaxUndefined"><span class="keyword">val</span> maxUndefined</span> : <code class="type">('k, 'v, 'a) <a href="Belt_Map.html#TYPEt">t</a> -> ('k * 'v) <a href="Js.html#TYPEundefined">Js.undefined</a></code></pre><div class="info ">
<div class="not-examples">
<b>See</b> <a href="Belt_Map.html#VALmaximum"><code class="code">Belt_Map.maximum</code></a><br>
</div>
</div>
<pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'k -> 'v option</code></pre><div class="info ">
<div class="not-examples">
<code class="code">get s k</code><br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> get (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) 2 =
Some "2";;
get (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) 2 =
None;;
</code></pre> </pre>
</div>
</div>
<pre><span id="VALgetUndefined"><span class="keyword">val</span> getUndefined</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'k -> 'v <a href="Js.html#TYPEundefined">Js.undefined</a></code></pre><div class="info ">
<div class="not-examples">
<b>See</b> <a href="Belt_Map.html#VALget"><code class="code">Belt_Map.get</code></a><br>
<div class="tag"> <li><b>Returns</b> <code class="code">undefined</code> when not found</li>
</div>
</div>
</div>
<pre><span id="VALgetWithDefault"><span class="keyword">val</span> getWithDefault</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'k -> 'v -> 'v</code></pre><div class="info ">
<div class="not-examples">
<code class="code">getWithDefault s k default</code>
<b>See</b> <a href="Belt_Map.html#VALget"><code class="code">Belt_Map.get</code></a><br>
<div class="tag"> <li><b>Returns</b> <code class="code">default</code> when <code class="code">k</code> is not found</li>
</div>
</div>
</div>
<pre><span id="VALgetExn"><span class="keyword">val</span> getExn</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'k -> 'v</code></pre><div class="info ">
<div class="not-examples">
<code class="code">getExn s k</code>
<b>See</b> <a href="Belt_Map.html#VALgetExn"><code class="code">Belt_Map.getExn</code></a>
<b>raise</b> when <code class="code">k</code> not exist<br>
</div>
</div>
<pre><span id="VALremove"><span class="keyword">val</span> remove</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'k -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">remove m x</code> when <code class="code">x</code> is not in <code class="code">m</code>, <code class="code">m</code> is returned reference unchanged.<br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> let s0 = (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp));;
let s1 = remove s0 1;;
let s2 = remove s1 1;;
s1 == s2 ;;
keysToArray s1 = [|2;3|];;
</code></pre> </pre>
</div>
</div>
<pre><span id="VALremoveMany"><span class="keyword">val</span> removeMany</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'k array -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">removeMany s xs</code>
Removing each of <code class="code">xs</code> to <code class="code">s</code>, note unlike <a href="Belt_Map.html#VALremove"><code class="code">Belt_Map.remove</code></a>,
the reference of return value might be changed even if none in <code class="code">xs</code>
exists <code class="code">s</code><br>
</div>
</div>
<pre><span id="VALset"><span class="keyword">val</span> set</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> 'k -> 'v -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">set m x y </code> returns a map containing the same bindings as
<code class="code">m</code>, with a new binding of <code class="code">x</code> to <code class="code">y</code>. If <code class="code">x</code> was already bound
in <code class="code">m</code>, its previous binding disappears.<br>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code"> let s0 = (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp));;
let s1 = set s0 2 "3";;
valuesToArray s1 = ["1";"3";"3"];;
</code></pre> </pre>
</div>
</div>
<pre><span id="VALupdateU"><span class="keyword">val</span> updateU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> 'k -> ('v option -> 'v option [@bs]) -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre>
<pre><span id="VALupdate"><span class="keyword">val</span> update</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> 'k -> ('v option -> 'v option) -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">update m x f</code> returns a map containing the same bindings as
<code class="code">m</code>, except for the binding of <code class="code">x</code>.
Depending on the value of
<code class="code">y</code> where <code class="code">y</code> is <code class="code">f (get x m)</code>, the binding of <code class="code">x</code> is
added, removed or updated. If <code class="code">y</code> is <code class="code">None</code>, the binding is
removed if it exists; otherwise, if <code class="code">y</code> is <code class="code">Some z</code> then <code class="code">x</code>
is associated to <code class="code">z</code> in the resulting map.<br>
</div>
</div>
<pre><span id="VALmergeMany"><span class="keyword">val</span> mergeMany</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k * 'v) array -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">mergeMany s xs</code>
Adding each of <code class="code">xs</code> to <code class="code">s</code>, note unlike <code class="code">add</code>,
the reference of return value might be changed even if all values in <code class="code">xs</code>
exist <code class="code">s</code><br>
</div>
</div>
<pre><span id="VALmergeU"><span class="keyword">val</span> mergeU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k, 'v2, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k -> 'v option -> 'v2 option -> 'v3 option [@bs]) -><br> ('k, 'v3, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre>
<pre><span id="VALmerge"><span class="keyword">val</span> merge</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k, 'v2, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k -> 'v option -> 'v2 option -> 'v3 option) -> ('k, 'v3, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">merge m1 m2 f</code> computes a map whose keys is a subset of keys of <code class="code">m1</code>
and of <code class="code">m2</code>. The presence of each such binding, and the corresponding
value, is determined with the function <code class="code">f</code>.<br>
</div>
</div>
<pre><span id="VALkeepU"><span class="keyword">val</span> keepU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k -> 'v -> bool [@bs]) -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre>
<pre><span id="VALkeep"><span class="keyword">val</span> keep</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k -> 'v -> bool) -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">keep m p</code> returns the map with all the bindings in <code class="code">m</code>
that satisfy predicate <code class="code">p</code>.<br>
</div>
</div>
<pre><span id="VALpartitionU"><span class="keyword">val</span> partitionU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k -> 'v -> bool [@bs]) -><br> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> * ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre>
<pre><span id="VALpartition"><span class="keyword">val</span> partition</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k -> 'v -> bool) -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> * ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">partition m p</code> returns a pair of maps <code class="code">(m1, m2)</code>, where
<code class="code">m1</code> contains all the bindings of <code class="code">s</code> that satisfy the
predicate <code class="code">p</code>, and <code class="code">m2</code> is the map with all the bindings of
<code class="code">s</code> that do not satisfy <code class="code">p</code>.<br>
</div>
</div>
<pre><span id="VALsplit"><span class="keyword">val</span> split</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> 'k -> (('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> * ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a>) * 'v option</code></pre><div class="info ">
<div class="not-examples">
<code class="code">split x m</code> returns a tuple <code class="code">(l r), data</code>, where
<code class="code">l</code> is the map with all the bindings of <code class="code">m</code> whose 'k
is strictly less than <code class="code">x</code>;
<code class="code">r</code> is the map with all the bindings of <code class="code">m</code> whose 'k
is strictly greater than <code class="code">x</code>;
<code class="code">data</code> is <code class="code">None</code> if <code class="code">m</code> contains no binding for <code class="code">x</code>,
or <code class="code">Some v</code> if <code class="code">m</code> binds <code class="code">v</code> to <code class="code">x</code>.<br>
</div>
</div>
<pre><span id="VALmapU"><span class="keyword">val</span> mapU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('v -> 'v2 [@bs]) -> ('k, 'v2, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre>
<pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('v -> 'v2) -> ('k, 'v2, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">map m f</code> returns a map with same domain as <code class="code">m</code>, where the
associated value <code class="code">a</code> of all bindings of <code class="code">m</code> has been
replaced by the result of the application of <code class="code">f</code> to <code class="code">a</code>.
The bindings are passed to <code class="code">f</code> in increasing order
with respect to the ordering over the type of the keys.<br>
</div>
</div>
<pre><span id="VALmapWithKeyU"><span class="keyword">val</span> mapWithKeyU</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -><br> ('k -> 'v -> 'v2 [@bs]) -> ('k, 'v2, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre>
<pre><span id="VALmapWithKey"><span class="keyword">val</span> mapWithKey</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k -> 'v -> 'v2) -> ('k, 'v2, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">mapWithKey m f</code>
The same as <a href="Belt_Map.html#VALmap"><code class="code">Belt_Map.map</code></a> except that <code class="code">f</code> is supplied with one more argument: the key<br>
</div>
</div>
<pre><span id="VALgetData"><span class="keyword">val</span> getData</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k, 'v, 'id) <a href="Belt_MapDict.html#TYPEt">Belt_MapDict.t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">getData s0</code>
<b>Advanced usage only</b><br>
<div class="tag"> <li><b>Returns</b> the raw data (detached from comparator),
but its type is still manifested, so that user can pass identity directly
without boxing</li>
</div>
</div>
</div>
<pre><span id="VALgetId"><span class="keyword">val</span> getId</span> : <code class="type">('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a> -> ('k, 'id) <a href="Belt_Map.html#TYPEid">id</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">getId s0</code>
<b>Advanced usage only</b><br>
<div class="tag"> <li><b>Returns</b> the identity of <code class="code">s0</code></li>
</div>
</div>
</div>
<pre><span id="VALpackIdData"><span class="keyword">val</span> packIdData</span> : <code class="type">id:('k, 'id) <a href="Belt_Map.html#TYPEid">id</a> -><br> data:('k, 'v, 'id) <a href="Belt_MapDict.html#TYPEt">Belt_MapDict.t</a> -> ('k, 'v, 'id) <a href="Belt_Map.html#TYPEt">t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">packIdData ~id ~data</code>
<b>Advanced usage only</b><br>
<div class="tag"> <li><b>Returns</b> the packed collection</li>
</div>
</div>
</div>
</body></html>