avl-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 +195 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +195 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +195 -0
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +195 -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/avl-tree-typed.js +195 -0
  34. package/dist/umd/avl-tree-typed.js.map +1 -1
  35. package/dist/umd/avl-tree-typed.min.js +2 -2
  36. package/dist/umd/avl-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
@@ -261,6 +261,35 @@ var IterableElementBase = class {
261
261
  for (const ele of this) if (ele === element) return true;
262
262
  return false;
263
263
  }
264
+ /**
265
+ * Check whether a value exists (Array-compatible alias for `has`).
266
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
267
+ * @param element - Element to search for (uses `===`).
268
+ * @returns `true` if found.
269
+ */
270
+ includes(element) {
271
+ return this.has(element);
272
+ }
273
+ /**
274
+ * Return an iterator of `[index, value]` pairs (Array-compatible).
275
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
276
+ */
277
+ *entries() {
278
+ let index = 0;
279
+ for (const value of this) {
280
+ yield [index++, value];
281
+ }
282
+ }
283
+ /**
284
+ * Return an iterator of numeric indices (Array-compatible).
285
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
286
+ */
287
+ *keys() {
288
+ let index = 0;
289
+ for (const _ of this) {
290
+ yield index++;
291
+ }
292
+ }
264
293
  /**
265
294
  * Reduces all elements to a single accumulated value.
266
295
  *
@@ -523,6 +552,16 @@ var LinearBase = class _LinearBase extends IterableElementBase {
523
552
  }
524
553
  return this;
525
554
  }
555
+ /**
556
+ * Return a new instance of the same type with elements in reverse order (non-mutating).
557
+ * @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
558
+ * @returns A new reversed instance.
559
+ */
560
+ toReversed() {
561
+ const cloned = this.clone();
562
+ cloned.reverse();
563
+ return cloned;
564
+ }
526
565
  };
527
566
 
528
567
  // src/data-structures/base/iterable-entry-base.ts
