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.
Files changed (61) hide show
  1. package/dist/cjs/index.cjs +126 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +126 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +126 -0
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +126 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  10. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
  24. package/dist/types/data-structures/heap/heap.d.ts +42 -0
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +90 -1
  30. package/dist/types/data-structures/queue/queue.d.ts +36 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +30 -0
  32. package/dist/types/data-structures/trie/trie.d.ts +36 -0
  33. package/dist/umd/binary-tree-typed.js +126 -0
  34. package/dist/umd/binary-tree-typed.js.map +1 -1
  35. package/dist/umd/binary-tree-typed.min.js +1 -1
  36. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  37. package/package.json +2 -2
  38. package/src/data-structures/base/iterable-element-base.ts +32 -0
  39. package/src/data-structures/base/linear-base.ts +11 -0
  40. package/src/data-structures/binary-tree/avl-tree.ts +36 -0
  41. package/src/data-structures/binary-tree/binary-indexed-tree.ts +42 -0
  42. package/src/data-structures/binary-tree/binary-tree.ts +75 -0
  43. package/src/data-structures/binary-tree/bst.ts +72 -0
  44. package/src/data-structures/binary-tree/red-black-tree.ts +57 -0
  45. package/src/data-structures/binary-tree/segment-tree.ts +18 -0
  46. package/src/data-structures/binary-tree/tree-map.ts +375 -0
  47. package/src/data-structures/binary-tree/tree-multi-map.ts +392 -0
  48. package/src/data-structures/binary-tree/tree-multi-set.ts +336 -0
  49. package/src/data-structures/binary-tree/tree-set.ts +492 -0
  50. package/src/data-structures/graph/directed-graph.ts +30 -0
  51. package/src/data-structures/graph/undirected-graph.ts +27 -0
  52. package/src/data-structures/hash/hash-map.ts +33 -0
  53. package/src/data-structures/heap/heap.ts +42 -0
  54. package/src/data-structures/linked-list/doubly-linked-list.ts +90 -2
  55. package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
  56. package/src/data-structures/linked-list/skip-linked-list.ts +54 -0
  57. package/src/data-structures/matrix/matrix.ts +24 -0
  58. package/src/data-structures/queue/deque.ts +103 -1
  59. package/src/data-structures/queue/queue.ts +36 -0
  60. package/src/data-structures/stack/stack.ts +30 -0
  61. package/src/data-structures/trie/trie.ts +36 -0
@@ -216,6 +216,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
216
216
 
217
217
 
218
218
 
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
219
234
 
220
235
 
221
236
 
@@ -406,6 +421,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
406
421
 
407
422
 
408
423
 
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
409
439
 
410
440
 
411
441
 
@@ -447,6 +477,18 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
447
477
 
448
478
 
449
479
 
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
450
492
 
451
493
 
452
494
 
@@ -639,6 +681,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
639
681
 
640
682
 
641
683
 
684
+
685
+
686
+
687
+
688
+
689
+
690
+
691
+
692
+
693
+
694
+
695
+
696
+
697
+
698
+
642
699
 
643
700
 
644
701
 
@@ -840,6 +897,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
840
897
 
841
898
 
842
899
 
900
+
901
+
902
+
903
+
904
+
905
+
906
+
907
+
908
+
909
+
910
+
911
+
912
+
913
+
914
+
843
915
 
844
916
 
845
917
 
@@ -1036,6 +1108,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1036
1108
 
1037
1109
 
1038
1110
 
1111
+
1112
+
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1121
+
1122
+
1123
+
1124
+
1125
+
1039
1126
 
1040
1127
 
1041
1128
 
@@ -1223,6 +1310,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1223
1310
 
1224
1311
 
1225
1312
 
1313
+
1314
+
1315
+
1316
+
1317
+
1318
+
1319
+
1320
+
1321
+
1322
+
1323
+
1324
+
1325
+
1326
+
1327
+
1226
1328
 
1227
1329
 
1228
1330
 
@@ -1411,6 +1513,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1411
1513
 
1412
1514
 
1413
1515
 
