binary-tree-typed 2.5.3 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +126 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +126 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +126 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +126 -0
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
- package/dist/types/data-structures/base/linear-base.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
- package/dist/types/data-structures/heap/heap.d.ts +42 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
- package/dist/types/data-structures/queue/deque.d.ts +90 -1
- package/dist/types/data-structures/queue/queue.d.ts +36 -0
- package/dist/types/data-structures/stack/stack.d.ts +30 -0
- package/dist/types/data-structures/trie/trie.d.ts +36 -0
- package/dist/umd/binary-tree-typed.js +126 -0
- package/dist/umd/binary-tree-typed.js.map +1 -1
- package/dist/umd/binary-tree-typed.min.js +1 -1
- package/dist/umd/binary-tree-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +32 -0
- package/src/data-structures/base/linear-base.ts +11 -0
- package/src/data-structures/binary-tree/avl-tree.ts +36 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +42 -0
- package/src/data-structures/binary-tree/binary-tree.ts +75 -0
- package/src/data-structures/binary-tree/bst.ts +72 -0
- package/src/data-structures/binary-tree/red-black-tree.ts +57 -0
- package/src/data-structures/binary-tree/segment-tree.ts +18 -0
- package/src/data-structures/binary-tree/tree-map.ts +375 -0
- package/src/data-structures/binary-tree/tree-multi-map.ts +392 -0
- package/src/data-structures/binary-tree/tree-multi-set.ts +336 -0
- package/src/data-structures/binary-tree/tree-set.ts +492 -0
- package/src/data-structures/graph/directed-graph.ts +30 -0
- package/src/data-structures/graph/undirected-graph.ts +27 -0
- package/src/data-structures/hash/hash-map.ts +33 -0
- package/src/data-structures/heap/heap.ts +42 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +90 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +54 -0
- package/src/data-structures/matrix/matrix.ts +24 -0
- package/src/data-structures/queue/deque.ts +103 -1
- package/src/data-structures/queue/queue.ts +36 -0
- package/src/data-structures/stack/stack.ts +30 -0
- package/src/data-structures/trie/trie.ts +36 -0
|
@@ -110,6 +110,9 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
110
110
|
|
|
111
111
|
|
|
112
112
|
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
113
116
|
|
|
114
117
|
|
|
115
118
|
|
|
@@ -290,6 +293,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
290
293
|
|
|
291
294
|
|
|
292
295
|
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
293
311
|
|
|
294
312
|
|
|
295
313
|
|
|
@@ -482,6 +500,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
482
500
|
|
|
483
501
|
|
|
484
502
|
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
485
518
|
|
|
486
519
|
|
|
487
520
|
|
|
@@ -539,6 +572,9 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
539
572
|
|
|
540
573
|
|
|
541
574
|
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
542
578
|
|
|
543
579
|
|
|
544
580
|
|
|
@@ -714,6 +750,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
714
750
|
|
|
715
751
|
|
|
716
752
|
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
717
768
|
|
|
718
769
|
|
|
719
770
|
|
|
@@ -781,6 +832,9 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
781
832
|
|
|
782
833
|
|
|
783
834
|
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
784
838
|
|
|
785
839
|
|
|
786
840
|
|
|
@@ -977,6 +1031,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
977
1031
|
|
|
978
1032
|
|
|
979
1033
|
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
|
|
980
1049
|
|
|
981
1050
|
|
|
982
1051
|
|
|
@@ -1048,6 +1117,9 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1048
1117
|
|
|
1049
1118
|
|
|
1050
1119
|
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1051
1123
|
|
|
1052
1124
|
|
|
1053
1125
|
|
|
@@ -1097,6 +1169,9 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1097
1169
|
|
|
1098
1170
|
|
|
1099
1171
|
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
|
|
1100
1175
|
|
|
1101
1176
|
|
|
1102
1177
|
|
|
@@ -1277,6 +1352,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1277
1352
|
|
|
1278
1353
|
|
|
1279
1354
|
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
|
|
1280
1370
|
|
|
1281
1371
|
|
|
1282
1372
|
|
|
@@ -1315,6 +1405,48 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1315
1405
|
}
|
|
1316
1406
|
}
|
|
1317
1407
|
|
|
1408
|
+
/**
|
|
1409
|
+
* Iterate over all elements with multiplicity (Set-compatible, alias for `[Symbol.iterator]`).
|
|
1410
|
+
* @remarks Each key is yielded `count(key)` times. Time O(size), Space O(1) per step.
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
* @example
|
|
1420
|
+
* // Iterate with multiplicity
|
|
1421
|
+
* const ms = new TreeMultiSet<number>();
|
|
1422
|
+
* ms.add(1); ms.add(1); ms.add(2); ms.add(3); ms.add(3); ms.add(3);
|
|
1423
|
+
* console.log([...ms.keys()]); // [1, 1, 2, 3, 3, 3];
|
|
1424
|
+
*/
|
|
1425
|
+
*keys(): IterableIterator<K> {
|
|
1426
|
+
yield* this;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
/**
|
|
1430
|
+
* Iterate over all elements with multiplicity (Set-compatible, alias for `[Symbol.iterator]`).
|
|
1431
|
+
* @remarks Each key is yielded `count(key)` times. Time O(size), Space O(1) per step.
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
* @example
|
|
1441
|
+
* // Iterate with multiplicity
|
|
1442
|
+
* const ms = new TreeMultiSet<number>();
|
|
1443
|
+
* ms.add(5); ms.add(5); ms.add(10);
|
|
1444
|
+
* console.log([...ms.values()]); // [5, 5, 10];
|
|
1445
|
+
*/
|
|
1446
|
+
*values(): IterableIterator<K> {
|
|
1447
|
+
yield* this;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1318
1450
|
/**
|
|
1319
1451
|
* Returns an array with all elements (expanded).
|
|
1320
1452
|
* @remarks Time O(size), Space O(size)
|
|
@@ -1480,6 +1612,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1480
1612
|
|
|
1481
1613
|
|
|
1482
1614
|
|
|
1615
|
+
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
|
|
1628
|
+
|
|
1629
|
+
|
|
1483
1630
|
|
|
1484
1631
|
|
|
1485
1632
|
|
|
@@ -1536,6 +1683,9 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1536
1683
|
|
|
1537
1684
|
|
|
1538
1685
|
|
|
1686
|
+
|
|
1687
|
+
|
|
1688
|
+
|
|
1539
1689
|
|
|
1540
1690
|
|
|
1541
1691
|
|
|
@@ -1580,6 +1730,9 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1580
1730
|
|
|
1581
1731
|
|
|
1582
1732
|
|
|
1733
|
+
|
|
1734
|
+
|
|
1735
|
+
|
|
1583
1736
|
|
|
1584
1737
|
|
|
1585
1738
|
|
|
@@ -1771,6 +1924,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1771
1924
|
|
|
1772
1925
|
|
|
1773
1926
|
|
|
1927
|
+
|
|
1928
|
+
|
|
1929
|
+
|
|
1930
|
+
|
|
1931
|
+
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
|
|
1938
|
+
|
|
1939
|
+
|
|
1940
|
+
|
|
1941
|
+
|
|
1774
1942
|
|
|
1775
1943
|
|
|
1776
1944
|
|
|
@@ -1831,6 +1999,9 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1831
1999
|
|
|
1832
2000
|
|
|
1833
2001
|
|
|
2002
|
+
|
|
2003
|
+
|
|
2004
|
+
|
|
1834
2005
|
|
|
1835
2006
|
|
|
1836
2007
|
|
|
@@ -1876,6 +2047,9 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1876
2047
|
|
|
1877
2048
|
|
|
1878
2049
|
|
|
2050
|
+
|
|
2051
|
+
|
|
2052
|
+
|
|
1879
2053
|
|
|
1880
2054
|
|
|
1881
2055
|
|
|
@@ -1921,6 +2095,9 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1921
2095
|
|
|
1922
2096
|
|
|
1923
2097
|
|
|
2098
|
+
|
|
2099
|
+
|
|
2100
|
+
|
|
1924
2101
|
|
|
1925
2102
|
|
|
1926
2103
|
|
|
@@ -1970,6 +2147,9 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1970
2147
|
|
|
1971
2148
|
|
|
1972
2149
|
|
|
2150
|
+
|
|
2151
|
+
|
|
2152
|
+
|
|
1973
2153
|
|
|
1974
2154
|
|
|
1975
2155
|
|
|
@@ -2120,6 +2300,18 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2120
2300
|
|
|
2121
2301
|
|
|
2122
2302
|
|
|
2303
|
+
|
|
2304
|
+
|
|
2305
|
+
|
|
2306
|
+
|
|
2307
|
+
|
|
2308
|
+
|
|
2309
|
+
|
|
2310
|
+
|
|
2311
|
+
|
|
2312
|
+
|
|
2313
|
+
|
|
2314
|
+
|
|
2123
2315
|
|
|
2124
2316
|
|
|
2125
2317
|
|
|
@@ -2278,6 +2470,18 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2278
2470
|
|
|
2279
2471
|
|
|
2280
2472
|
|
|
2473
|
+
|
|
2474
|
+
|
|
2475
|
+
|
|
2476
|
+
|
|
2477
|
+
|
|
2478
|
+
|
|
2479
|
+
|
|
2480
|
+
|
|
2481
|
+
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
|
|
2281
2485
|
|
|
2282
2486
|
|
|
2283
2487
|
|
|
@@ -2436,6 +2640,18 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2436
2640
|
|
|
2437
2641
|
|
|
2438
2642
|
|
|
2643
|
+
|
|
2644
|
+
|
|
2645
|
+
|
|
2646
|
+
|
|
2647
|
+
|
|
2648
|
+
|
|
2649
|
+
|
|
2650
|
+
|
|
2651
|
+
|
|
2652
|
+
|
|
2653
|
+
|
|
2654
|
+
|
|
2439
2655
|
|
|
2440
2656
|
|
|
2441
2657
|
|
|
@@ -2593,6 +2809,18 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2593
2809
|
|
|
2594
2810
|
|
|
2595
2811
|
|
|
2812
|
+
|
|
2813
|
+
|
|
2814
|
+
|
|
2815
|
+
|
|
2816
|
+
|
|
2817
|
+
|
|
2818
|
+
|
|
2819
|
+
|
|
2820
|
+
|
|
2821
|
+
|
|
2822
|
+
|
|
2823
|
+
|
|
2596
2824
|
|
|
2597
2825
|
|
|
2598
2826
|
|
|
@@ -2786,6 +3014,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2786
3014
|
|
|
2787
3015
|
|
|
2788
3016
|
|
|
3017
|
+
|
|
3018
|
+
|
|
3019
|
+
|
|
3020
|
+
|
|
3021
|
+
|
|
3022
|
+
|
|
3023
|
+
|
|
3024
|
+
|
|
3025
|
+
|
|
3026
|
+
|
|
3027
|
+
|
|
3028
|
+
|
|
3029
|
+
|
|
3030
|
+
|
|
3031
|
+
|
|
2789
3032
|
|
|
2790
3033
|
|
|
2791
3034
|
|
|
@@ -2983,6 +3226,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2983
3226
|
|
|
2984
3227
|
|
|
2985
3228
|
|
|
3229
|
+
|
|
3230
|
+
|
|
3231
|
+
|
|
3232
|
+
|
|
3233
|
+
|
|
3234
|
+
|
|
3235
|
+
|
|
3236
|
+
|
|
3237
|
+
|
|
3238
|
+
|
|
3239
|
+
|
|
3240
|
+
|
|
3241
|
+
|
|
3242
|
+
|
|
3243
|
+
|
|
2986
3244
|
|
|
2987
3245
|
|
|
2988
3246
|
|
|
@@ -3187,6 +3445,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
3187
3445
|
|
|
3188
3446
|
|
|
3189
3447
|
|
|
3448
|
+
|
|
3449
|
+
|
|
3450
|
+
|
|
3451
|
+
|
|
3452
|
+
|
|
3453
|
+
|
|
3454
|
+
|
|
3455
|
+
|
|
3456
|
+
|
|
3457
|
+
|
|
3458
|
+
|
|
3459
|
+
|
|
3460
|
+
|
|
3461
|
+
|
|
3462
|
+
|
|
3190
3463
|
|
|
3191
3464
|
|
|
3192
3465
|
|
|
@@ -3386,6 +3659,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
3386
3659
|
|
|
3387
3660
|
|
|
3388
3661
|
|
|
3662
|
+
|
|
3663
|
+
|
|
3664
|
+
|
|
3665
|
+
|
|
3666
|
+
|
|
3667
|
+
|
|
3668
|
+
|
|
3669
|
+
|
|
3670
|
+
|
|
3671
|
+
|
|
3672
|
+
|
|
3673
|
+
|
|
3674
|
+
|
|
3675
|
+
|
|
3676
|
+
|
|
3389
3677
|
|
|
3390
3678
|
|
|
3391
3679
|
|
|
@@ -3626,6 +3914,12 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
3626
3914
|
|
|
3627
3915
|
|
|
3628
3916
|
|
|
3917
|
+
|
|
3918
|
+
|
|
3919
|
+
|
|
3920
|
+
|
|
3921
|
+
|
|
3922
|
+
|
|
3629
3923
|
* @example
|
|
3630
3924
|
* // Pagination by position in tree order
|
|
3631
3925
|
* const tree = new TreeMultiSet<number>(
|
|
@@ -3665,6 +3959,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
3665
3959
|
|
|
3666
3960
|
|
|
3667
3961
|
|
|
3962
|
+
|
|
3963
|
+
|
|
3964
|
+
|
|
3965
|
+
|
|
3966
|
+
|
|
3967
|
+
|
|
3968
|
+
|
|
3969
|
+
|
|
3970
|
+
|
|
3971
|
+
|
|
3972
|
+
|
|
3973
|
+
|
|
3974
|
+
|
|
3975
|
+
|
|
3976
|
+
|
|
3668
3977
|
|
|
3669
3978
|
|
|
3670
3979
|
|
|
@@ -3824,6 +4133,18 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
3824
4133
|
|
|
3825
4134
|
|
|
3826
4135
|
|
|
4136
|
+
|
|
4137
|
+
|
|
4138
|
+
|
|
4139
|
+
|
|
4140
|
+
|
|
4141
|
+
|
|
4142
|
+
|
|
4143
|
+
|
|
4144
|
+
|
|
4145
|
+
|
|
4146
|
+
|
|
4147
|
+
|
|
3827
4148
|
|
|
3828
4149
|
|
|
3829
4150
|
|
|
@@ -4020,6 +4341,21 @@ export class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
4020
4341
|
|
|
4021
4342
|
|
|
4022
4343
|
|
|
4344
|
+
|
|
4345
|
+
|
|
4346
|
+
|
|
4347
|
+
|
|
4348
|
+
|
|
4349
|
+
|
|
4350
|
+
|
|
4351
|
+
|
|
4352
|
+
|
|
4353
|
+
|
|
4354
|
+
|
|
4355
|
+
|
|
4356
|
+
|
|
4357
|
+
|
|
4358
|
+
|
|
4023
4359
|
|
|
4024
4360
|
|
|
4025
4361
|
|