@@ -802,6 +841,9 @@ var Queue = class _Queue extends LinearBase {
802
841
 
803
842
 
804
843
 
844
+
845
+
846
+
805
847
 
806
848
 
807
849
 
@@ -856,6 +898,9 @@ var Queue = class _Queue extends LinearBase {
856
898
 
857
899
 
858
900
 
901
+
902
+
903
+
859
904
 
860
905
 
861
906
 
@@ -934,6 +979,9 @@ var Queue = class _Queue extends LinearBase {
934
979
 
935
980
 
936
981
 
982
+
983
+
984
+
937
985
 
938
986
 
939
987
 
@@ -1000,6 +1048,9 @@ var Queue = class _Queue extends LinearBase {
1000
1048
 
1001
1049
 
1002
1050
 
1051
+
1052
+
1053
+
1003
1054
 
1004
1055
 
1005
1056
 
@@ -1073,6 +1124,9 @@ var Queue = class _Queue extends LinearBase {
1073
1124
 
1074
1125
 
1075
1126
 
1127
+
1128
+
1129
+
1076
1130
 
1077
1131
 
1078
1132
 
@@ -1136,6 +1190,9 @@ var Queue = class _Queue extends LinearBase {
1136
1190
 
1137
1191
 
1138
1192
 
1193
+
1194
+
1195
+
1139
1196
 
1140
1197
 
1141
1198
 
@@ -1192,6 +1249,9 @@ var Queue = class _Queue extends LinearBase {
1192
1249
 
1193
1250
 
1194
1251
 
1252
+
1253
+
1254
+
1195
1255
 
1196
1256
 
1197
1257
 
@@ -1304,6 +1364,9 @@ var Queue = class _Queue extends LinearBase {
1304
1364
 
1305
1365
 
1306
1366
 
1367
+
1368
+
1369
+
1307
1370
 
1308
1371
 
1309
1372
 
@@ -1354,6 +1417,9 @@ var Queue = class _Queue extends LinearBase {
1354
1417
 
1355
1418
 
1356
1419
 
1420
+
1421
+
1422
+
1357
1423
 
1358
1424
 
1359
1425
 
@@ -1427,6 +1493,9 @@ var Queue = class _Queue extends LinearBase {
1427
1493
 
1428
1494
 
1429
1495
 
1496
+
1497
+
1498
+
1430
1499
 
1431
1500
 
1432
1501
 
@@ -1484,6 +1553,9 @@ var Queue = class _Queue extends LinearBase {
1484
1553
 
1485
1554
 
1486
1555
 
1556
+
1557
+
1558
+
1487
1559
 
1488
1560
 
1489
1561
 
@@ -1545,6 +1617,9 @@ var Queue = class _Queue extends LinearBase {
1545
1617
 
1546
1618
 
1547
1619
 
1620
+
1621
+
1622
+
1548
1623
 
1549
1624
 
1550
1625
 
@@ -2049,6 +2124,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2049
2124
 
2050
2125
 
2051
2126
 
2127
+
2128
+
2129
+
2052
2130
 
2053
2131
 
2054
2132
 
@@ -2107,6 +2185,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2107
2185
 
2108
2186
 
2109
2187
 
2188
+
2189
+
2190
+
2110
2191
 
2111
2192
 
2112
2193
 
@@ -2217,6 +2298,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2217
2298
 
2218
2299
 
2219
2300
 
2301
+
2302
+
2303
+
2220
2304
 
2221
2305
 
2222
2306
 
@@ -2263,6 +2347,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2263
2347
 
2264
2348
 
2265
2349
 
2350
+
2351
+
2352
+
2266
2353
 
2267
2354
 
2268
2355
 
@@ -2330,6 +2417,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2330
2417
 
2331
2418
 
2332
2419
 
2420
+
2421
+
2422
+
2333
2423
 
2334
2424
 
2335
2425
 
@@ -2436,6 +2526,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2436
2526
 
2437
2527
 
2438
2528
 
2529
+
2530
+
2531
+
2439
2532
 
2440
2533
 
2441
2534
 
@@ -2540,6 +2633,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2540
2633
 
2541
2634
 
2542
2635
 
2636
+
2637
+
2638
+
2543
2639
 
2544
2640
 
2545
2641
 
@@ -2602,6 +2698,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2602
2698
 
2603
2699
 
2604
2700
 
2701
+
2702
+
2703
+
2605
2704
 
2606
2705
 
2607
2706
 
@@ -2666,6 +2765,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2666
2765
 
2667
2766
 
2668
2767
 
2768
+
2769
+
2770
+
2669
2771
 
2670
2772
 
2671
2773
 
@@ -2718,6 +2820,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2718
2820
 
2719
2821
 
2720
2822
 
2823
+
2824
+
2825
+
2721
2826
 
2722
2827
 
2723
2828
 
@@ -2779,6 +2884,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2779
2884
 
2780
2885
 
2781
2886
 
2887
+
2888
+
2889
+
2782
2890
 
2783
2891
 
2784
2892
 
@@ -2867,6 +2975,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2867
2975
 
2868
2976
 
2869
2977
 
2978
+
2979
+
2980
+
2870
2981
 
2871
2982
 
2872
2983
 
@@ -2932,6 +3043,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
2932
3043
 
2933
3044
 
2934
3045
 
3046
+
3047
+
3048
+
2935
3049
 
2936
3050
 
2937
3051
 
@@ -3413,6 +3527,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
3413
3527
 
3414
3528
 
3415
3529
 
3530
+
3531
+
3532
+
3416
3533
 
3417
3534
 
3418
3535
 
@@ -3469,6 +3586,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
3469
3586
 
3470
3587
 
3471
3588
 
3589
+
3590
+
3591
+
3472
3592
 
3473
3593
 
3474
3594
 
@@ -3529,6 +3649,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
3529
3649
 
3530
3650
 
3531
3651
 
3652
+
3653
+
3654
+
3532
3655
 
3533
3656
 
3534
3657
 
@@ -3614,6 +3737,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
3614
3737
 
3615
3738
 
3616
3739
 
3740
+
3741
+
3742
+
3617
3743
 
3618
3744
 
3619
3745
 
@@ -4442,6 +4568,12 @@ var BST = class extends BinaryTree {
4442
4568
 
4443
4569
 
4444
4570
 
4571
+
4572
+
4573
+
4574
+
4575
+
4576
+
4445
4577
 
4446
4578
 
4447
4579
 
@@ -4787,6 +4919,15 @@ var BST = class extends BinaryTree {
4787
4919
 
4788
4920
 
4789
4921
 
4922
+
4923
+
4924
+
4925
+
4926
+
4927
+
4928
+
4929
+
4930
+
4790
4931
 
4791
4932
 
4792
4933
 
@@ -4913,6 +5054,12 @@ var BST = class extends BinaryTree {
4913
5054
 
4914
5055
 
4915
5056
 
5057
+
5058
+
5059
+
5060
+
5061
+
5062
+
4916
5063
 
4917
5064
 
4918
5065
 
@@ -5207,6 +5354,9 @@ var BST = class extends BinaryTree {
5207
5354
 
5208
5355
 
5209
5356
 
5357
+
5358
+
5359
+
5210
5360
 
5211
5361
 
5212
5362
 
@@ -5280,6 +5430,9 @@ var BST = class extends BinaryTree {
5280
5430
 
5281
5431
 
5282
5432
 
5433
+
5434
+
5435
+
5283
5436
 
5284
5437
 
5285
5438
 
@@ -5407,6 +5560,12 @@ var BST = class extends BinaryTree {
5407
5560
 
5408
5561
 
5409
5562
 
5563
+
5564
+
5565
+
5566
+
5567
+
5568
+
5410
5569
 
5411
5570
 
5412
5571
 
@@ -6322,6 +6481,18 @@ var AVLTree = class extends BST {
6322
6481
 
6323
6482
 
6324
6483
 
6484
+
6485
+
6486
+
6487
+
6488
+
6489
+
6490
+
6491
+
6492
+
6493
+
6494
+
6495
+
6325
6496
 
6326
6497
 
6327
6498
 
@@ -6461,6 +6632,15 @@ var AVLTree = class extends BST {
6461
6632
 
6462
6633
 
6463
6634
 
6635
+
6636
+
6637
+
6638
+
6639
+
6640
+
6641
+
6642
+
6643
+
6464
6644
 
6465
6645
 
6466
6646
 
@@ -6555,6 +6735,12 @@ var AVLTree = class extends BST {
6555
6735
 
6556
6736
 
6557
6737
 
6738
+
6739
+
6740
+
6741
+
6742
+
6743
+
6558
6744
 
6559
6745
 
6560
6746
 
@@ -6700,6 +6886,15 @@ var AVLTree = class extends BST {
6700
6886
 
6701
6887
 
6702
6888
 
6889
+
6890
+
6891
+
6892
+
6893
+
6894
+
6895
+
6896
+
6897
+
6703
6898
 
6704
6899
 
6705
6900