1516
+
1517
+
1518
+
1519
+
1520
+
1521
+
1522
+
1523
+
1524
+
1525
+
1526
+
1527
+
1528
+
1529
+
1530
+
1414
1531
 
1415
1532
 
1416
1533
 
@@ -1599,6 +1716,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1599
1716
 
1600
1717
 
1601
1718
 
1719
+
1720
+
1721
+
1722
+
1723
+
1724
+
1725
+
1726
+
1727
+
1728
+
1729
+
1730
+
1731
+
1732
+
1733
+
1602
1734
 
1603
1735
 
1604
1736
 
@@ -1788,6 +1920,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1788
1920
 
1789
1921
 
1790
1922
 
1923
+
1924
+
1925
+
1926
+
1927
+
1928
+
1929
+
1930
+
1931
+
1932
+
1933
+
1934
+
1935
+
1936
+
1937
+
1791
1938
 
1792
1939
 
1793
1940
 
@@ -1979,6 +2126,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1979
2126
 
1980
2127
 
1981
2128
 
2129
+
2130
+
2131
+
2132
+
2133
+
2134
+
2135
+
2136
+
2137
+
2138
+
2139
+
2140
+
2141
+
2142
+
2143
+
1982
2144
 
1983
2145
 
1984
2146
 
@@ -2169,6 +2331,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2169
2331
 
2170
2332
 
2171
2333
 
2334
+
2335
+
2336
+
2337
+
2338
+
2339
+
2340
+
2341
+
2342
+
2343
+
2344
+
2345
+
2346
+
2347
+
2348
+
2172
2349
 
2173
2350
 
2174
2351
 
@@ -2357,6 +2534,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2357
2534
 
2358
2535
 
2359
2536
 
2537
+
2538
+
2539
+
2540
+
2541
+
2542
+
2543
+
2544
+
2545
+
2546
+
2547
+
2548
+
2549
+
2550
+
2551
+
2360
2552
 
2361
2553
 
2362
2554
 
@@ -2543,6 +2735,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2543
2735
 
2544
2736
 
2545
2737
 
2738
+
2739
+
2740
+
2741
+
2742
+
2743
+
2744
+
2745
+
2746
+
2747
+
2748
+
2749
+
2750
+
2751
+
2752
+
2546
2753
 
2547
2754
 
2548
2755
 
@@ -2728,6 +2935,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2728
2935
 
2729
2936
 
2730
2937
 
2938
+
2939
+
2940
+
2941
+
2942
+
2943
+
2944
+
2945
+
2946
+
2947
+
2948
+
2949
+
2950
+
2951
+
2952
+
2731
2953
 
2732
2954
 
2733
2955
 
@@ -2913,6 +3135,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2913
3135
 
2914
3136
 
2915
3137
 
3138
+
3139
+
3140
+
3141
+
3142
+
3143
+
3144
+
3145
+
3146
+
3147
+
3148
+
3149
+
3150
+
3151
+
3152
+
2916
3153
 
2917
3154
 
2918
3155
 
@@ -3101,6 +3338,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3101
3338
 
3102
3339
 
3103
3340
 
3341
+
3342
+
3343
+
3344
+
3345
+
3346
+
3347
+
3348
+
3349
+
3350
+
3351
+
3352
+
3353
+
3354
+
3355
+
3104
3356
 
3105
3357
 
3106
3358
 
@@ -3288,6 +3540,21 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3288
3540
 
3289
3541
 
3290
3542
 
3543
+
3544
+
3545
+
3546
+
3547
+
3548
+
3549
+
3550
+
3551
+
3552
+
3553
+
3554
+
3555
+
3556
+
3557
+
3291
3558
 
3292
3559
 
3293
3560
 
@@ -3347,6 +3614,9 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3347
3614
 
3348
3615
 
3349
3616
 
3617
+
3618
+
3619
+
3350
3620
 
3351
3621
 
3352
3622
 
@@ -3417,6 +3687,9 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3417
3687
 
3418
3688
 
3419
3689
 
3690
+
3691
+
3692
+
3420
3693
 
3421
3694
 
3422
3695
 
@@ -3465,6 +3738,9 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3465
3738
 
3466
3739
 
3467
3740
 
