Source file map_intf.ml
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
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
open! Import
open! T
module Or_duplicate = struct
type 'a t =
[ `Ok of 'a
| `Duplicate
]
[@@deriving_inline compare, equal, sexp_of]
let compare : 'a. ('a -> 'a -> int) -> 'a t -> 'a t -> int =
fun _cmp__a a__001_ b__002_ ->
if Ppx_compare_lib.phys_equal a__001_ b__002_
then 0
else (
match a__001_, b__002_ with
| `Ok _left__003_, `Ok _right__004_ -> _cmp__a _left__003_ _right__004_
| `Duplicate, `Duplicate -> 0
| x, y -> Ppx_compare_lib.polymorphic_compare x y)
;;
let equal : 'a. ('a -> 'a -> bool) -> 'a t -> 'a t -> bool =
fun _cmp__a a__005_ b__006_ ->
if Ppx_compare_lib.phys_equal a__005_ b__006_
then true
else (
match a__005_, b__006_ with
| `Ok _left__007_, `Ok _right__008_ -> _cmp__a _left__007_ _right__008_
| `Duplicate, `Duplicate -> true
| x, y -> Ppx_compare_lib.polymorphic_equal x y)
;;
let sexp_of_t : 'a. ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t =
fun _of_a__009_ -> function
| `Ok v__010_ -> Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "Ok"; _of_a__009_ v__010_ ]
| `Duplicate -> Sexplib0.Sexp.Atom "Duplicate"
;;
[@@@end]
end
module Without_comparator = struct
type ('key, 'cmp, 'z) t = 'z
end
module With_comparator = struct
type ('key, 'cmp, 'z) t = comparator:('key, 'cmp) Comparator.t -> 'z
end
module With_first_class_module = struct
type ('key, 'cmp, 'z) t = ('key, 'cmp) Comparator.Module.t -> 'z
end
module Symmetric_diff_element = struct
type ('k, 'v) t = 'k * [ `Left of 'v | `Right of 'v | `Unequal of 'v * 'v ]
[@@deriving_inline compare, equal, sexp, sexp_grammar]
let compare :
'k 'v. ('k -> 'k -> int) -> ('v -> 'v -> int) -> ('k, 'v) t -> ('k, 'v) t -> int
=
fun _cmp__k _cmp__v a__011_ b__012_ ->
let t__013_, t__014_ = a__011_ in
let t__015_, t__016_ = b__012_ in
match _cmp__k t__013_ t__015_ with
| 0 ->
if Ppx_compare_lib.phys_equal t__014_ t__016_
then 0
else (
match t__014_, t__016_ with
| `Left _left__017_, `Left _right__018_ -> _cmp__v _left__017_ _right__018_
| `Right _left__019_, `Right _right__020_ -> _cmp__v _left__019_ _right__020_
| `Unequal _left__021_, `Unequal _right__022_ ->
let t__023_, t__024_ = _left__021_ in
let t__025_, t__026_ = _right__022_ in
(match _cmp__v t__023_ t__025_ with
| 0 -> _cmp__v t__024_ t__026_
| n -> n)
| x, y -> Ppx_compare_lib.polymorphic_compare x y)
| n -> n
;;
let equal :
'k 'v.
('k -> 'k -> bool) -> ('v -> 'v -> bool) -> ('k, 'v) t -> ('k, 'v) t -> bool
=
fun _cmp__k _cmp__v a__027_ b__028_ ->
let t__029_, t__030_ = a__027_ in
let t__031_, t__032_ = b__028_ in
Ppx_compare_lib.( && )
(_cmp__k t__029_ t__031_)
(if Ppx_compare_lib.phys_equal t__030_ t__032_
then true
else (
match t__030_, t__032_ with
| `Left _left__033_, `Left _right__034_ -> _cmp__v _left__033_ _right__034_
| `Right _left__035_, `Right _right__036_ -> _cmp__v _left__035_ _right__036_
| `Unequal _left__037_, `Unequal _right__038_ ->
let t__039_, t__040_ = _left__037_ in
let t__041_, t__042_ = _right__038_ in
Ppx_compare_lib.( && ) (_cmp__v t__039_ t__041_) (_cmp__v t__040_ t__042_)
| x, y -> Ppx_compare_lib.polymorphic_equal x y))
;;
let t_of_sexp :
'k 'v.
(Sexplib0.Sexp.t -> 'k)
-> (Sexplib0.Sexp.t -> 'v)
-> Sexplib0.Sexp.t
-> ('k, 'v) t
=
let error_source__057_ = "map_intf.ml.Symmetric_diff_element.t" in
fun _of_k__043_ _of_v__044_ -> function
| Sexplib0.Sexp.List [ arg0__067_; arg1__068_ ] ->
let res0__069_ = _of_k__043_ arg0__067_
and res1__070_ =
let sexp__066_ = arg1__068_ in
try
match sexp__066_ with
| Sexplib0.Sexp.Atom atom__047_ as _sexp__049_ ->
(match atom__047_ with
| "Left" ->
Sexplib0.Sexp_conv_error.ptag_takes_args error_source__057_ _sexp__049_
| "Right" ->
Sexplib0.Sexp_conv_error.ptag_takes_args error_source__057_ _sexp__049_
| "Unequal" ->
Sexplib0.Sexp_conv_error.ptag_takes_args error_source__057_ _sexp__049_
| _ -> Sexplib0.Sexp_conv_error.no_variant_match ())
| Sexplib0.Sexp.List (Sexplib0.Sexp.Atom atom__047_ :: sexp_args__050_) as
_sexp__049_ ->
(match atom__047_ with
| "Left" as _tag__063_ ->
(match sexp_args__050_ with
| [ arg0__064_ ] ->
let res0__065_ = _of_v__044_ arg0__064_ in
`Left res0__065_
| _ ->
Sexplib0.Sexp_conv_error.ptag_incorrect_n_args
error_source__057_
_tag__063_
_sexp__049_)
| "Right" as _tag__060_ ->
(match sexp_args__050_ with
| [ arg0__061_ ] ->
let res0__062_ = _of_v__044_ arg0__061_ in
`Right res0__062_
| _ ->
Sexplib0.Sexp_conv_error.ptag_incorrect_n_args
error_source__057_
_tag__060_
_sexp__049_)
| "Unequal" as _tag__051_ ->
(match sexp_args__050_ with
| [ arg0__058_ ] ->
let res0__059_ =
match arg0__058_ with
| Sexplib0.Sexp.List [ arg0__052_; arg1__053_ ] ->
let res0__054_ = _of_v__044_ arg0__052_
and res1__055_ = _of_v__044_ arg1__053_ in
res0__054_, res1__055_
| sexp__056_ ->
Sexplib0.Sexp_conv_error.tuple_of_size_n_expected
error_source__057_
2
sexp__056_
in
`Unequal res0__059_
| _ ->
Sexplib0.Sexp_conv_error.ptag_incorrect_n_args
error_source__057_
_tag__051_
_sexp__049_)
| _ -> Sexplib0.Sexp_conv_error.no_variant_match ())
| Sexplib0.Sexp.List (Sexplib0.Sexp.List _ :: _) as sexp__048_ ->
Sexplib0.Sexp_conv_error.nested_list_invalid_poly_var
error_source__057_
sexp__048_
| Sexplib0.Sexp.List [] as sexp__048_ ->
Sexplib0.Sexp_conv_error.empty_list_invalid_poly_var
error_source__057_
sexp__048_
with
| Sexplib0.Sexp_conv_error.No_variant_match ->
Sexplib0.Sexp_conv_error.no_matching_variant_found
error_source__057_
sexp__066_
in
res0__069_, res1__070_
| sexp__071_ ->
Sexplib0.Sexp_conv_error.tuple_of_size_n_expected error_source__057_ 2 sexp__071_
;;
let sexp_of_t :
'k 'v.
('k -> Sexplib0.Sexp.t)
-> ('v -> Sexplib0.Sexp.t)
-> ('k, 'v) t
-> Sexplib0.Sexp.t
=
fun _of_k__072_ _of_v__073_ (arg0__081_, arg1__082_) ->
let res0__083_ = _of_k__072_ arg0__081_
and res1__084_ =
match arg1__082_ with
| `Left v__074_ ->
Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "Left"; _of_v__073_ v__074_ ]
| `Right v__075_ ->
Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "Right"; _of_v__073_ v__075_ ]
| `Unequal v__076_ ->
Sexplib0.Sexp.List
[ Sexplib0.Sexp.Atom "Unequal"
; (let arg0__077_, arg1__078_ = v__076_ in
let res0__079_ = _of_v__073_ arg0__077_
and res1__080_ = _of_v__073_ arg1__078_ in
Sexplib0.Sexp.List [ res0__079_; res1__080_ ])
]
in
Sexplib0.Sexp.List [ res0__083_; res1__084_ ]
;;
let (t_sexp_grammar :
'k Sexplib0.Sexp_grammar.t
-> 'v Sexplib0.Sexp_grammar.t
-> ('k, 'v) t Sexplib0.Sexp_grammar.t)
=
fun _'k_sexp_grammar _'v_sexp_grammar ->
{ untyped =
List
(Cons
( _'k_sexp_grammar.untyped
, Cons
( Variant
{ case_sensitivity = Case_sensitive
; clauses =
[ No_tag
{ name = "Left"
; clause_kind =
List_clause
{ args = Cons (_'v_sexp_grammar.untyped, Empty) }
}
; No_tag
{ name = "Right"
; clause_kind =
List_clause
{ args = Cons (_'v_sexp_grammar.untyped, Empty) }
}
; No_tag
{ name = "Unequal"
; clause_kind =
List_clause
{ args =
Cons
( List
(Cons
( _'v_sexp_grammar.untyped
, Cons (_'v_sexp_grammar.untyped, Empty)
))
, Empty )
}
}
]
}
, Empty ) ))
}
;;
[@@@end]
end
module Merge_element = struct
type ('left, 'right) t =
[ `Left of 'left
| `Right of 'right
| `Both of 'left * 'right
]
[@@deriving_inline compare, equal, sexp_of]
let compare :
'left 'right.
('left -> 'left -> int)
-> ('right -> 'right -> int)
-> ('left, 'right) t
-> ('left, 'right) t
-> int
=
fun _cmp__left _cmp__right a__085_ b__086_ ->
if Ppx_compare_lib.phys_equal a__085_ b__086_
then 0
else (
match a__085_, b__086_ with
| `Left _left__087_, `Left _right__088_ -> _cmp__left _left__087_ _right__088_
| `Right _left__089_, `Right _right__090_ -> _cmp__right _left__089_ _right__090_
| `Both _left__091_, `Both _right__092_ ->
let t__093_, t__094_ = _left__091_ in
let t__095_, t__096_ = _right__092_ in
(match _cmp__left t__093_ t__095_ with
| 0 -> _cmp__right t__094_ t__096_
| n -> n)
| x, y -> Ppx_compare_lib.polymorphic_compare x y)
;;
let equal :
'left 'right.
('left -> 'left -> bool)
-> ('right -> 'right -> bool)
-> ('left, 'right) t
-> ('left, 'right) t
-> bool
=
fun _cmp__left _cmp__right a__097_ b__098_ ->
if Ppx_compare_lib.phys_equal a__097_ b__098_
then true
else (
match a__097_, b__098_ with
| `Left _left__099_, `Left _right__100_ -> _cmp__left _left__099_ _right__100_
| `Right _left__101_, `Right _right__102_ -> _cmp__right _left__101_ _right__102_
| `Both _left__103_, `Both _right__104_ ->
let t__105_, t__106_ = _left__103_ in
let t__107_, t__108_ = _right__104_ in
Ppx_compare_lib.( && ) (_cmp__left t__105_ t__107_) (_cmp__right t__106_ t__108_)
| x, y -> Ppx_compare_lib.polymorphic_equal x y)
;;
let sexp_of_t :
'left 'right.
('left -> Sexplib0.Sexp.t)
-> ('right -> Sexplib0.Sexp.t)
-> ('left, 'right) t
-> Sexplib0.Sexp.t
=
fun _of_left__109_ _of_right__110_ -> function
| `Left v__111_ ->
Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "Left"; _of_left__109_ v__111_ ]
| `Right v__112_ ->
Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "Right"; _of_right__110_ v__112_ ]
| `Both v__113_ ->
Sexplib0.Sexp.List
[ Sexplib0.Sexp.Atom "Both"
; (let arg0__114_, arg1__115_ = v__113_ in
let res0__116_ = _of_left__109_ arg0__114_
and res1__117_ = _of_right__110_ arg1__115_ in
Sexplib0.Sexp.List [ res0__116_; res1__117_ ])
]
;;
[@@@end]
end
(** @canonical Base.Map.Continue_or_stop *)
module Continue_or_stop = struct
type t =
| Continue
| Stop
[@@deriving_inline compare, enumerate, equal, sexp_of]
let compare = (Ppx_compare_lib.polymorphic_compare : t -> t -> int)
let all = ([ Continue; Stop ] : t list)
let equal = (Ppx_compare_lib.polymorphic_equal : t -> t -> bool)
let sexp_of_t =
(function
| Continue -> Sexplib0.Sexp.Atom "Continue"
| Stop -> Sexplib0.Sexp.Atom "Stop"
: t -> Sexplib0.Sexp.t)
;;
[@@@end]
end
(** @canonical Base.Map.Finished_or_unfinished *)
module Finished_or_unfinished = struct
type t =
| Finished
| Unfinished
[@@deriving_inline compare, enumerate, equal, sexp_of]
let compare = (Ppx_compare_lib.polymorphic_compare : t -> t -> int)
let all = ([ Finished; Unfinished ] : t list)
let equal = (Ppx_compare_lib.polymorphic_equal : t -> t -> bool)
let sexp_of_t =
(function
| Finished -> Sexplib0.Sexp.Atom "Finished"
| Unfinished -> Sexplib0.Sexp.Atom "Unfinished"
: t -> Sexplib0.Sexp.t)
;;
[@@@end]
end
module type Accessors_generic = sig
type ('a, 'b, 'cmp) t
type ('a, 'b, 'cmp) tree
type 'a key
type 'cmp cmp
type ('a, 'cmp, 'z) options
val invariants : ('k, 'cmp, ('k, 'v, 'cmp) t -> bool) options
val is_empty : (_, _, _) t -> bool
val length : (_, _, _) t -> int
val add
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t -> key:'k key -> data:'v -> ('k, 'v, 'cmp) t Or_duplicate.t )
options
val add_exn
: ('k, 'cmp, ('k, 'v, 'cmp) t -> key:'k key -> data:'v -> ('k, 'v, 'cmp) t) options
val set
: ('k, 'cmp, ('k, 'v, 'cmp) t -> key:'k key -> data:'v -> ('k, 'v, 'cmp) t) options
val add_multi
: ( 'k
, 'cmp
, ('k, 'v list, 'cmp) t -> key:'k key -> data:'v -> ('k, 'v list, 'cmp) t )
options
val remove_multi
: ('k, 'cmp, ('k, 'v list, 'cmp) t -> 'k key -> ('k, 'v list, 'cmp) t) options
val find_multi : ('k, 'cmp, ('k, 'v list, 'cmp) t -> 'k key -> 'v list) options
val change
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t -> 'k key -> f:('v option -> 'v option) -> ('k, 'v, 'cmp) t )
options
val update
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t -> 'k key -> f:('v option -> 'v) -> ('k, 'v, 'cmp) t )
options
val find : ('k, 'cmp, ('k, 'v, 'cmp) t -> 'k key -> 'v option) options
val find_exn : ('k, 'cmp, ('k, 'v, 'cmp) t -> 'k key -> 'v) options
val remove : ('k, 'cmp, ('k, 'v, 'cmp) t -> 'k key -> ('k, 'v, 'cmp) t) options
val mem : ('k, 'cmp, ('k, _, 'cmp) t -> 'k key -> bool) options
val iter_keys : ('k, _, _) t -> f:('k key -> unit) -> unit
val iter : (_, 'v, _) t -> f:('v -> unit) -> unit
val iteri : ('k, 'v, _) t -> f:(key:'k key -> data:'v -> unit) -> unit
val iteri_until
: ('k, 'v, _) t
-> f:(key:'k key -> data:'v -> Continue_or_stop.t)
-> Finished_or_unfinished.t
val iter2
: ( 'k
, 'cmp
, ('k, 'v1, 'cmp) t
-> ('k, 'v2, 'cmp) t
-> f:(key:'k key -> data:('v1, 'v2) Merge_element.t -> unit)
-> unit )
options
val map : ('k, 'v1, 'cmp) t -> f:('v1 -> 'v2) -> ('k, 'v2, 'cmp) t
val mapi : ('k, 'v1, 'cmp) t -> f:(key:'k key -> data:'v1 -> 'v2) -> ('k, 'v2, 'cmp) t
val fold : ('k, 'v, _) t -> init:'a -> f:(key:'k key -> data:'v -> 'a -> 'a) -> 'a
val fold_until
: ('k, 'v, _) t
-> init:'a
-> f:(key:'k key -> data:'v -> 'a -> ('a, 'final) Container.Continue_or_stop.t)
-> finish:('a -> 'final)
-> 'final
val fold_right : ('k, 'v, _) t -> init:'a -> f:(key:'k key -> data:'v -> 'a -> 'a) -> 'a
val fold2
: ( 'k
, 'cmp
, ('k, 'v1, 'cmp) t
-> ('k, 'v2, 'cmp) t
-> init:'a
-> f:(key:'k key -> data:('v1, 'v2) Merge_element.t -> 'a -> 'a)
-> 'a )
options
val filter_keys
: ('k, 'cmp, ('k, 'v, 'cmp) t -> f:('k key -> bool) -> ('k, 'v, 'cmp) t) options
val filter : ('k, 'cmp, ('k, 'v, 'cmp) t -> f:('v -> bool) -> ('k, 'v, 'cmp) t) options
val filteri
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t -> f:(key:'k key -> data:'v -> bool) -> ('k, 'v, 'cmp) t )
options
val filter_map
: ('k, 'cmp, ('k, 'v1, 'cmp) t -> f:('v1 -> 'v2 option) -> ('k, 'v2, 'cmp) t) options
val filter_mapi
: ( 'k
, 'cmp
, ('k, 'v1, 'cmp) t -> f:(key:'k key -> data:'v1 -> 'v2 option) -> ('k, 'v2, 'cmp) t
)
options
val partition_mapi
: ( 'k
, 'cmp
, ('k, 'v1, 'cmp) t
-> f:(key:'k key -> data:'v1 -> ('v2, 'v3) Either.t)
-> ('k, 'v2, 'cmp) t * ('k, 'v3, 'cmp) t )
options
val partition_map
: ( 'k
, 'cmp
, ('k, 'v1, 'cmp) t
-> f:('v1 -> ('v2, 'v3) Either.t)
-> ('k, 'v2, 'cmp) t * ('k, 'v3, 'cmp) t )
options
val partitioni_tf
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t
-> f:(key:'k key -> data:'v -> bool)
-> ('k, 'v, 'cmp) t * ('k, 'v, 'cmp) t )
options
val partition_tf
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t -> f:('v -> bool) -> ('k, 'v, 'cmp) t * ('k, 'v, 'cmp) t )
options
val combine_errors
: ('k, 'cmp, ('k, 'v Or_error.t, 'cmp) t -> ('k, 'v, 'cmp) t Or_error.t) options
val compare_direct
: ('k, 'cmp, ('v -> 'v -> int) -> ('k, 'v, 'cmp) t -> ('k, 'v, 'cmp) t -> int) options
val equal
: ( 'k
, 'cmp
, ('v -> 'v -> bool) -> ('k, 'v, 'cmp) t -> ('k, 'v, 'cmp) t -> bool )
options
val keys : ('k, _, _) t -> 'k key list
val data : (_, 'v, _) t -> 'v list
val to_alist
: ?key_order:[ `Increasing | `Decreasing ]
-> ('k, 'v, _) t
-> ('k key * 'v) list
val merge
: ( 'k
, 'cmp
, ('k, 'v1, 'cmp) t
-> ('k, 'v2, 'cmp) t
-> f:(key:'k key -> ('v1, 'v2) Merge_element.t -> 'v3 option)
-> ('k, 'v3, 'cmp) t )
options
val merge_skewed
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t
-> ('k, 'v, 'cmp) t
-> combine:(key:'k key -> 'v -> 'v -> 'v)
-> ('k, 'v, 'cmp) t )
options
val symmetric_diff
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t
-> ('k, 'v, 'cmp) t
-> data_equal:('v -> 'v -> bool)
-> ('k key, 'v) Symmetric_diff_element.t Sequence.t )
options
val fold_symmetric_diff
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t
-> ('k, 'v, 'cmp) t
-> data_equal:('v -> 'v -> bool)
-> init:'a
-> f:('a -> ('k key, 'v) Symmetric_diff_element.t -> 'a)
-> 'a )
options
val min_elt : ('k, 'v, _) t -> ('k key * 'v) option
val min_elt_exn : ('k, 'v, _) t -> 'k key * 'v
val max_elt : ('k, 'v, _) t -> ('k key * 'v) option
val max_elt_exn : ('k, 'v, _) t -> 'k key * 'v
val for_all : ('k, 'v, _) t -> f:('v -> bool) -> bool
val for_alli : ('k, 'v, _) t -> f:(key:'k key -> data:'v -> bool) -> bool
val exists : ('k, 'v, _) t -> f:('v -> bool) -> bool
val existsi : ('k, 'v, _) t -> f:(key:'k key -> data:'v -> bool) -> bool
val count : ('k, 'v, _) t -> f:('v -> bool) -> int
val counti : ('k, 'v, _) t -> f:(key:'k key -> data:'v -> bool) -> int
val split
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t
-> 'k key
-> ('k, 'v, 'cmp) t * ('k key * 'v) option * ('k, 'v, 'cmp) t )
options
val append
: ( 'k
, 'cmp
, lower_part:('k, 'v, 'cmp) t
-> upper_part:('k, 'v, 'cmp) t
-> [ `Ok of ('k, 'v, 'cmp) t | `Overlapping_key_ranges ] )
options
val subrange
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t
-> lower_bound:'k key Maybe_bound.t
-> upper_bound:'k key Maybe_bound.t
-> ('k, 'v, 'cmp) t )
options
val fold_range_inclusive
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t
-> min:'k key
-> max:'k key
-> init:'a
-> f:(key:'k key -> data:'v -> 'a -> 'a)
-> 'a )
options
val range_to_alist
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t -> min:'k key -> max:'k key -> ('k key * 'v) list )
options
val closest_key
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t
-> [ `Greater_or_equal_to | `Greater_than | `Less_or_equal_to | `Less_than ]
-> 'k key
-> ('k key * 'v) option )
options
val nth : ('k, 'v, 'cmp) t -> int -> ('k key * 'v) option
val nth_exn : ('k, 'v, 'cmp) t -> int -> 'k key * 'v
val rank : ('k, 'cmp, ('k, _, 'cmp) t -> 'k key -> int option) options
val to_tree : ('k, 'v, 'cmp) t -> ('k key, 'v, 'cmp) tree
val to_sequence
: ( 'k
, 'cmp
, ?order:[ `Increasing_key | `Decreasing_key ]
-> ?keys_greater_or_equal_to:'k key
-> ?keys_less_or_equal_to:'k key
-> ('k, 'v, 'cmp) t
-> ('k key * 'v) Sequence.t )
options
val binary_search
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t
-> compare:(key:'k key -> data:'v -> 'key -> int)
-> Binary_searchable.Which_target_by_key.t
-> 'key
-> ('k key * 'v) option )
options
val binary_search_segmented
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t
-> segment_of:(key:'k key -> data:'v -> [ `Left | `Right ])
-> Binary_searchable.Which_target_by_segment.t
-> ('k key * 'v) option )
options
val binary_search_subrange
: ( 'k
, 'cmp
, ('k, 'v, 'cmp) t
-> compare:(key:'k key -> data:'v -> 'bound -> int)
-> lower_bound:'bound Maybe_bound.t
-> upper_bound:'bound Maybe_bound.t
-> ('k, 'v, 'cmp) t )
options
end
module type Accessors1 = sig
type 'a t
type 'a tree
type key
type comparator_witness
val invariants : _ t -> bool
val is_empty : _ t -> bool
val length : _ t -> int
val add : 'a t -> key:key -> data:'a -> 'a t Or_duplicate.t
val add_exn : 'a t -> key:key -> data:'a -> 'a t
val set : 'a t -> key:key -> data:'a -> 'a t
val add_multi : 'a list t -> key:key -> data:'a -> 'a list t
val remove_multi : 'a list t -> key -> 'a list t
val find_multi : 'a list t -> key -> 'a list
val change : 'a t -> key -> f:('a option -> 'a option) -> 'a t
val update : 'a t -> key -> f:('a option -> 'a) -> 'a t
val find : 'a t -> key -> 'a option
val find_exn : 'a t -> key -> 'a
val remove : 'a t -> key -> 'a t
val mem : _ t -> key -> bool
val iter_keys : _ t -> f:(key -> unit) -> unit
val iter : 'a t -> f:('a -> unit) -> unit
val iteri : 'a t -> f:(key:key -> data:'a -> unit) -> unit
val iteri_until
: 'a t
-> f:(key:key -> data:'a -> Continue_or_stop.t)
-> Finished_or_unfinished.t
val iter2 : 'a t -> 'b t -> f:(key:key -> data:('a, 'b) Merge_element.t -> unit) -> unit
val map : 'a t -> f:('a -> 'b) -> 'b t
val mapi : 'a t -> f:(key:key -> data:'a -> 'b) -> 'b t
val fold : 'a t -> init:'b -> f:(key:key -> data:'a -> 'b -> 'b) -> 'b
val fold_until
: 'a t
-> init:'acc
-> f:(key:key -> data:'a -> 'acc -> ('acc, 'final) Container.Continue_or_stop.t)
-> finish:('acc -> 'final)
-> 'final
val fold_right : 'a t -> init:'b -> f:(key:key -> data:'a -> 'b -> 'b) -> 'b
val fold2
: 'a t
-> 'b t
-> init:'c
-> f:(key:key -> data:('a, 'b) Merge_element.t -> 'c -> 'c)
-> 'c
val filter_keys : 'a t -> f:(key -> bool) -> 'a t
val filter : 'a t -> f:('a -> bool) -> 'a t
val filteri : 'a t -> f:(key:key -> data:'a -> bool) -> 'a t
val filter_map : 'a t -> f:('a -> 'b option) -> 'b t
val filter_mapi : 'a t -> f:(key:key -> data:'a -> 'b option) -> 'b t
val partition_mapi : 'a t -> f:(key:key -> data:'a -> ('b, 'c) Either.t) -> 'b t * 'c t
val partition_map : 'a t -> f:('a -> ('b, 'c) Either.t) -> 'b t * 'c t
val partitioni_tf : 'a t -> f:(key:key -> data:'a -> bool) -> 'a t * 'a t
val partition_tf : 'a t -> f:('a -> bool) -> 'a t * 'a t
val combine_errors : 'a Or_error.t t -> 'a t Or_error.t
val compare_direct : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val keys : _ t -> key list
val data : 'a t -> 'a list
val to_alist : ?key_order:[ `Increasing | `Decreasing ] -> 'a t -> (key * 'a) list
val merge : 'a t -> 'b t -> f:(key:key -> ('a, 'b) Merge_element.t -> 'c option) -> 'c t
val merge_skewed : 'v t -> 'v t -> combine:(key:key -> 'v -> 'v -> 'v) -> 'v t
val symmetric_diff
: 'a t
-> 'a t
-> data_equal:('a -> 'a -> bool)
-> (key, 'a) Symmetric_diff_element.t Sequence.t
val fold_symmetric_diff
: 'a t
-> 'a t
-> data_equal:('a -> 'a -> bool)
-> init:'c
-> f:('c -> (key, 'a) Symmetric_diff_element.t -> 'c)
-> 'c
val min_elt : 'a t -> (key * 'a) option
val min_elt_exn : 'a t -> key * 'a
val max_elt : 'a t -> (key * 'a) option
val max_elt_exn : 'a t -> key * 'a
val for_all : 'a t -> f:('a -> bool) -> bool
val for_alli : 'a t -> f:(key:key -> data:'a -> bool) -> bool
val exists : 'a t -> f:('a -> bool) -> bool
val existsi : 'a t -> f:(key:key -> data:'a -> bool) -> bool
val count : 'a t -> f:('a -> bool) -> int
val counti : 'a t -> f:(key:key -> data:'a -> bool) -> int
val split : 'a t -> key -> 'a t * (key * 'a) option * 'a t
val append
: lower_part:'a t
-> upper_part:'a t
-> [ `Ok of 'a t | `Overlapping_key_ranges ]
val subrange
: 'a t
-> lower_bound:key Maybe_bound.t
-> upper_bound:key Maybe_bound.t
-> 'a t
val fold_range_inclusive
: 'a t
-> min:key
-> max:key
-> init:'b
-> f:(key:key -> data:'a -> 'b -> 'b)
-> 'b
val range_to_alist : 'a t -> min:key -> max:key -> (key * 'a) list
val closest_key
: 'a t
-> [ `Greater_or_equal_to | `Greater_than | `Less_or_equal_to | `Less_than ]
-> key
-> (key * 'a) option
val nth : 'a t -> int -> (key * 'a) option
val nth_exn : 'a t -> int -> key * 'a
val rank : _ t -> key -> int option
val to_tree : 'a t -> 'a tree
val to_sequence
: ?order:[ `Increasing_key | `Decreasing_key ]
-> ?keys_greater_or_equal_to:key
-> ?keys_less_or_equal_to:key
-> 'a t
-> (key * 'a) Sequence.t
val binary_search
: 'a t
-> compare:(key:key -> data:'a -> 'key -> int)
-> Binary_searchable.Which_target_by_key.t
-> 'key
-> (key * 'a) option
val binary_search_segmented
: 'a t
-> segment_of:(key:key -> data:'a -> [ `Left | `Right ])
-> Binary_searchable.Which_target_by_segment.t
-> (key * 'a) option
val binary_search_subrange
: 'a t
-> compare:(key:key -> data:'a -> 'bound -> int)
-> lower_bound:'bound Maybe_bound.t
-> upper_bound:'bound Maybe_bound.t
-> 'a t
end
module type Accessors2 = sig
type ('a, 'b) t
type ('a, 'b) tree
type comparator_witness
val invariants : (_, _) t -> bool
val is_empty : (_, _) t -> bool
val length : (_, _) t -> int
val add : ('a, 'b) t -> key:'a -> data:'b -> ('a, 'b) t Or_duplicate.t
val add_exn : ('a, 'b) t -> key:'a -> data:'b -> ('a, 'b) t
val set : ('a, 'b) t -> key:'a -> data:'b -> ('a, 'b) t
val add_multi : ('a, 'b list) t -> key:'a -> data:'b -> ('a, 'b list) t
val remove_multi : ('a, 'b list) t -> 'a -> ('a, 'b list) t
val find_multi : ('a, 'b list) t -> 'a -> 'b list
val change : ('a, 'b) t -> 'a -> f:('b option -> 'b option) -> ('a, 'b) t
val update : ('a, 'b) t -> 'a -> f:('b option -> 'b) -> ('a, 'b) t
val find : ('a, 'b) t -> 'a -> 'b option
val find_exn : ('a, 'b) t -> 'a -> 'b
val remove : ('a, 'b) t -> 'a -> ('a, 'b) t
val mem : ('a, 'b) t -> 'a -> bool
val iter_keys : ('a, _) t -> f:('a -> unit) -> unit
val iter : (_, 'b) t -> f:('b -> unit) -> unit
val iteri : ('a, 'b) t -> f:(key:'a -> data:'b -> unit) -> unit
val iteri_until
: ('a, 'b) t
-> f:(key:'a -> data:'b -> Continue_or_stop.t)
-> Finished_or_unfinished.t
val iter2
: ('a, 'b) t
-> ('a, 'c) t
-> f:(key:'a -> data:('b, 'c) Merge_element.t -> unit)
-> unit
val map : ('a, 'b) t -> f:('b -> 'c) -> ('a, 'c) t
val mapi : ('a, 'b) t -> f:(key:'a -> data:'b -> 'c) -> ('a, 'c) t
val fold : ('a, 'b) t -> init:'c -> f:(key:'a -> data:'b -> 'c -> 'c) -> 'c
val fold_until
: ('k, 'v) t
-> init:'a
-> f:(key:'k -> data:'v -> 'a -> ('a, 'final) Container.Continue_or_stop.t)
-> finish:('a -> 'final)
-> 'final
val fold_right : ('a, 'b) t -> init:'c -> f:(key:'a -> data:'b -> 'c -> 'c) -> 'c
val fold2
: ('a, 'b) t
-> ('a, 'c) t
-> init:'d
-> f:(key:'a -> data:('b, 'c) Merge_element.t -> 'd -> 'd)
-> 'd
val filter_keys : ('a, 'b) t -> f:('a -> bool) -> ('a, 'b) t
val filter : ('a, 'b) t -> f:('b -> bool) -> ('a, 'b) t
val filteri : ('a, 'b) t -> f:(key:'a -> data:'b -> bool) -> ('a, 'b) t
val filter_map : ('a, 'b) t -> f:('b -> 'c option) -> ('a, 'c) t
val filter_mapi : ('a, 'b) t -> f:(key:'a -> data:'b -> 'c option) -> ('a, 'c) t
val partition_mapi
: ('a, 'b) t
-> f:(key:'a -> data:'b -> ('c, 'd) Either.t)
-> ('a, 'c) t * ('a, 'd) t
val partition_map : ('a, 'b) t -> f:('b -> ('c, 'd) Either.t) -> ('a, 'c) t * ('a, 'd) t
val partitioni_tf
: ('a, 'b) t
-> f:(key:'a -> data:'b -> bool)
-> ('a, 'b) t * ('a, 'b) t
val partition_tf : ('a, 'b) t -> f:('b -> bool) -> ('a, 'b) t * ('a, 'b) t
val combine_errors : ('a, 'b Or_error.t) t -> ('a, 'b) t Or_error.t
val compare_direct : ('b -> 'b -> int) -> ('a, 'b) t -> ('a, 'b) t -> int
val equal : ('b -> 'b -> bool) -> ('a, 'b) t -> ('a, 'b) t -> bool
val keys : ('a, _) t -> 'a list
val data : (_, 'b) t -> 'b list
val to_alist : ?key_order:[ `Increasing | `Decreasing ] -> ('a, 'b) t -> ('a * 'b) list
val merge
: ('a, 'b) t
-> ('a, 'c) t
-> f:(key:'a -> ('b, 'c) Merge_element.t -> 'd option)
-> ('a, 'd) t
val merge_skewed
: ('k, 'v) t
-> ('k, 'v) t
-> combine:(key:'k -> 'v -> 'v -> 'v)
-> ('k, 'v) t
val symmetric_diff
: ('a, 'b) t
-> ('a, 'b) t
-> data_equal:('b -> 'b -> bool)
-> ('a, 'b) Symmetric_diff_element.t Sequence.t
val fold_symmetric_diff
: ('a, 'b) t
-> ('a, 'b) t
-> data_equal:('b -> 'b -> bool)
-> init:'c
-> f:('c -> ('a, 'b) Symmetric_diff_element.t -> 'c)
-> 'c
val min_elt : ('a, 'b) t -> ('a * 'b) option
val min_elt_exn : ('a, 'b) t -> 'a * 'b
val max_elt : ('a, 'b) t -> ('a * 'b) option
val max_elt_exn : ('a, 'b) t -> 'a * 'b
val for_all : (_, 'b) t -> f:('b -> bool) -> bool
val for_alli : ('a, 'b) t -> f:(key:'a -> data:'b -> bool) -> bool
val exists : (_, 'b) t -> f:('b -> bool) -> bool
val existsi : ('a, 'b) t -> f:(key:'a -> data:'b -> bool) -> bool
val count : (_, 'b) t -> f:('b -> bool) -> int
val counti : ('a, 'b) t -> f:(key:'a -> data:'b -> bool) -> int
val split : ('a, 'b) t -> 'a -> ('a, 'b) t * ('a * 'b) option * ('a, 'b) t
val append
: lower_part:('a, 'b) t
-> upper_part:('a, 'b) t
-> [ `Ok of ('a, 'b) t | `Overlapping_key_ranges ]
val subrange
: ('a, 'b) t
-> lower_bound:'a Maybe_bound.t
-> upper_bound:'a Maybe_bound.t
-> ('a, 'b) t
val fold_range_inclusive
: ('a, 'b) t
-> min:'a
-> max:'a
-> init:'c
-> f:(key:'a -> data:'b -> 'c -> 'c)
-> 'c
val range_to_alist : ('a, 'b) t -> min:'a -> max:'a -> ('a * 'b) list
val closest_key
: ('a, 'b) t
-> [ `Greater_or_equal_to | `Greater_than | `Less_or_equal_to | `Less_than ]
-> 'a
-> ('a * 'b) option
val nth : ('a, 'b) t -> int -> ('a * 'b) option
val nth_exn : ('a, 'b) t -> int -> 'a * 'b
val rank : ('a, _) t -> 'a -> int option
val to_tree : ('a, 'b) t -> ('a, 'b) tree
val to_sequence
: ?order:[ `Increasing_key | `Decreasing_key ]
-> ?keys_greater_or_equal_to:'a
-> ?keys_less_or_equal_to:'a
-> ('a, 'b) t
-> ('a * 'b) Sequence.t
val binary_search
: ('k, 'v) t
-> compare:(key:'k -> data:'v -> 'key -> int)
-> Binary_searchable.Which_target_by_key.t
-> 'key
-> ('k * 'v) option
val binary_search_segmented
: ('k, 'v) t
-> segment_of:(key:'k -> data:'v -> [ `Left | `Right ])
-> Binary_searchable.Which_target_by_segment.t
-> ('k * 'v) option
val binary_search_subrange
: ('k, 'v) t
-> compare:(key:'k -> data:'v -> 'bound -> int)
-> lower_bound:'bound Maybe_bound.t
-> upper_bound:'bound Maybe_bound.t
-> ('k, 'v) t
end
module type Accessors3 = sig
type ('a, 'b, 'cmp) t
type ('a, 'b, 'cmp) tree
val invariants : (_, _, _) t -> bool
val is_empty : (_, _, _) t -> bool
val length : (_, _, _) t -> int
val add : ('a, 'b, 'cmp) t -> key:'a -> data:'b -> ('a, 'b, 'cmp) t Or_duplicate.t
val add_exn : ('a, 'b, 'cmp) t -> key:'a -> data:'b -> ('a, 'b, 'cmp) t
val set : ('a, 'b, 'cmp) t -> key:'a -> data:'b -> ('a, 'b, 'cmp) t
val add_multi : ('a, 'b list, 'cmp) t -> key:'a -> data:'b -> ('a, 'b list, 'cmp) t
val remove_multi : ('a, 'b list, 'cmp) t -> 'a -> ('a, 'b list, 'cmp) t
val find_multi : ('a, 'b list, 'cmp) t -> 'a -> 'b list
val change : ('a, 'b, 'cmp) t -> 'a -> f:('b option -> 'b option) -> ('a, 'b, 'cmp) t
val update : ('a, 'b, 'cmp) t -> 'a -> f:('b option -> 'b) -> ('a, 'b, 'cmp) t
val find : ('a, 'b, 'cmp) t -> 'a -> 'b option
val find_exn : ('a, 'b, 'cmp) t -> 'a -> 'b
val remove : ('a, 'b, 'cmp) t -> 'a -> ('a, 'b, 'cmp) t
val mem : ('a, 'b, 'cmp) t -> 'a -> bool
val iter_keys : ('a, _, 'cmp) t -> f:('a -> unit) -> unit
val iter : (_, 'b, 'cmp) t -> f:('b -> unit) -> unit
val iteri : ('a, 'b, 'cmp) t -> f:(key:'a -> data:'b -> unit) -> unit
val iteri_until
: ('a, 'b, 'cmp) t
-> f:(key:'a -> data:'b -> Continue_or_stop.t)
-> Finished_or_unfinished.t
val iter2
: ('a, 'b, 'cmp) t
-> ('a, 'c, 'cmp) t
-> f:(key:'a -> data:('b, 'c) Merge_element.t -> unit)
-> unit
val map : ('a, 'b, 'cmp) t -> f:('b -> 'c) -> ('a, 'c, 'cmp) t
val mapi : ('a, 'b, 'cmp) t -> f:(key:'a -> data:'b -> 'c) -> ('a, 'c, 'cmp) t
val fold : ('a, 'b, _) t -> init:'c -> f:(key:'a -> data:'b -> 'c -> 'c) -> 'c
val fold_until
: ('k, 'v, _) t
-> init:'a
-> f:(key:'k -> data:'v -> 'a -> ('a, 'final) Container.Continue_or_stop.t)
-> finish:('a -> 'final)
-> 'final
val fold_right : ('a, 'b, _) t -> init:'c -> f:(key:'a -> data:'b -> 'c -> 'c) -> 'c
val fold2
: ('a, 'b, 'cmp) t
-> ('a, 'c, 'cmp) t
-> init:'d
-> f:(key:'a -> data:('b, 'c) Merge_element.t -> 'd -> 'd)
-> 'd
val filter_keys : ('a, 'b, 'cmp) t -> f:('a -> bool) -> ('a, 'b, 'cmp) t
val filter : ('a, 'b, 'cmp) t -> f:('b -> bool) -> ('a, 'b, 'cmp) t
val filteri : ('a, 'b, 'cmp) t -> f:(key:'a -> data:'b -> bool) -> ('a, 'b, 'cmp) t
val filter_map : ('a, 'b, 'cmp) t -> f:('b -> 'c option) -> ('a, 'c, 'cmp) t
val filter_mapi
: ('a, 'b, 'cmp) t
-> f:(key:'a -> data:'b -> 'c option)
-> ('a, 'c, 'cmp) t
val partition_mapi
: ('a, 'b, 'cmp) t
-> f:(key:'a -> data:'b -> ('c, 'd) Either.t)
-> ('a, 'c, 'cmp) t * ('a, 'd, 'cmp) t
val partition_map
: ('a, 'b, 'cmp) t
-> f:('b -> ('c, 'd) Either.t)
-> ('a, 'c, 'cmp) t * ('a, 'd, 'cmp) t
val partitioni_tf
: ('a, 'b, 'cmp) t
-> f:(key:'a -> data:'b -> bool)
-> ('a, 'b, 'cmp) t * ('a, 'b, 'cmp) t
val partition_tf
: ('a, 'b, 'cmp) t
-> f:('b -> bool)
-> ('a, 'b, 'cmp) t * ('a, 'b, 'cmp) t
val combine_errors : ('a, 'b Or_error.t, 'cmp) t -> ('a, 'b, 'cmp) t Or_error.t
val compare_direct : ('b -> 'b -> int) -> ('a, 'b, 'cmp) t -> ('a, 'b, 'cmp) t -> int
val equal : ('b -> 'b -> bool) -> ('a, 'b, 'cmp) t -> ('a, 'b, 'cmp) t -> bool
val keys : ('a, _, _) t -> 'a list
val data : (_, 'b, _) t -> 'b list
val to_alist
: ?key_order:[ `Increasing | `Decreasing ]
-> ('a, 'b, _) t
-> ('a * 'b) list
val merge
: ('a, 'b, 'cmp) t
-> ('a, 'c, 'cmp) t
-> f:(key:'a -> ('b, 'c) Merge_element.t -> 'd option)
-> ('a, 'd, 'cmp) t
val merge_skewed
: ('k, 'v, 'cmp) t
-> ('k, 'v, 'cmp) t
-> combine:(key:'k -> 'v -> 'v -> 'v)
-> ('k, 'v, 'cmp) t
val symmetric_diff
: ('a, 'b, 'cmp) t
-> ('a, 'b, 'cmp) t
-> data_equal:('b -> 'b -> bool)
-> ('a, 'b) Symmetric_diff_element.t Sequence.t
val fold_symmetric_diff
: ('a, 'b, 'cmp) t
-> ('a, 'b, 'cmp) t
-> data_equal:('b -> 'b -> bool)
-> init:'c
-> f:('c -> ('a, 'b) Symmetric_diff_element.t -> 'c)
-> 'c
val min_elt : ('a, 'b, 'cmp) t -> ('a * 'b) option
val min_elt_exn : ('a, 'b, 'cmp) t -> 'a * 'b
val max_elt : ('a, 'b, 'cmp) t -> ('a * 'b) option
val max_elt_exn : ('a, 'b, 'cmp) t -> 'a * 'b
val for_all : (_, 'b, _) t -> f:('b -> bool) -> bool
val for_alli : ('a, 'b, _) t -> f:(key:'a -> data:'b -> bool) -> bool
val exists : (_, 'b, _) t -> f:('b -> bool) -> bool
val existsi : ('a, 'b, _) t -> f:(key:'a -> data:'b -> bool) -> bool
val count : (_, 'b, _) t -> f:('b -> bool) -> int
val counti : ('a, 'b, _) t -> f:(key:'a -> data:'b -> bool) -> int
val split
: ('k, 'v, 'cmp) t
-> 'k
-> ('k, 'v, 'cmp) t * ('k * 'v) option * ('k, 'v, 'cmp) t
val append
: lower_part:('k, 'v, 'cmp) t
-> upper_part:('k, 'v, 'cmp) t
-> [ `Ok of ('k, 'v, 'cmp) t | `Overlapping_key_ranges ]
val subrange
: ('k, 'v, 'cmp) t
-> lower_bound:'k Maybe_bound.t
-> upper_bound:'k Maybe_bound.t
-> ('k, 'v, 'cmp) t
val fold_range_inclusive
: ('a, 'b, _) t
-> min:'a
-> max:'a
-> init:'c
-> f:(key:'a -> data:'b -> 'c -> 'c)
-> 'c
val range_to_alist : ('a, 'b, _) t -> min:'a -> max:'a -> ('a * 'b) list
val closest_key
: ('a, 'b, _) t
-> [ `Greater_or_equal_to | `Greater_than | `Less_or_equal_to | `Less_than ]
-> 'a
-> ('a * 'b) option
val nth : ('a, 'b, _) t -> int -> ('a * 'b) option
val nth_exn : ('a, 'b, _) t -> int -> 'a * 'b
val rank : ('a, _, _) t -> 'a -> int option
val to_tree : ('a, 'b, 'cmp) t -> ('a, 'b, 'cmp) tree
val to_sequence
: ?order:[ `Increasing_key | `Decreasing_key ]
-> ?keys_greater_or_equal_to:'a
-> ?keys_less_or_equal_to:'a
-> ('a, 'b, _) t
-> ('a * 'b) Sequence.t
val binary_search
: ('k, 'v, _) t
-> compare:(key:'k -> data:'v -> 'key -> int)
-> Binary_searchable.Which_target_by_key.t
-> 'key
-> ('k * 'v) option
val binary_search_segmented
: ('k, 'v, _) t
-> segment_of:(key:'k -> data:'v -> [ `Left | `Right ])
-> Binary_searchable.Which_target_by_segment.t
-> ('k * 'v) option
val binary_search_subrange
: ('k, 'v, 'cmp) t
-> compare:(key:'k -> data:'v -> 'bound -> int)
-> lower_bound:'bound Maybe_bound.t
-> upper_bound:'bound Maybe_bound.t
-> ('k, 'v, 'cmp) t
end
module type Accessors3_with_comparator = sig
type ('a, 'b, 'cmp) t
type ('a, 'b, 'cmp) tree
val invariants : comparator:('a, 'cmp) Comparator.t -> ('a, 'b, 'cmp) t -> bool
val is_empty : ('a, 'b, 'cmp) t -> bool
val length : ('a, 'b, 'cmp) t -> int
val add
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> key:'a
-> data:'b
-> ('a, 'b, 'cmp) t Or_duplicate.t
val add_exn
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> key:'a
-> data:'b
-> ('a, 'b, 'cmp) t
val set
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> key:'a
-> data:'b
-> ('a, 'b, 'cmp) t
val add_multi
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b list, 'cmp) t
-> key:'a
-> data:'b
-> ('a, 'b list, 'cmp) t
val remove_multi
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b list, 'cmp) t
-> 'a
-> ('a, 'b list, 'cmp) t
val find_multi
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b list, 'cmp) t
-> 'a
-> 'b list
val change
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> 'a
-> f:('b option -> 'b option)
-> ('a, 'b, 'cmp) t
val update
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> 'a
-> f:('b option -> 'b)
-> ('a, 'b, 'cmp) t
val find : comparator:('a, 'cmp) Comparator.t -> ('a, 'b, 'cmp) t -> 'a -> 'b option
val find_exn : comparator:('a, 'cmp) Comparator.t -> ('a, 'b, 'cmp) t -> 'a -> 'b
val remove
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> 'a
-> ('a, 'b, 'cmp) t
val mem : comparator:('a, 'cmp) Comparator.t -> ('a, 'b, 'cmp) t -> 'a -> bool
val iter_keys : ('a, _, 'cmp) t -> f:('a -> unit) -> unit
val iter : (_, 'b, 'cmp) t -> f:('b -> unit) -> unit
val iteri : ('a, 'b, 'cmp) t -> f:(key:'a -> data:'b -> unit) -> unit
val iteri_until
: ('a, 'b, 'cmp) t
-> f:(key:'a -> data:'b -> Continue_or_stop.t)
-> Finished_or_unfinished.t
val iter2
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> ('a, 'c, 'cmp) t
-> f:(key:'a -> data:('b, 'c) Merge_element.t -> unit)
-> unit
val map : ('a, 'b, 'cmp) t -> f:('b -> 'c) -> ('a, 'c, 'cmp) t
val mapi : ('a, 'b, 'cmp) t -> f:(key:'a -> data:'b -> 'c) -> ('a, 'c, 'cmp) t
val fold : ('a, 'b, _) t -> init:'c -> f:(key:'a -> data:'b -> 'c -> 'c) -> 'c
val fold_until
: ('k, 'v, _) t
-> init:'a
-> f:(key:'k -> data:'v -> 'a -> ('a, 'final) Container.Continue_or_stop.t)
-> finish:('a -> 'final)
-> 'final
val fold_right : ('a, 'b, _) t -> init:'c -> f:(key:'a -> data:'b -> 'c -> 'c) -> 'c
val fold2
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> ('a, 'c, 'cmp) t
-> init:'d
-> f:(key:'a -> data:('b, 'c) Merge_element.t -> 'd -> 'd)
-> 'd
val filter_keys
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> f:('a -> bool)
-> ('a, 'b, 'cmp) t
val filter
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> f:('b -> bool)
-> ('a, 'b, 'cmp) t
val filteri
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> f:(key:'a -> data:'b -> bool)
-> ('a, 'b, 'cmp) t
val filter_map
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> f:('b -> 'c option)
-> ('a, 'c, 'cmp) t
val filter_mapi
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> f:(key:'a -> data:'b -> 'c option)
-> ('a, 'c, 'cmp) t
val partition_mapi
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> f:(key:'a -> data:'b -> ('c, 'd) Either.t)
-> ('a, 'c, 'cmp) t * ('a, 'd, 'cmp) t
val partition_map
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> f:('b -> ('c, 'd) Either.t)
-> ('a, 'c, 'cmp) t * ('a, 'd, 'cmp) t
val partitioni_tf
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> f:(key:'a -> data:'b -> bool)
-> ('a, 'b, 'cmp) t * ('a, 'b, 'cmp) t
val partition_tf
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> f:('b -> bool)
-> ('a, 'b, 'cmp) t * ('a, 'b, 'cmp) t
val combine_errors
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b Or_error.t, 'cmp) t
-> ('a, 'b, 'cmp) t Or_error.t
val compare_direct
: comparator:('a, 'cmp) Comparator.t
-> ('b -> 'b -> int)
-> ('a, 'b, 'cmp) t
-> ('a, 'b, 'cmp) t
-> int
val equal
: comparator:('a, 'cmp) Comparator.t
-> ('b -> 'b -> bool)
-> ('a, 'b, 'cmp) t
-> ('a, 'b, 'cmp) t
-> bool
val keys : ('a, _, _) t -> 'a list
val data : (_, 'b, _) t -> 'b list
val to_alist
: ?key_order:[ `Increasing | `Decreasing ]
-> ('a, 'b, _) t
-> ('a * 'b) list
val merge
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> ('a, 'c, 'cmp) t
-> f:(key:'a -> ('b, 'c) Merge_element.t -> 'd option)
-> ('a, 'd, 'cmp) t
val merge_skewed
: comparator:('k, 'cmp) Comparator.t
-> ('k, 'v, 'cmp) t
-> ('k, 'v, 'cmp) t
-> combine:(key:'k -> 'v -> 'v -> 'v)
-> ('k, 'v, 'cmp) t
val symmetric_diff
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> ('a, 'b, 'cmp) t
-> data_equal:('b -> 'b -> bool)
-> ('a, 'b) Symmetric_diff_element.t Sequence.t
val fold_symmetric_diff
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> ('a, 'b, 'cmp) t
-> data_equal:('b -> 'b -> bool)
-> init:'c
-> f:('c -> ('a, 'b) Symmetric_diff_element.t -> 'c)
-> 'c
val min_elt : ('a, 'b, 'cmp) t -> ('a * 'b) option
val min_elt_exn : ('a, 'b, 'cmp) t -> 'a * 'b
val max_elt : ('a, 'b, 'cmp) t -> ('a * 'b) option
val max_elt_exn : ('a, 'b, 'cmp) t -> 'a * 'b
val for_all : ('a, 'b, 'cmp) t -> f:('b -> bool) -> bool
val for_alli : ('a, 'b, 'cmp) t -> f:(key:'a -> data:'b -> bool) -> bool
val exists : ('a, 'b, 'cmp) t -> f:('b -> bool) -> bool
val existsi : ('a, 'b, 'cmp) t -> f:(key:'a -> data:'b -> bool) -> bool
val count : ('a, 'b, 'cmp) t -> f:('b -> bool) -> int
val counti : ('a, 'b, 'cmp) t -> f:(key:'a -> data:'b -> bool) -> int
val split
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> 'a
-> ('a, 'b, 'cmp) t * ('a * 'b) option * ('a, 'b, 'cmp) t
val append
: comparator:('a, 'cmp) Comparator.t
-> lower_part:('a, 'b, 'cmp) t
-> upper_part:('a, 'b, 'cmp) t
-> [ `Ok of ('a, 'b, 'cmp) t | `Overlapping_key_ranges ]
val subrange
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> lower_bound:'a Maybe_bound.t
-> upper_bound:'a Maybe_bound.t
-> ('a, 'b, 'cmp) t
val fold_range_inclusive
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> min:'a
-> max:'a
-> init:'c
-> f:(key:'a -> data:'b -> 'c -> 'c)
-> 'c
val range_to_alist
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> min:'a
-> max:'a
-> ('a * 'b) list
val closest_key
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) t
-> [ `Greater_or_equal_to | `Greater_than | `Less_or_equal_to | `Less_than ]
-> 'a
-> ('a * 'b) option
val nth : ('a, 'b, 'cmp) t -> int -> ('a * 'b) option
val nth_exn : ('a, 'b, 'cmp) t -> int -> 'a * 'b
val rank : comparator:('a, 'cmp) Comparator.t -> ('a, 'b, 'cmp) t -> 'a -> int option
val to_tree : ('a, 'b, 'cmp) t -> ('a, 'b, 'cmp) tree
val to_sequence
: comparator:('a, 'cmp) Comparator.t
-> ?order:[ `Increasing_key | `Decreasing_key ]
-> ?keys_greater_or_equal_to:'a
-> ?keys_less_or_equal_to:'a
-> ('a, 'b, 'cmp) t
-> ('a * 'b) Sequence.t
val binary_search
: comparator:('k, 'cmp) Comparator.t
-> ('k, 'v, 'cmp) t
-> compare:(key:'k -> data:'v -> 'key -> int)
-> Binary_searchable.Which_target_by_key.t
-> 'key
-> ('k * 'v) option
val binary_search_segmented
: comparator:('k, 'cmp) Comparator.t
-> ('k, 'v, 'cmp) t
-> segment_of:(key:'k -> data:'v -> [ `Left | `Right ])
-> Binary_searchable.Which_target_by_segment.t
-> ('k * 'v) option
val binary_search_subrange
: comparator:('k, 'cmp) Comparator.t
-> ('k, 'v, 'cmp) t
-> compare:(key:'k -> data:'v -> 'bound -> int)
-> lower_bound:'bound Maybe_bound.t
-> upper_bound:'bound Maybe_bound.t
-> ('k, 'v, 'cmp) t
end
(** Consistency checks (same as in [Container]). *)
module Check_accessors
(T : T3)
(Tree : T3)
(Key : T1)
(Cmp : T1)
(Options : T3)
(_ : Accessors_generic
with type ('a, 'b, 'c) options := ('a, 'b, 'c) Options.t
with type ('a, 'b, 'c) t := ('a, 'b, 'c) T.t
with type ('a, 'b, 'c) tree := ('a, 'b, 'c) Tree.t
with type 'a key := 'a Key.t
with type 'cmp cmp := 'cmp Cmp.t) =
struct end
module Check_accessors1 (M : Accessors1) =
Check_accessors
(struct
type ('a, 'b, 'c) t = 'b M.t
end)
(struct
type ('a, 'b, 'c) t = 'b M.tree
end)
(struct
type 'a t = M.key
end)
(struct
type 'a t = M.comparator_witness
end)
(Without_comparator)
(M)
module Check_accessors2 (M : Accessors2) =
Check_accessors
(struct
type ('a, 'b, 'c) t = ('a, 'b) M.t
end)
(struct
type ('a, 'b, 'c) t = ('a, 'b) M.tree
end)
(struct
type 'a t = 'a
end)
(struct
type 'a t = M.comparator_witness
end)
(Without_comparator)
(M)
module Check_accessors3 (M : Accessors3) =
Check_accessors
(struct
type ('a, 'b, 'c) t = ('a, 'b, 'c) M.t
end)
(struct
type ('a, 'b, 'c) t = ('a, 'b, 'c) M.tree
end)
(struct
type 'a t = 'a
end)
(struct
type 'a t = 'a
end)
(Without_comparator)
(M)
module Check_accessors3_with_comparator (M : Accessors3_with_comparator) =
Check_accessors
(struct
type ('a, 'b, 'c) t = ('a, 'b, 'c) M.t
end)
(struct
type ('a, 'b, 'c) t = ('a, 'b, 'c) M.tree
end)
(struct
type 'a t = 'a
end)
(struct
type 'a t = 'a
end)
(With_comparator)
(M)
module type Creators_generic = sig
type ('k, 'v, 'cmp) t
type ('k, 'v, 'cmp) tree
type 'k key
type ('a, 'cmp, 'z) options
type 'cmp cmp
val empty : ('k, 'cmp, ('k, _, 'cmp) t) options
val singleton : ('k, 'cmp, 'k key -> 'v -> ('k, 'v, 'cmp) t) options
val map_keys
: ( 'k2
, 'cmp2
, ('k1, 'v, 'cmp1) t
-> f:('k1 key -> 'k2 key)
-> [ `Ok of ('k2, 'v, 'cmp2) t | `Duplicate_key of 'k2 key ] )
options
val map_keys_exn
: ( 'k2
, 'cmp2
, ('k1, 'v, 'cmp1) t -> f:('k1 key -> 'k2 key) -> ('k2, 'v, 'cmp2) t )
options
val of_sorted_array
: ('k, 'cmp, ('k key * 'v) array -> ('k, 'v, 'cmp) t Or_error.t) options
val of_sorted_array_unchecked
: ('k, 'cmp, ('k key * 'v) array -> ('k, 'v, 'cmp) t) options
val of_increasing_iterator_unchecked
: ('k, 'cmp, len:int -> f:(int -> 'k key * 'v) -> ('k, 'v, 'cmp) t) options
val of_alist
: ( 'k
, 'cmp
, ('k key * 'v) list -> [ `Ok of ('k, 'v, 'cmp) t | `Duplicate_key of 'k key ] )
options
val of_alist_or_error
: ('k, 'cmp, ('k key * 'v) list -> ('k, 'v, 'cmp) t Or_error.t) options
val of_alist_exn : ('k, 'cmp, ('k key * 'v) list -> ('k, 'v, 'cmp) t) options
val of_alist_multi : ('k, 'cmp, ('k key * 'v) list -> ('k, 'v list, 'cmp) t) options
val of_alist_fold
: ( 'k
, 'cmp
, ('k key * 'v1) list -> init:'v2 -> f:('v2 -> 'v1 -> 'v2) -> ('k, 'v2, 'cmp) t )
options
val of_alist_reduce
: ('k, 'cmp, ('k key * 'v) list -> f:('v -> 'v -> 'v) -> ('k, 'v, 'cmp) t) options
val of_increasing_sequence
: ('k, 'cmp, ('k key * 'v) Sequence.t -> ('k, 'v, 'cmp) t Or_error.t) options
val of_sequence
: ( 'k
, 'cmp
, ('k key * 'v) Sequence.t -> [ `Ok of ('k, 'v, 'cmp) t | `Duplicate_key of 'k key ]
)
options
val of_sequence_or_error
: ('k, 'cmp, ('k key * 'v) Sequence.t -> ('k, 'v, 'cmp) t Or_error.t) options
val of_sequence_exn : ('k, 'cmp, ('k key * 'v) Sequence.t -> ('k, 'v, 'cmp) t) options
val of_sequence_multi
: ('k, 'cmp, ('k key * 'v) Sequence.t -> ('k, 'v list, 'cmp) t) options
val of_sequence_fold
: ( 'k
, 'cmp
, ('k key * 'v1) Sequence.t
-> init:'v2
-> f:('v2 -> 'v1 -> 'v2)
-> ('k, 'v2, 'cmp) t )
options
val of_sequence_reduce
: ( 'k
, 'cmp
, ('k key * 'v) Sequence.t -> f:('v -> 'v -> 'v) -> ('k, 'v, 'cmp) t )
options
val of_iteri
: ( 'k
, 'cmp
, iteri:(f:(key:'k key -> data:'v -> unit) -> unit)
-> [ `Ok of ('k, 'v, 'cmp) t | `Duplicate_key of 'k key ] )
options
val of_iteri_exn
: ( 'k
, 'cmp
, iteri:(f:(key:'k key -> data:'v -> unit) -> unit) -> ('k, 'v, 'cmp) t )
options
val of_tree : ('k, 'cmp, ('k key, 'v, 'cmp) tree -> ('k, 'v, 'cmp) t) options
end
module type Creators1 = sig
type 'a t
type 'a tree
type key
type comparator_witness
val empty : _ t
val singleton : key -> 'a -> 'a t
val map_keys : 'v t -> f:(key -> key) -> [ `Ok of 'v t | `Duplicate_key of key ]
val map_keys_exn : 'v t -> f:(key -> key) -> 'v t
val of_alist : (key * 'a) list -> [ `Ok of 'a t | `Duplicate_key of key ]
val of_alist_or_error : (key * 'a) list -> 'a t Or_error.t
val of_alist_exn : (key * 'a) list -> 'a t
val of_alist_multi : (key * 'a) list -> 'a list t
val of_alist_fold : (key * 'a) list -> init:'b -> f:('b -> 'a -> 'b) -> 'b t
val of_alist_reduce : (key * 'a) list -> f:('a -> 'a -> 'a) -> 'a t
val of_sorted_array : (key * 'a) array -> 'a t Or_error.t
val of_sorted_array_unchecked : (key * 'a) array -> 'a t
val of_increasing_iterator_unchecked : len:int -> f:(int -> key * 'a) -> 'a t
val of_increasing_sequence : (key * 'a) Sequence.t -> 'a t Or_error.t
val of_sequence : (key * 'a) Sequence.t -> [ `Ok of 'a t | `Duplicate_key of key ]
val of_sequence_or_error : (key * 'a) Sequence.t -> 'a t Or_error.t
val of_sequence_exn : (key * 'a) Sequence.t -> 'a t
val of_sequence_multi : (key * 'a) Sequence.t -> 'a list t
val of_sequence_fold : (key * 'a) Sequence.t -> init:'b -> f:('b -> 'a -> 'b) -> 'b t
val of_sequence_reduce : (key * 'a) Sequence.t -> f:('a -> 'a -> 'a) -> 'a t
val of_iteri
: iteri:(f:(key:key -> data:'v -> unit) -> unit)
-> [ `Ok of 'v t | `Duplicate_key of key ]
val of_iteri_exn : iteri:(f:(key:key -> data:'v -> unit) -> unit) -> 'v t
val of_tree : 'a tree -> 'a t
end
module type Creators2 = sig
type ('a, 'b) t
type ('a, 'b) tree
type comparator_witness
val empty : (_, _) t
val singleton : 'a -> 'b -> ('a, 'b) t
val map_keys
: ('k1, 'v) t
-> f:('k1 -> 'k2)
-> [ `Ok of ('k2, 'v) t | `Duplicate_key of 'k2 ]
val map_keys_exn : ('k1, 'v) t -> f:('k1 -> 'k2) -> ('k2, 'v) t
val of_alist : ('a * 'b) list -> [ `Ok of ('a, 'b) t | `Duplicate_key of 'a ]
val of_alist_or_error : ('a * 'b) list -> ('a, 'b) t Or_error.t
val of_alist_exn : ('a * 'b) list -> ('a, 'b) t
val of_alist_multi : ('a * 'b) list -> ('a, 'b list) t
val of_alist_fold : ('a * 'b) list -> init:'c -> f:('c -> 'b -> 'c) -> ('a, 'c) t
val of_alist_reduce : ('a * 'b) list -> f:('b -> 'b -> 'b) -> ('a, 'b) t
val of_sorted_array : ('a * 'b) array -> ('a, 'b) t Or_error.t
val of_sorted_array_unchecked : ('a * 'b) array -> ('a, 'b) t
val of_increasing_iterator_unchecked : len:int -> f:(int -> 'a * 'b) -> ('a, 'b) t
val of_increasing_sequence : ('a * 'b) Sequence.t -> ('a, 'b) t Or_error.t
val of_sequence : ('a * 'b) Sequence.t -> [ `Ok of ('a, 'b) t | `Duplicate_key of 'a ]
val of_sequence_or_error : ('a * 'b) Sequence.t -> ('a, 'b) t Or_error.t
val of_sequence_exn : ('a * 'b) Sequence.t -> ('a, 'b) t
val of_sequence_multi : ('a * 'b) Sequence.t -> ('a, 'b list) t
val of_sequence_fold
: ('a * 'b) Sequence.t
-> init:'c
-> f:('c -> 'b -> 'c)
-> ('a, 'c) t
val of_sequence_reduce : ('a * 'b) Sequence.t -> f:('b -> 'b -> 'b) -> ('a, 'b) t
val of_iteri
: iteri:(f:(key:'a -> data:'b -> unit) -> unit)
-> [ `Ok of ('a, 'b) t | `Duplicate_key of 'a ]
val of_iteri_exn : iteri:(f:(key:'a -> data:'b -> unit) -> unit) -> ('a, 'b) t
val of_tree : ('a, 'b) tree -> ('a, 'b) t
end
module type Creators3_with_comparator = sig
type ('a, 'b, 'cmp) t
type ('a, 'b, 'cmp) tree
val empty : comparator:('a, 'cmp) Comparator.t -> ('a, _, 'cmp) t
val singleton : comparator:('a, 'cmp) Comparator.t -> 'a -> 'b -> ('a, 'b, 'cmp) t
val map_keys
: comparator:('k2, 'cmp2) Comparator.t
-> ('k1, 'v, 'cmp1) t
-> f:('k1 -> 'k2)
-> [ `Ok of ('k2, 'v, 'cmp2) t | `Duplicate_key of 'k2 ]
val map_keys_exn
: comparator:('k2, 'cmp2) Comparator.t
-> ('k1, 'v, 'cmp1) t
-> f:('k1 -> 'k2)
-> ('k2, 'v, 'cmp2) t
val of_alist
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) list
-> [ `Ok of ('a, 'b, 'cmp) t | `Duplicate_key of 'a ]
val of_alist_or_error
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) list
-> ('a, 'b, 'cmp) t Or_error.t
val of_alist_exn
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) list
-> ('a, 'b, 'cmp) t
val of_alist_multi
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) list
-> ('a, 'b list, 'cmp) t
val of_alist_fold
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) list
-> init:'c
-> f:('c -> 'b -> 'c)
-> ('a, 'c, 'cmp) t
val of_alist_reduce
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) list
-> f:('b -> 'b -> 'b)
-> ('a, 'b, 'cmp) t
val of_sorted_array
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) array
-> ('a, 'b, 'cmp) t Or_error.t
val of_sorted_array_unchecked
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) array
-> ('a, 'b, 'cmp) t
val of_increasing_iterator_unchecked
: comparator:('a, 'cmp) Comparator.t
-> len:int
-> f:(int -> 'a * 'b)
-> ('a, 'b, 'cmp) t
val of_increasing_sequence
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) Sequence.t
-> ('a, 'b, 'cmp) t Or_error.t
val of_sequence
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) Sequence.t
-> [ `Ok of ('a, 'b, 'cmp) t | `Duplicate_key of 'a ]
val of_sequence_or_error
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) Sequence.t
-> ('a, 'b, 'cmp) t Or_error.t
val of_sequence_exn
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) Sequence.t
-> ('a, 'b, 'cmp) t
val of_sequence_multi
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) Sequence.t
-> ('a, 'b list, 'cmp) t
val of_sequence_fold
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) Sequence.t
-> init:'c
-> f:('c -> 'b -> 'c)
-> ('a, 'c, 'cmp) t
val of_sequence_reduce
: comparator:('a, 'cmp) Comparator.t
-> ('a * 'b) Sequence.t
-> f:('b -> 'b -> 'b)
-> ('a, 'b, 'cmp) t
val of_iteri
: comparator:('a, 'cmp) Comparator.t
-> iteri:(f:(key:'a -> data:'b -> unit) -> unit)
-> [ `Ok of ('a, 'b, 'cmp) t | `Duplicate_key of 'a ]
val of_iteri_exn
: comparator:('a, 'cmp) Comparator.t
-> iteri:(f:(key:'a -> data:'b -> unit) -> unit)
-> ('a, 'b, 'cmp) t
val of_tree
: comparator:('a, 'cmp) Comparator.t
-> ('a, 'b, 'cmp) tree
-> ('a, 'b, 'cmp) t
end
module Check_creators
(T : T3)
(Tree : T3)
(Key : T1)
(Cmp : T1)
(Options : T3)
(_ : Creators_generic
with type ('a, 'b, 'c) options := ('a, 'b, 'c) Options.t
with type ('a, 'b, 'c) t := ('a, 'b, 'c) T.t
with type ('a, 'b, 'c) tree := ('a, 'b, 'c) Tree.t
with type 'a key := 'a Key.t
with type 'a cmp := 'a Cmp.t) =
struct end
module Check_creators1 (M : Creators1) =
Check_creators
(struct
type ('a, 'b, 'c) t = 'b M.t
end)
(struct
type ('a, 'b, 'c) t = 'b M.tree
end)
(struct
type 'a t = M.key
end)
(struct
type 'a t = M.comparator_witness
end)
(Without_comparator)
(M)
module Check_creators2 (M : Creators2) =
Check_creators
(struct
type ('a, 'b, 'c) t = ('a, 'b) M.t
end)
(struct
type ('a, 'b, 'c) t = ('a, 'b) M.tree
end)
(struct
type 'a t = 'a
end)
(struct
type 'a t = M.comparator_witness
end)
(Without_comparator)
(M)
module Check_creators3_with_comparator (M : Creators3_with_comparator) =
Check_creators
(struct
type ('a, 'b, 'c) t = ('a, 'b, 'c) M.t
end)
(struct
type ('a, 'b, 'c) t = ('a, 'b, 'c) M.tree
end)
(struct
type 'a t = 'a
end)
(struct
type 'a t = 'a
end)
(With_comparator)
(M)
module type Creators_and_accessors_generic = sig
include Creators_generic
include
Accessors_generic
with type ('a, 'b, 'c) t := ('a, 'b, 'c) t
with type ('a, 'b, 'c) tree := ('a, 'b, 'c) tree
with type 'a key := 'a key
with type 'a cmp := 'a cmp
with type ('a, 'b, 'c) options := ('a, 'b, 'c) options
end
module type Creators_and_accessors1 = sig
include Creators1
include
Accessors1
with type 'a t := 'a t
with type 'a tree := 'a tree
with type key := key
with type comparator_witness := comparator_witness
end
module type Creators_and_accessors2 = sig
include Creators2
include
Accessors2
with type ('a, 'b) t := ('a, 'b) t
with type ('a, 'b) tree := ('a, 'b) tree
with type comparator_witness := comparator_witness
end
module type Creators_and_accessors3_with_comparator = sig
include Creators3_with_comparator
include
Accessors3_with_comparator
with type ('a, 'b, 'c) t := ('a, 'b, 'c) t
with type ('a, 'b, 'c) tree := ('a, 'b, 'c) tree
end
module type S_poly = Creators_and_accessors2
module type For_deriving = sig
type ('a, 'b, 'c) t
module type Sexp_of_m = sig
type t [@@deriving_inline sexp_of]
val sexp_of_t : t -> Sexplib0.Sexp.t
[@@@end]
end
module type M_of_sexp = sig
type t [@@deriving_inline of_sexp]
val t_of_sexp : Sexplib0.Sexp.t -> t
[@@@end]
include Comparator.S with type t := t
end
module type M_sexp_grammar = sig
type t [@@deriving_inline sexp_grammar]
val t_sexp_grammar : t Sexplib0.Sexp_grammar.t
[@@@end]
end
module type Compare_m = sig end
module type Equal_m = sig end
module type Hash_fold_m = Hasher.S
val sexp_of_m__t
: (module Sexp_of_m with type t = 'k)
-> ('v -> Sexp.t)
-> ('k, 'v, 'cmp) t
-> Sexp.t
val m__t_of_sexp
: (module M_of_sexp with type t = 'k and type comparator_witness = 'cmp)
-> (Sexp.t -> 'v)
-> Sexp.t
-> ('k, 'v, 'cmp) t
val m__t_sexp_grammar
: (module M_sexp_grammar with type t = 'k)
-> 'v Sexplib0.Sexp_grammar.t
-> ('k, 'v, 'cmp) t Sexplib0.Sexp_grammar.t
val compare_m__t
: (module Compare_m)
-> ('v -> 'v -> int)
-> ('k, 'v, 'cmp) t
-> ('k, 'v, 'cmp) t
-> int
val equal_m__t
: (module Equal_m)
-> ('v -> 'v -> bool)
-> ('k, 'v, 'cmp) t
-> ('k, 'v, 'cmp) t
-> bool
val hash_fold_m__t
: (module Hash_fold_m with type t = 'k)
-> (Hash.state -> 'v -> Hash.state)
-> Hash.state
-> ('k, 'v, _) t
-> Hash.state
end
module type Map = sig
(** [Map] is a functional data structure (balanced binary tree) implementing finite maps
over a totally-ordered domain, called a "key". *)
type ('key, +'value, 'cmp) t
module Or_duplicate = Or_duplicate
module Continue_or_stop = Continue_or_stop
module Finished_or_unfinished : sig
type t = Finished_or_unfinished.t =
| Finished
| Unfinished
[@@deriving_inline compare, enumerate, equal, sexp_of]
include Ppx_compare_lib.Comparable.S with type t := t
include Ppx_enumerate_lib.Enumerable.S with type t := t
include Ppx_compare_lib.Equal.S with type t := t
val sexp_of_t : t -> Sexplib0.Sexp.t
[@@@end]
(** Maps [Continue] to [Finished] and [Stop] to [Unfinished]. *)
val of_continue_or_stop : Continue_or_stop.t -> t
(** Maps [Finished] to [Continue] and [Unfinished] to [Stop]. *)
val to_continue_or_stop : t -> Continue_or_stop.t
end
module Merge_element : sig
type ('left, 'right) t =
[ `Left of 'left
| `Right of 'right
| `Both of 'left * 'right
]
[@@deriving_inline compare, equal, sexp_of]
val compare
: ('left -> 'left -> int)
-> ('right -> 'right -> int)
-> ('left, 'right) t
-> ('left, 'right) t
-> int
val equal
: ('left -> 'left -> bool)
-> ('right -> 'right -> bool)
-> ('left, 'right) t
-> ('left, 'right) t
-> bool
val sexp_of_t
: ('left -> Sexplib0.Sexp.t)
-> ('right -> Sexplib0.Sexp.t)
-> ('left, 'right) t
-> Sexplib0.Sexp.t
[@@@end]
val left : ('left, _) t -> 'left option
val right : (_, 'right) t -> 'right option
val left_value : ('left, _) t -> default:'left -> 'left
val right_value : (_, 'right) t -> default:'right -> 'right
val values
: ('left, 'right) t
-> left_default:'left
-> right_default:'right
-> 'left * 'right
end
type ('k, 'cmp) comparator = ('k, 'cmp) Comparator.Module.t
[@@deprecated "[since 2021-12] use [Comparator.Module.t] instead"]
(** Test if the invariants of the internal AVL search tree hold. *)
val invariants : (_, _, _) t -> bool
(** Returns a first-class module that can be used to build other map/set/etc.
with the same notion of comparison. *)
val comparator_s : ('a, _, 'cmp) t -> ('a, 'cmp) Comparator.Module.t
val comparator : ('a, _, 'cmp) t -> ('a, 'cmp) Comparator.t
(** The empty map. *)
val empty : ('a, 'cmp) Comparator.Module.t -> ('a, 'b, 'cmp) t
(** A map with one (key, data) pair. *)
val singleton : ('a, 'cmp) Comparator.Module.t -> 'a -> 'b -> ('a, 'b, 'cmp) t
(** Creates a map from an association list with unique keys. *)
val of_alist
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) list
-> [ `Ok of ('a, 'b, 'cmp) t | `Duplicate_key of 'a ]
(** Creates a map from an association list with unique keys, returning an error if
duplicate ['a] keys are found. *)
val of_alist_or_error
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) list
-> ('a, 'b, 'cmp) t Or_error.t
(** Creates a map from an association list with unique keys, raising an exception if
duplicate ['a] keys are found. *)
val of_alist_exn : ('a, 'cmp) Comparator.Module.t -> ('a * 'b) list -> ('a, 'b, 'cmp) t
(** Creates a map from an association list with possibly repeated keys. The values in
the map for a given key appear in the same order as they did in the association
list. *)
val of_alist_multi
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) list
-> ('a, 'b list, 'cmp) t
(** Combines an association list into a map, folding together bound values with common
keys. The accumulator is per-key.
Example:
{[
# let map = String.Map.of_alist_fold
[ "a", 1; "a", 10; "b", 2; "b", 20; "b", 200 ]
~init:Int.Set.empty
~f:Set.add
in
print_s [%sexp (map : Int.Set.t String.Map.t)];;
((a (1 10)) (b (2 20 200)))
- : unit = ()
]}
*)
val of_alist_fold
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) list
-> init:'c
-> f:('c -> 'b -> 'c)
-> ('a, 'c, 'cmp) t
(** Combines an association list into a map, reducing together bound values with common
keys. *)
val of_alist_reduce
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) list
-> f:('b -> 'b -> 'b)
-> ('a, 'b, 'cmp) t
(** [of_iteri ~iteri] behaves like [of_alist], except that instead of taking a concrete
data structure, it takes an iteration function. For instance, to convert a string table
into a map: [of_iteri (module String) ~f:(Hashtbl.iteri table)]. It is faster than
adding the elements one by one. *)
val of_iteri
: ('a, 'cmp) Comparator.Module.t
-> iteri:(f:(key:'a -> data:'b -> unit) -> unit)
-> [ `Ok of ('a, 'b, 'cmp) t | `Duplicate_key of 'a ]
(** Like [of_iteri] except that it raises an exception if duplicate ['a] keys are found. *)
val of_iteri_exn
: ('a, 'cmp) Comparator.Module.t
-> iteri:(f:(key:'a -> data:'b -> unit) -> unit)
-> ('a, 'b, 'cmp) t
(** Creates a map from a sorted array of key-data pairs. The input array must be sorted
(either in ascending or descending order), as given by the relevant comparator, and
must not contain duplicate keys. If either of these conditions does not hold,
an error is returned. *)
val of_sorted_array
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) array
-> ('a, 'b, 'cmp) t Or_error.t
(** Like [of_sorted_array] except that it returns a map with broken invariants when an
[Error] would have been returned. *)
val of_sorted_array_unchecked
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) array
-> ('a, 'b, 'cmp) t
(** [of_increasing_iterator_unchecked c ~len ~f] behaves like [of_sorted_array_unchecked c
(Array.init len ~f)], with the additional restriction that a decreasing order is not
supported. The advantage is not requiring you to allocate an intermediate array. [f]
will be called with 0, 1, ... [len - 1], in order. *)
val of_increasing_iterator_unchecked
: ('a, 'cmp) Comparator.Module.t
-> len:int
-> f:(int -> 'a * 'b)
-> ('a, 'b, 'cmp) t
(** [of_increasing_sequence c seq] behaves like [of_sorted_array c (Sequence.to_array
seq)], but does not allocate the intermediate array.
The sequence will be folded over once, and the additional time complexity is {e O(n)}.
*)
val of_increasing_sequence
: ('k, 'cmp) Comparator.Module.t
-> ('k * 'v) Sequence.t
-> ('k, 'v, 'cmp) t Or_error.t
(** Creates a map from an association sequence with unique keys.
[of_sequence c seq] behaves like [of_alist c (Sequence.to_list seq)] but
does not allocate the intermediate list.
If your sequence is increasing, use [of_increasing_sequence].
*)
val of_sequence
: ('k, 'cmp) Comparator.Module.t
-> ('k * 'v) Sequence.t
-> [ `Ok of ('k, 'v, 'cmp) t | `Duplicate_key of 'k ]
(** Creates a map from an association sequence with unique keys, returning an error if
duplicate ['a] keys are found.
[of_sequence_or_error c seq] behaves like [of_alist_or_error c (Sequence.to_list seq)]
but does not allocate the intermediate list.
*)
val of_sequence_or_error
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) Sequence.t
-> ('a, 'b, 'cmp) t Or_error.t
(** Creates a map from an association sequence with unique keys, raising an exception if
duplicate ['a] keys are found.
[of_sequence_exn c seq] behaves like [of_alist_exn c (Sequence.to_list seq)] but
does not allocate the intermediate list.
*)
val of_sequence_exn
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) Sequence.t
-> ('a, 'b, 'cmp) t
(** Creates a map from an association sequence with possibly repeated keys. The values in
the map for a given key appear in the same order as they did in the association
list.
[of_sequence_multi c seq] behaves like [of_alist_exn c (Sequence.to_list seq)] but
does not allocate the intermediate list.
*)
val of_sequence_multi
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) Sequence.t
-> ('a, 'b list, 'cmp) t
(** Combines an association sequence into a map, folding together bound values with common
keys.
[of_sequence_fold c seq ~init ~f] behaves like [of_alist_fold c (Sequence.to_list seq) ~init ~f]
but does not allocate the intermediate list.
*)
val of_sequence_fold
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) Sequence.t
-> init:'c
-> f:('c -> 'b -> 'c)
-> ('a, 'c, 'cmp) t
(** Combines an association sequence into a map, reducing together bound values with common
keys.
[of_sequence_reduce c seq ~f] behaves like [of_alist_reduce c (Sequence.to_list seq) ~f]
but does not allocate the intermediate list. *)
val of_sequence_reduce
: ('a, 'cmp) Comparator.Module.t
-> ('a * 'b) Sequence.t
-> f:('b -> 'b -> 'b)
-> ('a, 'b, 'cmp) t
(** Tests whether a map is empty. *)
val is_empty : (_, _, _) t -> bool
(** [length map] returns the number of elements in [map]. O(1), but [Tree.length] is
O(n). *)
val length : (_, _, _) t -> int
(** Returns a new map with the specified new binding; if the key was already bound, its
previous binding disappears. *)
val set : ('k, 'v, 'cmp) t -> key:'k -> data:'v -> ('k, 'v, 'cmp) t
(** [add t ~key ~data] adds a new entry to [t] mapping [key] to [data] and returns [`Ok]
with the new map, or if [key] is already present in [t], returns [`Duplicate]. *)
val add : ('k, 'v, 'cmp) t -> key:'k -> data:'v -> ('k, 'v, 'cmp) t Or_duplicate.t
val add_exn : ('k, 'v, 'cmp) t -> key:'k -> data:'v -> ('k, 'v, 'cmp) t
(** If [key] is not present then add a singleton list, otherwise, cons data onto the
head of the existing list. *)
val add_multi : ('k, 'v list, 'cmp) t -> key:'k -> data:'v -> ('k, 'v list, 'cmp) t
(** If the key is present, then remove its head element; if the result is empty, remove
the key. *)
val remove_multi : ('k, 'v list, 'cmp) t -> 'k -> ('k, 'v list, 'cmp) t
(** Returns the value bound to the given key, or the empty list if there is none. *)
val find_multi : ('k, 'v list, 'cmp) t -> 'k -> 'v list
(** [change t key ~f] returns a new map [m] that is the same as [t] on all keys except
for [key], and whose value for [key] is defined by [f], i.e., [find m key = f (find
t key)]. *)
val change : ('k, 'v, 'cmp) t -> 'k -> f:('v option -> 'v option) -> ('k, 'v, 'cmp) t
(** [update t key ~f] is [change t key ~f:(fun o -> Some (f o))]. *)
val update : ('k, 'v, 'cmp) t -> 'k -> f:('v option -> 'v) -> ('k, 'v, 'cmp) t
(** Returns [Some value] bound to the given key, or [None] if none exists. *)
val find : ('k, 'v, 'cmp) t -> 'k -> 'v option
(** Returns the value bound to the given key, raising [Caml.Not_found] or [Not_found_s]
if none exists. *)
val find_exn : ('k, 'v, 'cmp) t -> 'k -> 'v
(** Returns a new map with any binding for the key in question removed. *)
val remove : ('k, 'v, 'cmp) t -> 'k -> ('k, 'v, 'cmp) t
(** [mem map key] tests whether [map] contains a binding for [key]. *)
val mem : ('k, _, 'cmp) t -> 'k -> bool
val iter_keys : ('k, _, _) t -> f:('k -> unit) -> unit
val iter : (_, 'v, _) t -> f:('v -> unit) -> unit
val iteri : ('k, 'v, _) t -> f:(key:'k -> data:'v -> unit) -> unit
(** Iterates until the first time [f] returns [Stop]. If [f] returns [Stop], the final
result is [Unfinished]. Otherwise, the final result is [Finished]. *)
val iteri_until
: ('k, 'v, _) t
-> f:(key:'k -> data:'v -> Continue_or_stop.t)
-> Finished_or_unfinished.t
(** Iterates two maps side by side. The complexity of this function is O(M + N). If two
inputs are [[(0, a); (1, a)]] and [[(1, b); (2, b)]], [f] will be called with [[(0,
`Left a); (1, `Both (a, b)); (2, `Right b)]]. *)
val iter2
: ('k, 'v1, 'cmp) t
-> ('k, 'v2, 'cmp) t
-> f:(key:'k -> data:('v1, 'v2) Merge_element.t -> unit)
-> unit
(** Returns a new map with bound values replaced by [f] applied to the bound values.*)
val map : ('k, 'v1, 'cmp) t -> f:('v1 -> 'v2) -> ('k, 'v2, 'cmp) t
(** Like [map], but the passed function takes both [key] and [data] as arguments. *)
val mapi : ('k, 'v1, 'cmp) t -> f:(key:'k -> data:'v1 -> 'v2) -> ('k, 'v2, 'cmp) t
(** Convert map with keys of type ['k2] to a map with keys of type ['k2] using [f]. *)
val map_keys
: ('k2, 'cmp2) Comparator.Module.t
-> ('k1, 'v, 'cmp1) t
-> f:('k1 -> 'k2)
-> [ `Ok of ('k2, 'v, 'cmp2) t | `Duplicate_key of 'k2 ]
(** Like [map_keys], but raises on duplicate key. *)
val map_keys_exn
: ('k2, 'cmp2) Comparator.Module.t
-> ('k1, 'v, 'cmp1) t
-> f:('k1 -> 'k2)
-> ('k2, 'v, 'cmp2) t
(** Folds over keys and data in the map in increasing order of [key]. *)
val fold : ('k, 'v, _) t -> init:'a -> f:(key:'k -> data:'v -> 'a -> 'a) -> 'a
(** Folds over keys and data in the map in increasing order of [key], until the first
time that [f] returns [Stop _]. If [f] returns [Stop final], this function returns
immediately with the value [final]. If [f] never returns [Stop _], and the final
call to [f] returns [Continue last], this function returns [finish last]. *)
val fold_until
: ('k, 'v, _) t
-> init:'acc
-> f:(key:'k -> data:'v -> 'acc -> ('acc, 'final) Container.Continue_or_stop.t)
-> finish:('acc -> 'final)
-> 'final
(** Folds over keys and data in the map in decreasing order of [key]. *)
val fold_right : ('k, 'v, _) t -> init:'a -> f:(key:'k -> data:'v -> 'a -> 'a) -> 'a
(** Folds over two maps side by side, like [iter2]. *)
val fold2
: ('k, 'v1, 'cmp) t
-> ('k, 'v2, 'cmp) t
-> init:'a
-> f:(key:'k -> data:('v1, 'v2) Merge_element.t -> 'a -> 'a)
-> 'a
(** [filter], [filteri], [filter_keys], [filter_map], and [filter_mapi] run in O(n * lg
n) time; they simply accumulate each key & data pair retained by [f] into a new map
using [add]. *)
val filter_keys : ('k, 'v, 'cmp) t -> f:('k -> bool) -> ('k, 'v, 'cmp) t
val filter : ('k, 'v, 'cmp) t -> f:('v -> bool) -> ('k, 'v, 'cmp) t
val filteri : ('k, 'v, 'cmp) t -> f:(key:'k -> data:'v -> bool) -> ('k, 'v, 'cmp) t
(** Returns a new map with bound values filtered by [f] applied to the bound values. *)
val filter_map : ('k, 'v1, 'cmp) t -> f:('v1 -> 'v2 option) -> ('k, 'v2, 'cmp) t
(** Like [filter_map], but the passed function takes both [key] and [data] as
arguments. *)
val filter_mapi
: ('k, 'v1, 'cmp) t
-> f:(key:'k -> data:'v1 -> 'v2 option)
-> ('k, 'v2, 'cmp) t
(** [partition_mapi t ~f] returns two new [t]s, with each key in [t] appearing in
exactly one of the resulting maps depending on its mapping in [f]. *)
val partition_mapi
: ('k, 'v1, 'cmp) t
-> f:(key:'k -> data:'v1 -> ('v2, 'v3) Either.t)
-> ('k, 'v2, 'cmp) t * ('k, 'v3, 'cmp) t
(** [partition_map t ~f = partition_mapi t ~f:(fun ~key:_ ~data -> f data)] *)
val partition_map
: ('k, 'v1, 'cmp) t
-> f:('v1 -> ('v2, 'v3) Either.t)
-> ('k, 'v2, 'cmp) t * ('k, 'v3, 'cmp) t
(**
{[
partitioni_tf t ~f
=
partition_mapi t ~f:(fun ~key ~data ->
if f ~key ~data
then First data
else Second data)
]} *)
val partitioni_tf
: ('k, 'v, 'cmp) t
-> f:(key:'k -> data:'v -> bool)
-> ('k, 'v, 'cmp) t * ('k, 'v, 'cmp) t
(** [partition_tf t ~f = partitioni_tf t ~f:(fun ~key:_ ~data -> f data)] *)
val partition_tf
: ('k, 'v, 'cmp) t
-> f:('v -> bool)
-> ('k, 'v, 'cmp) t * ('k, 'v, 'cmp) t
(** Produces [Ok] of a map including all keys if all data is [Ok], or an [Error]
including all errors otherwise. *)
val combine_errors : ('k, 'v Or_error.t, 'cmp) t -> ('k, 'v, 'cmp) t Or_error.t
(** Returns a total ordering between maps. The first argument is a total ordering used
to compare data associated with equal keys in the two maps. *)
val compare_direct : ('v -> 'v -> int) -> ('k, 'v, 'cmp) t -> ('k, 'v, 'cmp) t -> int
(** Hash function: a building block to use when hashing data structures containing maps in
them. [hash_fold_direct hash_fold_key] is compatible with [compare_direct] iff
[hash_fold_key] is compatible with [(comparator m).compare] of the map [m] being
hashed. *)
val hash_fold_direct : 'k Hash.folder -> 'v Hash.folder -> ('k, 'v, 'cmp) t Hash.folder
(** [equal cmp m1 m2] tests whether the maps [m1] and [m2] are equal, that is, contain
the same keys and associate each key with the same value. [cmp] is the equality
predicate used to compare the values associated with the keys. *)
val equal : ('v -> 'v -> bool) -> ('k, 'v, 'cmp) t -> ('k, 'v, 'cmp) t -> bool
(** Returns a list of the keys in the given map. *)
val keys : ('k, _, _) t -> 'k list
(** Returns a list of the data in the given map. *)
val data : (_, 'v, _) t -> 'v list
(** Creates an association list from the given map. *)
val to_alist
: ?key_order:[ `Increasing | `Decreasing ] (** default is [`Increasing] *)
-> ('k, 'v, _) t
-> ('k * 'v) list
(** {2 Additional operations on maps} *)
(** Merges two maps. The runtime is O(length(t1) + length(t2)). You shouldn't use this
function to merge a list of maps; consider using [merge_skewed] instead. *)
val merge
: ('k, 'v1, 'cmp) t
-> ('k, 'v2, 'cmp) t
-> f:(key:'k -> ('v1, 'v2) Merge_element.t -> 'v3 option)
-> ('k, 'v3, 'cmp) t
(** A special case of [merge], [merge_skewed t1 t2] is a map containing all the
bindings of [t1] and [t2]. Bindings that appear in both [t1] and [t2] are
combined into a single value using the [combine] function. In a call
[combine ~key v1 v2], the value [v1] comes from [t1] and [v2] from [t2].
The runtime of [merge_skewed] is [O(min(l1, l2) * log(max(l1, l2)))], where [l1] is
the length of [t1] and [l2] the length of [t2]. This is likely to be faster than
[merge] when one of the maps is a lot smaller, or when you merge a list of maps. *)
val merge_skewed
: ('k, 'v, 'cmp) t
-> ('k, 'v, 'cmp) t
-> combine:(key:'k -> 'v -> 'v -> 'v)
-> ('k, 'v, 'cmp) t
module Symmetric_diff_element : sig
type ('k, 'v) t = 'k * [ `Left of 'v | `Right of 'v | `Unequal of 'v * 'v ]
[@@deriving_inline compare, equal, sexp, sexp_grammar]
include Ppx_compare_lib.Comparable.S2 with type ('k, 'v) t := ('k, 'v) t
include Ppx_compare_lib.Equal.S2 with type ('k, 'v) t := ('k, 'v) t
include Sexplib0.Sexpable.S2 with type ('k, 'v) t := ('k, 'v) t
val t_sexp_grammar
: 'k Sexplib0.Sexp_grammar.t
-> 'v Sexplib0.Sexp_grammar.t
-> ('k, 'v) t Sexplib0.Sexp_grammar.t
[@@@end]
end
(** [symmetric_diff t1 t2 ~data_equal] returns a list of changes between [t1] and [t2].
It is intended to be efficient in the case where [t1] and [t2] share a large amount
of structure. The keys in the output sequence will be in sorted order.
It is assumed that [data_equal] is at least as equating as physical equality: that
[phys_equal x y] implies [data_equal x y]. Otherwise, [symmetric_diff] may behave in
unexpected ways. For example, with [~data_equal:(fun _ _ -> false)] it is NOT
necessarily the case the resulting change sequence will contain an element
[(k, `Unequal _)] for every key [k] shared by both maps.
Warning: Float equality violates this property! [phys_equal Float.nan Float.nan] is
true, but [Float.(=) Float.nan Float.nan] is false. *)
val symmetric_diff
: ('k, 'v, 'cmp) t
-> ('k, 'v, 'cmp) t
-> data_equal:('v -> 'v -> bool)
-> ('k, 'v) Symmetric_diff_element.t Sequence.t
(** [fold_symmetric_diff t1 t2 ~data_equal] folds across an implicit sequence of changes
between [t1] and [t2], in sorted order by keys. Equivalent to
[Sequence.fold (symmetric_diff t1 t2 ~data_equal)], and more efficient. *)
val fold_symmetric_diff
: ('k, 'v, 'cmp) t
-> ('k, 'v, 'cmp) t
-> data_equal:('v -> 'v -> bool)
-> init:'a
-> f:('a -> ('k, 'v) Symmetric_diff_element.t -> 'a)
-> 'a
(** [min_elt map] returns [Some (key, data)] pair corresponding to the minimum key in
[map], or [None] if empty. *)
val min_elt : ('k, 'v, _) t -> ('k * 'v) option
val min_elt_exn : ('k, 'v, _) t -> 'k * 'v
(** [max_elt map] returns [Some (key, data)] pair corresponding to the maximum key in
[map], or [None] if [map] is empty. *)
val max_elt : ('k, 'v, _) t -> ('k * 'v) option
val max_elt_exn : ('k, 'v, _) t -> 'k * 'v
(** These functions have the same semantics as similar functions in [List]. *)
val for_all : ('k, 'v, _) t -> f:('v -> bool) -> bool
val for_alli : ('k, 'v, _) t -> f:(key:'k -> data:'v -> bool) -> bool
val exists : ('k, 'v, _) t -> f:('v -> bool) -> bool
val existsi : ('k, 'v, _) t -> f:(key:'k -> data:'v -> bool) -> bool
val count : ('k, 'v, _) t -> f:('v -> bool) -> int
val counti : ('k, 'v, _) t -> f:(key:'k -> data:'v -> bool) -> int
(** [split t key] returns a map of keys strictly less than [key], the mapping of [key] if
any, and a map of keys strictly greater than [key].
Runtime is O(m + log n), where n is the size of the input map and m is the size of
the smaller of the two output maps. The O(m) term is due to the need to calculate
the length of the output maps. *)
val split
: ('k, 'v, 'cmp) t
-> 'k
-> ('k, 'v, 'cmp) t * ('k * 'v) option * ('k, 'v, 'cmp) t
(** [append ~lower_part ~upper_part] returns [`Ok map] where [map] contains all the
[(key, value)] pairs from the two input maps if all the keys from [lower_part] are
less than all the keys from [upper_part]. Otherwise it returns
[`Overlapping_key_ranges].
Runtime is O(log n) where n is the size of the larger input map. This can be
significantly faster than [Map.merge] or repeated [Map.add].
{[
assert (match Map.append ~lower_part ~upper_part with
| `Ok whole_map ->
Map.to_alist whole_map
= List.append (to_alist lower_part) (to_alist upper_part)
| `Overlapping_key_ranges -> true);
]} *)
val append
: lower_part:('k, 'v, 'cmp) t
-> upper_part:('k, 'v, 'cmp) t
-> [ `Ok of ('k, 'v, 'cmp) t | `Overlapping_key_ranges ]
(** [subrange t ~lower_bound ~upper_bound] returns a map containing all the entries from
[t] whose keys lie inside the interval indicated by [~lower_bound] and
[~upper_bound]. If this interval is empty, an empty map is returned.
Runtime is O(m + log n), where n is the size of the input map and m is the size of
the output map. The O(m) term is due to the need to calculate the length of the
output map. *)
val subrange
: ('k, 'v, 'cmp) t
-> lower_bound:'k Maybe_bound.t
-> upper_bound:'k Maybe_bound.t
-> ('k, 'v, 'cmp) t
(** [fold_range_inclusive t ~min ~max ~init ~f] folds [f] (with initial value [~init])
over all keys (and their associated values) that are in the range [[min, max]]
(inclusive). *)
val fold_range_inclusive
: ('k, 'v, 'cmp) t
-> min:'k
-> max:'k
-> init:'a
-> f:(key:'k -> data:'v -> 'a -> 'a)
-> 'a
(** [range_to_alist t ~min ~max] returns an associative list of the elements whose keys
lie in [[min, max]] (inclusive), with the smallest key being at the head of the
list. *)
val range_to_alist : ('k, 'v, 'cmp) t -> min:'k -> max:'k -> ('k * 'v) list
(** [closest_key t dir k] returns the [(key, value)] pair in [t] with [key] closest to
[k] that satisfies the given inequality bound.
For example, [closest_key t `Less_than k] would be the pair with the closest key to
[k] where [key < k].
[to_sequence] can be used to get the same results as [closest_key]. It is less
efficient for individual lookups but more efficient for finding many elements starting
at some value. *)
val closest_key
: ('k, 'v, 'cmp) t
-> [ `Greater_or_equal_to | `Greater_than | `Less_or_equal_to | `Less_than ]
-> 'k
-> ('k * 'v) option
(** [nth t n] finds the (key, value) pair of rank n (i.e., such that there are exactly n
keys strictly less than the found key), if one exists. O(log(length t) + n) time. *)
val nth : ('k, 'v, _) t -> int -> ('k * 'v) option
val nth_exn : ('k, 'v, _) t -> int -> 'k * 'v
(** [rank t k] If [k] is in [t], returns the number of keys strictly less than [k] in
[t], and [None] otherwise. *)
val rank : ('k, 'v, 'cmp) t -> 'k -> int option
(** [to_sequence ?order ?keys_greater_or_equal_to ?keys_less_or_equal_to t]
gives a sequence of key-value pairs between [keys_less_or_equal_to] and
[keys_greater_or_equal_to] inclusive, presented in [order]. If
[keys_greater_or_equal_to > keys_less_or_equal_to], the sequence is
empty.
When neither [keys_greater_or_equal_to] nor [keys_less_or_equal_to] are
provided, the cost is O(log n) up front and amortized O(1) to produce
each element. If either is provided (and is used by the order parameter
provided), then the the cost is O(n) up front, and amortized O(1) to
produce each element. *)
val to_sequence
: ?order:[ `Increasing_key (** default *) | `Decreasing_key ]
-> ?keys_greater_or_equal_to:'k
-> ?keys_less_or_equal_to:'k
-> ('k, 'v, 'cmp) t
-> ('k * 'v) Sequence.t
(** [binary_search t ~compare which elt] returns the [(key, value)] pair in [t]
specified by [compare] and [which], if one exists.
[t] must be sorted in increasing order according to [compare], where [compare] and
[elt] divide [t] into three (possibly empty) segments:
{v
| < elt | = elt | > elt |
v}
[binary_search] returns an element on the boundary of segments as specified by
[which]. See the diagram below next to the [which] variants.
[binary_search] does not check that [compare] orders [t], and behavior is
unspecified if [compare] doesn't order [t]. Behavior is also unspecified if
[compare] mutates [t]. *)
val binary_search
: ('k, 'v, 'cmp) t
-> compare:(key:'k -> data:'v -> 'key -> int)
-> [ `Last_strictly_less_than (** {v | < elt X | v} *)
| `Last_less_than_or_equal_to (** {v | <= elt X | v} *)
| `Last_equal_to (** {v | = elt X | v} *)
| `First_equal_to (** {v | X = elt | v} *)
| `First_greater_than_or_equal_to (** {v | X >= elt | v} *)
| `First_strictly_greater_than (** {v | X > elt | v} *)
]
-> 'key
-> ('k * 'v) option
(** [binary_search_segmented t ~segment_of which] takes a [segment_of] function that
divides [t] into two (possibly empty) segments:
{v
| segment_of elt = `Left | segment_of elt = `Right |
v}
[binary_search_segmented] returns the [(key, value)] pair on the boundary of the
segments as specified by [which]: [`Last_on_left] yields the last element of the
left segment, while [`First_on_right] yields the first element of the right segment.
It returns [None] if the segment is empty.
[binary_search_segmented] does not check that [segment_of] segments [t] as in the
diagram, and behavior is unspecified if [segment_of] doesn't segment [t]. Behavior
is also unspecified if [segment_of] mutates [t]. *)
val binary_search_segmented
: ('k, 'v, 'cmp) t
-> segment_of:(key:'k -> data:'v -> [ `Left | `Right ])
-> [ `Last_on_left | `First_on_right ]
-> ('k * 'v) option
(** [binary_search_subrange] takes a [compare] function that divides [t] into three
(possibly empty) segments with respect to [lower_bound] and [upper_bound]:
{v
| Below_lower_bound | In_range | Above_upper_bound |
v}
and returns a map of the [In_range] segment.
Runtime is O(log m + n) where [m] is the length of the input map and [n] is the
length of the output. The linear term in [n] is to compute the length of the output.
Behavior is undefined if [compare] does not segment [t] as shown above, or if
[compare] mutates its inputs. *)
val binary_search_subrange
: ('k, 'v, 'cmp) t
-> compare:(key:'k -> data:'v -> 'bound -> int)
-> lower_bound:'bound Maybe_bound.t
-> upper_bound:'bound Maybe_bound.t
-> ('k, 'v, 'cmp) t
(** [M] is meant to be used in combination with OCaml applicative functor types:
{[
type string_to_int_map = int Map.M(String).t
]}
which stands for:
{[
type string_to_int_map = (String.t, int, String.comparator_witness) Map.t
]}
The point is that [int Map.M(String).t] supports deriving, whereas the second syntax
doesn't (because there is no such thing as, say, [String.sexp_of_comparator_witness]
-- instead you would want to pass the comparator directly).
In addition, when using [@@deriving], the requirements on the key module are only
those needed to satisfy what you are trying to derive on the map itself. Say you
write:
{[
type t = int Map.M(X).t [@@deriving hash]
]}
then this will be well typed exactly if [X] contains at least:
- a type [t] with no parameters
- a comparator witness
- a [hash_fold_t] function with the right type *)
module M (K : sig
type t
type comparator_witness
end) : sig
type nonrec 'v t = (K.t, 'v, K.comparator_witness) t
end
include For_deriving with type ('key, 'value, 'cmp) t := ('key, 'value, 'cmp) t
(** [Using_comparator] is a similar interface as the toplevel of [Map], except the
functions take a [~comparator:('k, 'cmp) Comparator.t], whereas the functions at the
toplevel of [Map] take a [('k, 'cmp) comparator]. *)
module Using_comparator : sig
type nonrec ('k, +'v, 'cmp) t = ('k, 'v, 'cmp) t [@@deriving_inline sexp_of]
val sexp_of_t
: ('k -> Sexplib0.Sexp.t)
-> ('v -> Sexplib0.Sexp.t)
-> ('cmp -> Sexplib0.Sexp.t)
-> ('k, 'v, 'cmp) t
-> Sexplib0.Sexp.t
[@@@end]
val t_of_sexp_direct
: comparator:('k, 'cmp) Comparator.t
-> (Sexp.t -> 'k)
-> (Sexp.t -> 'v)
-> Sexp.t
-> ('k, 'v, 'cmp) t
module Tree : sig
type (+'k, +'v, 'cmp) t [@@deriving_inline sexp_of]
val sexp_of_t
: ('k -> Sexplib0.Sexp.t)
-> ('v -> Sexplib0.Sexp.t)
-> ('cmp -> Sexplib0.Sexp.t)
-> ('k, 'v, 'cmp) t
-> Sexplib0.Sexp.t
[@@@end]
val t_of_sexp_direct
: comparator:('k, 'cmp) Comparator.t
-> (Sexp.t -> 'k)
-> (Sexp.t -> 'v)
-> Sexp.t
-> ('k, 'v, 'cmp) t
include
Creators_and_accessors3_with_comparator
with type ('a, 'b, 'c) t := ('a, 'b, 'c) t
with type ('a, 'b, 'c) tree := ('a, 'b, 'c) t
val empty_without_value_restriction : (_, _, _) t
(** [Build_increasing] can be used to construct a map incrementally from a
sequence that is known to be increasing.
The total time complexity of constructing a map this way is O(n), which is more
efficient than using [Map.add] by a logarithmic factor.
This interface can be thought of as a dual of [to_sequence], but we don't have
an equally neat idiom for the duals of sequences ([of_sequence] is much less
general because it does not allow the sequence to be produced asynchronously). *)
module Build_increasing : sig
type ('a, 'b, 'c) tree := ('a, 'b, 'c) t
type ('k, 'v, 'w) t
val empty : ('k, 'v, 'w) t
(** Time complexity of [add_exn] is amortized constant-time (if [t] is used
linearly), with a worst-case O(log(n)) time. *)
val add_exn
: ('k, 'v, 'w) t
-> comparator:('k, 'w) Comparator.t
-> key:'k
-> data:'v
-> ('k, 'v, 'w) t
(** Time complexity is O(log(n)). *)
val to_tree : ('k, 'v, 'w) t -> ('k, 'v, 'w) tree
end
end
include
Accessors3
with type ('a, 'b, 'c) t := ('a, 'b, 'c) t
with type ('a, 'b, 'c) tree := ('a, 'b, 'c) Tree.t
include
Creators3_with_comparator
with type ('a, 'b, 'c) t := ('a, 'b, 'c) t
with type ('a, 'b, 'c) tree := ('a, 'b, 'c) Tree.t
val comparator : ('a, _, 'cmp) t -> ('a, 'cmp) Comparator.t
val hash_fold_direct
: 'k Hash.folder
-> 'v Hash.folder
-> ('k, 'v, 'cmp) t Hash.folder
(** To get around the value restriction, apply the functor and include it. You
can see an example of this in the [Poly] submodule below. *)
module Empty_without_value_restriction (K : Comparator.S1) : sig
val empty : ('a K.t, 'v, K.comparator_witness) t
end
end
(** A polymorphic Map. *)
module Poly :
S_poly
with type ('key, +'value) t = ('key, 'value, Comparator.Poly.comparator_witness) t
and type ('key, +'value) tree =
('key, 'value, Comparator.Poly.comparator_witness) Using_comparator.Tree.t
and type comparator_witness = Comparator.Poly.comparator_witness
(** Create a map from a tree using the given comparator. *)
val of_tree
: ('k, 'cmp) Comparator.Module.t
-> ('k, 'v, 'cmp) Using_comparator.Tree.t
-> ('k, 'v, 'cmp) t
(** Extract a tree from a map. *)
val to_tree : ('k, 'v, 'cmp) t -> ('k, 'v, 'cmp) Using_comparator.Tree.t
(** {2 Modules and module types for extending [Map]}
For use in extensions of Base, like [Core]. *)
module With_comparator = With_comparator
module With_first_class_module = With_first_class_module
module Without_comparator = Without_comparator
module type For_deriving = For_deriving
module type S_poly = S_poly
module type Accessors1 = Accessors1
module type Accessors2 = Accessors2
module type Accessors3 = Accessors3
module type Accessors3_with_comparator = Accessors3_with_comparator
module type Accessors_generic = Accessors_generic
module type Creators1 = Creators1
module type Creators2 = Creators2
module type Creators3_with_comparator = Creators3_with_comparator
module type Creators_and_accessors1 = Creators_and_accessors1
module type Creators_and_accessors2 = Creators_and_accessors2
module type Creators_and_accessors3_with_comparator =
Creators_and_accessors3_with_comparator
module type Creators_and_accessors_generic = Creators_and_accessors_generic
module type Creators_generic = Creators_generic
end