directed-graph-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 +147 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +147 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +147 -0
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +147 -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/directed-graph-typed.js +147 -0
  34. package/dist/umd/directed-graph-typed.js.map +1 -1
  35. package/dist/umd/directed-graph-typed.min.js +1 -1
  36. package/dist/umd/directed-graph-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
@@ -411,6 +411,35 @@ var IterableElementBase = class {
411
411
  for (const ele of this) if (ele === element) return true;
412
412
  return false;
413
413
  }
414
+ /**
415
+ * Check whether a value exists (Array-compatible alias for `has`).
416
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
417
+ * @param element - Element to search for (uses `===`).
418
+ * @returns `true` if found.
419
+ */
420
+ includes(element) {
421
+ return this.has(element);
422
+ }
423
+ /**
424
+ * Return an iterator of `[index, value]` pairs (Array-compatible).
425
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
426
+ */
427
+ *entries() {
428
+ let index = 0;
429
+ for (const value of this) {
430
+ yield [index++, value];
431
+ }
432
+ }
433
+ /**
434
+ * Return an iterator of numeric indices (Array-compatible).
435
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
436
+ */
437
+ *keys() {
438
+ let index = 0;
439
+ for (const _ of this) {
440
+ yield index++;
441
+ }
442
+ }
414
443
  /**
415
444
  * Reduces all elements to a single accumulated value.
416
445
  *
@@ -673,6 +702,16 @@ var LinearBase = class _LinearBase extends IterableElementBase {
673
702
  }
674
703
  return this;
675
704
  }
705
+ /**
706
+ * Return a new instance of the same type with elements in reverse order (non-mutating).
707
+ * @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
708
+ * @returns A new reversed instance.
709
+ */
710
+ toReversed() {
711
+ const cloned = this.clone();
712
+ cloned.reverse();
713
+ return cloned;
714
+ }
676
715
  };
677
716
 
678
717
  // src/data-structures/heap/heap.ts