3741
+
3742
+
3743
+
3468
3744
 
3469
3745
 
3470
3746
 
@@ -3515,6 +3791,9 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3515
3791
 
3516
3792
 
3517
3793
 
3794
+
3795
+
3796
+
3518
3797
 
3519
3798
 
3520
3799
 
@@ -3666,6 +3945,18 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3666
3945
 
3667
3946
 
3668
3947
 
3948
+
3949
+
3950
+
3951
+
3952
+
3953
+
3954
+
3955
+
3956
+
3957
+
3958
+
3959
+
3669
3960
 
3670
3961
 
3671
3962
 
@@ -3836,6 +4127,18 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3836
4127
 
3837
4128
 
3838
4129
 
4130
+
4131
+
4132
+
4133
+
4134
+
4135
+
4136
+
4137
+
4138
+
4139
+
4140
+
4141
+
3839
4142
 
3840
4143
 
3841
4144
 
@@ -3998,6 +4301,18 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3998
4301
 
3999
4302
 
4000
4303
 
4304
+
4305
+
4306
+
4307
+
4308
+
4309
+
4310
+
4311
+
4312
+
4313
+
4314
+
4315
+
4001
4316
 
4002
4317
 
4003
4318
 
@@ -4158,6 +4473,18 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
4158
4473
 
4159
4474
 
4160
4475
 
4476
+
4477
+
4478
+
4479
+
4480
+
4481
+
4482
+
4483
+
4484
+
4485
+
4486
+
4487
+
4161
4488
 
4162
4489
 
4163
4490
 
@@ -4321,6 +4648,18 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
4321
4648
 
4322
4649
 
4323
4650
 
4651
+
4652
+
4653
+
4654
+
4655
+
4656
+
4657
+
4658
+
4659
+
4660
+
4661
+
4662
+
4324
4663
 
4325
4664
 
4326
4665
 
@@ -4394,6 +4733,12 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
4394
4733
 
4395
4734
 
4396
4735
 
4736
+
4737
+
4738
+
4739
+
4740
+
4741
+
4397
4742
  * @example
4398
4743
  * // Pagination by position in tree order
4399
4744
  * const tree = new TreeSet<number>(
@@ -4586,6 +4931,11 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
4586
4931
 
4587
4932
 
4588
4933
 
4934
+
4935
+
4936
+
4937
+
4938
+
4589
4939
 
4590
4940
 
4591
4941
 
@@ -4599,5 +4949,93 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
4599
4949
  * copy.delete(1);
4600
4950
  * console.log(ts.has(1)); // true;
4601
4951
  */
4952
+ /**
4953
+ * Return a new TreeSet containing all elements from both sets.
4954
+ * @remarks When both sets share the same comparator, uses O(n+m) merge. Otherwise O(m log n).
4955
+ * @param other - Any iterable of keys.
4956
+ * @returns A new TreeSet.
4957
+ * @example
4958
+ * // Merge two sets
4959
+ * console.log([...a.union(b)]); // [1, 2, 3, 4, 5, 6, 7];
4960
+ */
4961
+ union(other: Iterable<K>): TreeSet<K>;
4962
+ /**
4963
+ * Return a new TreeSet containing only elements present in both sets.
4964
+ * @remarks Time O(n+m) with ordered merge when possible, otherwise O(n log m).
4965
+ * @param other - Any iterable of keys (converted to Set for fast lookup if not a TreeSet).
4966
+ * @returns A new TreeSet.
4967
+ * @example
4968
+ * // Find common elements
4969
+ * console.log([...a.intersection(b)]); // [3, 4, 5];
4970
+ */
4971
+ intersection(other: Iterable<K>): TreeSet<K>;
4972
+ /**
4973
+ * Return a new TreeSet containing elements in this set but not in the other.
4974
+ * @remarks Time O(n+m) with ordered merge when possible, otherwise O(n log m).
4975
+ * @param other - Any iterable of keys.
4976
+ * @returns A new TreeSet.
4977
+ * @example
4978
+ * // Find exclusive elements
4979
+ * console.log([...a.difference(b)]); // [1, 2];
4980
+ */
4981
+ difference(other: Iterable<K>): TreeSet<K>;
4982
+ /**
4983
+ * Return a new TreeSet containing elements in either set but not both.
4984
+ * @remarks Time O(n+m).
4985
+ * @param other - Any iterable of keys.
4986
+ * @returns A new TreeSet.
4987
+ * @example
4988
+ * // Find symmetric difference
4989
+ * console.log([...a.symmetricDifference(b)]); // [1, 2, 6, 7];
4990
+ */
4991
+ symmetricDifference(other: Iterable<K>): TreeSet<K>;
4992
+ /**
4993
+ * Check whether every element in this set is also in the other.
4994
+ * @remarks Time O(n).
4995
+ * @param other - Any iterable of keys (converted to Set for fast lookup if not a TreeSet).
4996
+ * @returns `true` if this is a subset of other.
4997
+ * @example
4998
+ * // Check subset
4999
+ * console.log(new TreeSet([3, 4]).isSubsetOf(a)); // true;
5000
+ */
5001
+ isSubsetOf(other: Iterable<K>): boolean;
5002
+ /**
5003
+ * Check whether every element in the other set is also in this set.
5004
+ * @remarks Time O(m).
5005
+ * @param other - Any iterable of keys.
5006
+ * @returns `true` if this is a superset of other.
5007
+ * @example
5008
+ * // Check superset
5009
+ * console.log(a.isSupersetOf(new TreeSet([2, 3]))); // true;
5010
+ */
5011
+ isSupersetOf(other: Iterable<K>): boolean;
5012
+ /**
5013
+ * Check whether this set and the other share no common elements.
5014
+ * @remarks Time O(min(n,m)), can short-circuit on first overlap.
5015
+ * @param other - Any iterable of keys (converted to Set for fast lookup if not a TreeSet).
5016
+ * @returns `true` if sets are disjoint.
5017
+ * @example
5018
+ * // Check disjoint
5019
+ * console.log(a.isDisjointFrom(new TreeSet([8, 9]))); // true;
5020
+ */
5021
+ isDisjointFrom(other: Iterable<K>): boolean;
5022
+ /**
5023
+ * Deep copy
5024
+
5025
+
5026
+
5027
+
5028
+
5029
+
5030
+
5031
+
5032
+
5033
+ * @example
5034
+ * // Deep clone
5035
+ * const ts = new TreeSet<number>([1, 2, 3]);
5036
+ * const copy = ts.clone();
5037
+ * copy.delete(1);
5038
+ * console.log(ts.has(1)); // true;
5039
+ */
4602
5040
  clone(): TreeSet<K>;
4603
5041
  }
@@ -189,6 +189,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
189
189
 
190
190
 
191
191
 
192
+
193
+
194
+
192
195
 
193
196
 
194
197
 
@@ -252,6 +255,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
252
255
 
253
256
 
254
257
 
258
+
259
+
260
+
255
261
 
256
262
 
257
263
 
@@ -317,6 +323,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
317
323
 
318
324
 
319
325
 
326
+
327
+
328
+
320
329
 
321
330
 
322
331
 
@@ -370,6 +379,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
370
379
 
371
380
 
372
381
 
382
+
383
+
384
+
373
385
 
374
386
 
375
387
 
@@ -422,6 +434,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
422
434
 
423
435
 
424
436
 
437
+
438
+
439
+
425
440
 
426
441
 
427
442
 
@@ -502,6 +517,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
502
517
 
503
518
 
504
519
 
520
+
521
+
522
+
505
523
 
506
524
 
507
525
 
@@ -564,6 +582,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
564
582
 
565
583
 
566
584
 
585
+
586
+
587
+
567
588
 
568
589
 
569
590
 
@@ -612,6 +633,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
612
633
 
613
634
 
614
635
 
636
+
637
+
638
+
615
639
 
616
640
 
617
641
 
@@ -687,6 +711,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
687
711
 
688
712
 
689
713
 
714
+
715
+
716
+
690
717
 
691
718
 
692
719
 
@@ -758,6 +785,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
758
785
 
759
786
 
760
787
 
788
+
789
+
790
+
761
791
 
762
792
 
763
793