@@ -744,6 +783,9 @@ var Heap = class _Heap extends IterableElementBase {
744
783
 
745
784
 
746
785
 
786
+
787
+
788
+
747
789
 
748
790
 
749
791
 
@@ -834,6 +876,9 @@ var Heap = class _Heap extends IterableElementBase {
834
876
 
835
877
 
836
878
 
879
+
880
+
881
+
837
882
 
838
883
 
839
884
 
@@ -895,6 +940,9 @@ var Heap = class _Heap extends IterableElementBase {
895
940
 
896
941
 
897
942
 
943
+
944
+
945
+
898
946
 
899
947
 
900
948
 
@@ -989,6 +1037,9 @@ var Heap = class _Heap extends IterableElementBase {
989
1037
  */
990
1038
  /**
991
1039
  * @deprecated Use `pop` instead. Will be removed in a future major version.
1040
+
1041
+
1042
+
992
1043
  * @example
993
1044
  * // Heap with custom comparator (MaxHeap behavior)
994
1045
  * interface Task {
@@ -1072,6 +1123,9 @@ var Heap = class _Heap extends IterableElementBase {
1072
1123
 
1073
1124
 
1074
1125
 
1126
+
1127
+
1128
+
1075
1129
 
1076
1130
 
1077
1131
 
@@ -1176,6 +1230,9 @@ var Heap = class _Heap extends IterableElementBase {
1176
1230
 
1177
1231
 
1178
1232
 
1233
+
1234
+
1235
+
1179
1236
 
1180
1237
 
1181
1238
 
@@ -1227,6 +1284,9 @@ var Heap = class _Heap extends IterableElementBase {
1227
1284
 
1228
1285
 
1229
1286
 
1287
+
1288
+
1289
+
1230
1290
 
1231
1291
 
1232
1292
 
@@ -1271,6 +1331,9 @@ var Heap = class _Heap extends IterableElementBase {
1271
1331
 
1272
1332
 
1273
1333
 
1334
+
1335
+
1336
+
1274
1337
 
1275
1338
 
1276
1339
 
@@ -1322,6 +1385,9 @@ var Heap = class _Heap extends IterableElementBase {
1322
1385
 
1323
1386
 
1324
1387
 
1388
+
1389
+
1390
+
1325
1391
 
1326
1392
 
1327
1393
 
@@ -1425,6 +1491,9 @@ var Heap = class _Heap extends IterableElementBase {
1425
1491
 
1426
1492
 
1427
1493
 
1494
+
1495
+
1496
+
1428
1497
 
1429
1498
 
1430
1499
 
@@ -1509,6 +1578,9 @@ var Heap = class _Heap extends IterableElementBase {
1509
1578
 
1510
1579
 
1511
1580
 
1581
+
1582
+
1583
+
1512
1584
 
1513
1585
 
1514
1586
 
@@ -1566,6 +1638,9 @@ var Heap = class _Heap extends IterableElementBase {
1566
1638
 
1567
1639
 
1568
1640
 
1641
+
1642
+
1643
+
1569
1644
 
1570
1645
 
1571
1646
 
@@ -1622,6 +1697,9 @@ var Heap = class _Heap extends IterableElementBase {
1622
1697
 
1623
1698
 
1624
1699
 
1700
+
1701
+
1702
+
1625
1703
 
1626
1704
 
1627
1705
 
@@ -1685,6 +1763,9 @@ var Heap = class _Heap extends IterableElementBase {
1685
1763
 
1686
1764
 
1687
1765
 
1766
+
1767
+
1768
+
1688
1769
 
1689
1770
 
1690
1771
 
@@ -1902,6 +1983,9 @@ var Queue = class _Queue extends LinearBase {
1902
1983
 
1903
1984
 
1904
1985
 
1986
+
1987
+
1988
+
1905
1989
 
1906
1990
 
1907
1991
 
@@ -1956,6 +2040,9 @@ var Queue = class _Queue extends LinearBase {
1956
2040
 
1957
2041
 
1958
2042
 
2043
+
2044
+
2045
+
1959
2046
 
1960
2047
 
1961
2048
 
@@ -2034,6 +2121,9 @@ var Queue = class _Queue extends LinearBase {
2034
2121
 
2035
2122
 
2036
2123
 
2124
+
2125
+
2126
+
2037
2127
 
2038
2128
 
2039
2129
 
@@ -2100,6 +2190,9 @@ var Queue = class _Queue extends LinearBase {
2100
2190
 
2101
2191
 
2102
2192
 
2193
+
2194
+
2195
+
2103
2196
 
2104
2197
 
2105
2198
 
@@ -2173,6 +2266,9 @@ var Queue = class _Queue extends LinearBase {
2173
2266
 
2174
2267
 
2175
2268
 
2269
+
2270
+
2271
+
2176
2272
 
2177
2273
 
2178
2274
 
@@ -2236,6 +2332,9 @@ var Queue = class _Queue extends LinearBase {
2236
2332
 
2237
2333
 
2238
2334
 
2335
+
2336
+
2337
+
2239
2338
 
2240
2339
 
2241
2340
 
@@ -2292,6 +2391,9 @@ var Queue = class _Queue extends LinearBase {
2292
2391
 
2293
2392
 
2294
2393
 
2394
+
2395
+
2396
+
2295
2397
 
2296
2398
 
2297
2399
 
@@ -2404,6 +2506,9 @@ var Queue = class _Queue extends LinearBase {
2404
2506
 
2405
2507
 
2406
2508
 
2509
+
2510
+
2511
+
2407
2512
 
2408
2513
 
2409
2514
 
@@ -2454,6 +2559,9 @@ var Queue = class _Queue extends LinearBase {
2454
2559
 
2455
2560
 
2456
2561
 
2562
+
2563
+
2564
+
2457
2565
 
2458
2566
 
2459
2567
 
@@ -2527,6 +2635,9 @@ var Queue = class _Queue extends LinearBase {
2527
2635
 
2528
2636
 
2529
2637
 
2638
+
2639
+
2640
+
2530
2641
 
2531
2642
 
2532
2643
 
@@ -2584,6 +2695,9 @@ var Queue = class _Queue extends LinearBase {
2584
2695
 
2585
2696
 
2586
2697
 
2698
+
2699
+
2700
+
2587
2701
 
2588
2702
 
2589
2703
 
@@ -2645,6 +2759,9 @@ var Queue = class _Queue extends LinearBase {
2645
2759
 
2646
2760
 
2647
2761
 
2762
+
2763
+
2764
+
2648
2765
 
2649
2766
 
2650
2767
 
@@ -3788,6 +3905,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
3788
3905
 
3789
3906
 
3790
3907
 
3908
+
3909
+
3910
+
3791
3911
 
3792
3912
 
3793
3913
 
@@ -3880,6 +4000,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
3880
4000
 
3881
4001
 
3882
4002
 
4003
+
4004
+
4005
+
3883
4006
 
3884
4007
 
3885
4008
 
@@ -3970,6 +4093,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
3970
4093
 
3971
4094
 
3972
4095
 
4096
+
4097
+
4098
+
3973
4099
 
3974
4100
 
3975
4101
 
@@ -4051,6 +4177,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4051
4177
 
4052
4178
 
4053
4179
 
4180
+
4181
+
4182
+
4054
4183
 
4055
4184
 
4056
4185
 
@@ -4109,6 +4238,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4109
4238
 
4110
4239
 
4111
4240
 
4241
+
4242
+
4243
+
4112
4244
 
4113
4245
 
4114
4246
 
@@ -4220,6 +4352,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4220
4352
 
4221
4353
 
4222
4354
 
4355
+
4356
+
4357
+
4223
4358
 
4224
4359
 
4225
4360
 
@@ -4312,6 +4447,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4312
4447
 
4313
4448
 
4314
4449
 
4450
+
4451
+
4452
+
4315
4453
 
4316
4454
 
4317
4455
 
@@ -4366,6 +4504,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4366
4504
 
4367
4505
 
4368
4506
 
4507
+
4508
+
4509
+
4369
4510
 
4370
4511
 
4371
4512
 
@@ -4473,6 +4614,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4473
4614
 
4474
4615
 
4475
4616
 
4617
+
4618
+
4619
+
4476
4620
 
4477
4621
 
4478
4622
 
@@ -4583,6 +4727,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4583
4727
 
4584
4728
 
4585
4729
 
4730
+
4731
+
4732
+
4586
4733
 
4587
4734
 
4588
4735