directed-graph-typed 2.5.1 → 2.5.2

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 (73) hide show
  1. package/dist/cjs/index.cjs +121 -6
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +121 -6
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +121 -7
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +121 -7
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/common/error.d.ts +9 -0
  10. package/dist/types/common/index.d.ts +1 -1
  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 +77 -2
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +171 -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 +409 -0
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +411 -6
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +339 -6
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +391 -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 +51 -0
  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 +45 -0
  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/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  34. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  35. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  36. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  37. package/dist/umd/directed-graph-typed.js +121 -7
  38. package/dist/umd/directed-graph-typed.js.map +1 -1
  39. package/dist/umd/directed-graph-typed.min.js +2 -2
  40. package/dist/umd/directed-graph-typed.min.js.map +1 -1
  41. package/package.json +2 -2
  42. package/src/common/error.ts +19 -1
  43. package/src/common/index.ts +1 -1
  44. package/src/data-structures/base/iterable-element-base.ts +3 -2
  45. package/src/data-structures/binary-tree/avl-tree.ts +47 -0
  46. package/src/data-structures/binary-tree/binary-indexed-tree.ts +46 -4
  47. package/src/data-structures/binary-tree/binary-tree.ts +79 -4
  48. package/src/data-structures/binary-tree/bst.ts +441 -6
  49. package/src/data-structures/binary-tree/red-black-tree.ts +73 -0
  50. package/src/data-structures/binary-tree/segment-tree.ts +18 -0
  51. package/src/data-structures/binary-tree/tree-map.ts +434 -9
  52. package/src/data-structures/binary-tree/tree-multi-map.ts +426 -5
  53. package/src/data-structures/binary-tree/tree-multi-set.ts +350 -6
  54. package/src/data-structures/binary-tree/tree-set.ts +410 -8
  55. package/src/data-structures/graph/abstract-graph.ts +2 -2
  56. package/src/data-structures/graph/directed-graph.ts +30 -0
  57. package/src/data-structures/graph/undirected-graph.ts +27 -0
  58. package/src/data-structures/hash/hash-map.ts +35 -4
  59. package/src/data-structures/heap/heap.ts +46 -4
  60. package/src/data-structures/heap/max-heap.ts +2 -2
  61. package/src/data-structures/linked-list/doubly-linked-list.ts +51 -0
  62. package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
  63. package/src/data-structures/linked-list/skip-linked-list.ts +59 -5
  64. package/src/data-structures/matrix/matrix.ts +33 -9
  65. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  66. package/src/data-structures/queue/deque.ts +45 -0
  67. package/src/data-structures/queue/queue.ts +36 -0
  68. package/src/data-structures/stack/stack.ts +30 -0
  69. package/src/data-structures/trie/trie.ts +38 -2
  70. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  71. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  72. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  73. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
@@ -23,6 +23,10 @@ var arrayRemove = /* @__PURE__ */ __name(function(array, predicate) {
23
23
  }, "arrayRemove");
24
24
 
25
25
  // src/common/error.ts
26
+ function raise(ErrorClass, message) {
27
+ throw new ErrorClass(message);
28
+ }
29
+ __name(raise, "raise");
26
30
  var ERR = {
27
31
  // Range / index
28
32
  indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
@@ -44,7 +48,9 @@ var ERR = {
44
48
  matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
45
49
  matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
46
50
  matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
47
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
51
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
52
+ // Order statistic
53
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
48
54
  };
49
55
 
50
56
  // src/common/index.ts
@@ -271,7 +277,7 @@ var IterableElementBase = class {
271
277
  if (options) {
272
278
  const { toElementFn } = options;
273
279
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
274
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
280
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
275
281
  }
276
282
  }
277
283
  /**
@@ -434,7 +440,7 @@ var IterableElementBase = class {
434
440
  acc = initialValue;
435
441
  } else {
436
442
  const first = iter.next();
437
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
443
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
438
444
  acc = first.value;
439
445
  index = 1;
440
446
  }
@@ -731,6 +737,9 @@ var Heap = class _Heap extends IterableElementBase {
731
737
 
732
738
 
733
739
 
740
+
741
+
742
+
734
743
 
735
744
 
736
745
 
@@ -814,6 +823,9 @@ var Heap = class _Heap extends IterableElementBase {
814
823
 
815
824
 
816
825
 
826
+
827
+
828
+
817
829
 
818
830
 
819
831
 
@@ -868,6 +880,9 @@ var Heap = class _Heap extends IterableElementBase {
868
880
 
869
881
 
870
882
 
883
+
884
+
885
+
871
886
 
872
887
 
873
888
 
@@ -924,6 +939,9 @@ var Heap = class _Heap extends IterableElementBase {
924
939
 
925
940
 
926
941
 
942
+
943
+
944
+
927
945
 
928
946
 
929
947
 
@@ -996,6 +1014,9 @@ var Heap = class _Heap extends IterableElementBase {
996
1014
 
997
1015
 
998
1016
 
1017
+
1018
+
1019
+
999
1020
 
1000
1021
 
1001
1022
 
@@ -1093,6 +1114,9 @@ var Heap = class _Heap extends IterableElementBase {
1093
1114
 
1094
1115
 
1095
1116
 
1117
+
1118
+
1119
+
1096
1120
 
1097
1121
 
1098
1122
 
@@ -1137,6 +1161,9 @@ var Heap = class _Heap extends IterableElementBase {
1137
1161
 
1138
1162
 
1139
1163
 
1164
+
1165
+
1166
+
1140
1167
 
1141
1168
 
1142
1169
 
@@ -1184,6 +1211,9 @@ var Heap = class _Heap extends IterableElementBase {
1184
1211
 
1185
1212
 
1186
1213
 
1214
+
1215
+
1216
+
1187
1217
 
1188
1218
 
1189
1219
 
@@ -1228,6 +1258,9 @@ var Heap = class _Heap extends IterableElementBase {
1228
1258
 
1229
1259
 
1230
1260
 
1261
+
1262
+
1263
+
1231
1264
 
1232
1265
 
1233
1266
 
@@ -1318,6 +1351,9 @@ var Heap = class _Heap extends IterableElementBase {
1318
1351
 
1319
1352
 
1320
1353
 
1354
+
1355
+
1356
+
1321
1357
 
1322
1358
 
1323
1359
 
@@ -1395,6 +1431,9 @@ var Heap = class _Heap extends IterableElementBase {
1395
1431
 
1396
1432
 
1397
1433
 
1434
+
1435
+
1436
+
1398
1437
 
1399
1438
 
1400
1439
 
@@ -1445,6 +1484,9 @@ var Heap = class _Heap extends IterableElementBase {
1445
1484
 
1446
1485
 
1447
1486
 
1487
+
1488
+
1489
+
1448
1490
 
1449
1491
 
1450
1492
 
@@ -1494,6 +1536,9 @@ var Heap = class _Heap extends IterableElementBase {
1494
1536
 
1495
1537
 
1496
1538
 
1539
+
1540
+
1541
+
1497
1542
 
1498
1543
 
1499
1544
 
@@ -1550,6 +1595,9 @@ var Heap = class _Heap extends IterableElementBase {
1550
1595
 
1551
1596
 
1552
1597
 
1598
+
1599
+
1600
+
1553
1601
 
1554
1602
 
1555
1603
 
@@ -1562,7 +1610,7 @@ var Heap = class _Heap extends IterableElementBase {
1562
1610
  */
1563
1611
  map(callback, options, thisArg) {
1564
1612
  const { comparator, toElementFn, ...rest } = options ?? {};
1565
- if (!comparator) throw new TypeError(ERR.comparatorRequired("Heap.map"));
1613
+ if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
1566
1614
  const out = this._createLike([], { ...rest, comparator, toElementFn });
1567
1615
  let i = 0;
1568
1616
  for (const x of this) {
@@ -1589,7 +1637,7 @@ var Heap = class _Heap extends IterableElementBase {
1589
1637
  }
1590
1638
  _DEFAULT_COMPARATOR = /* @__PURE__ */ __name((a, b) => {
1591
1639
  if (typeof a === "object" || typeof b === "object") {
1592
- throw new TypeError(ERR.comparatorRequired("Heap"));
1640
+ raise(TypeError, ERR.comparatorRequired("Heap"));
1593
1641
  }
1594
1642
  if (a > b) return 1;
1595
1643
  if (a < b) return -1;
@@ -1760,6 +1808,9 @@ var Queue = class _Queue extends LinearBase {
1760
1808
 
1761
1809
 
1762
1810
 
1811
+
1812
+
1813
+
1763
1814
 
1764
1815
 
1765
1816
 
@@ -1807,6 +1858,9 @@ var Queue = class _Queue extends LinearBase {
1807
1858
 
1808
1859
 
1809
1860
 
1861
+
1862
+
1863
+
1810
1864
 
1811
1865
 
1812
1866
 
@@ -1870,6 +1924,9 @@ var Queue = class _Queue extends LinearBase {
1870
1924
 
1871
1925
 
1872
1926
 
1927
+
1928
+
1929
+
1873
1930
 
1874
1931
 
1875
1932
 
@@ -1929,6 +1986,9 @@ var Queue = class _Queue extends LinearBase {
1929
1986
 
1930
1987
 
1931
1988
 
1989
+
1990
+
1991
+
1932
1992
 
1933
1993
 
1934
1994
 
@@ -1995,6 +2055,9 @@ var Queue = class _Queue extends LinearBase {
1995
2055
 
1996
2056
 
1997
2057
 
2058
+
2059
+
2060
+
1998
2061
 
1999
2062
 
2000
2063
 
@@ -2051,6 +2114,9 @@ var Queue = class _Queue extends LinearBase {
2051
2114
 
2052
2115
 
2053
2116
 
2117
+
2118
+
2119
+
2054
2120
 
2055
2121
 
2056
2122
 
@@ -2100,6 +2166,9 @@ var Queue = class _Queue extends LinearBase {
2100
2166
 
2101
2167
 
2102
2168
 
2169
+
2170
+
2171
+
2103
2172
 
2104
2173
 
2105
2174
 
@@ -2190,6 +2259,9 @@ var Queue = class _Queue extends LinearBase {
2190
2259
 
2191
2260
 
2192
2261
 
2262
+
2263
+
2264
+
2193
2265
 
2194
2266
 
2195
2267
 
@@ -2233,6 +2305,9 @@ var Queue = class _Queue extends LinearBase {
2233
2305
 
2234
2306
 
2235
2307
 
2308
+
2309
+
2310
+
2236
2311
 
2237
2312
 
2238
2313
 
@@ -2299,6 +2374,9 @@ var Queue = class _Queue extends LinearBase {
2299
2374
 
2300
2375
 
2301
2376
 
2377
+
2378
+
2379
+
2302
2380
 
2303
2381
 
2304
2382
 
@@ -2349,6 +2427,9 @@ var Queue = class _Queue extends LinearBase {
2349
2427
 
2350
2428
 
2351
2429
 
2430
+
2431
+
2432
+
2352
2433
 
2353
2434
 
2354
2435
 
@@ -2403,6 +2484,9 @@ var Queue = class _Queue extends LinearBase {
2403
2484
 
2404
2485
 
2405
2486
 
2487
+
2488
+
2489
+
2406
2490
 
2407
2491
 
2408
2492
 
@@ -2642,7 +2726,7 @@ var AbstractGraph = class extends IterableEntryBase {
2642
2726
  const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
2643
2727
  return this._addEdge(newEdge);
2644
2728
  } else {
2645
- throw new TypeError(ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
2729
+ raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
2646
2730
  }
2647
2731
  }
2648
2732
  }
@@ -3539,6 +3623,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
3539
3623
 
3540
3624
 
3541
3625
 
3626
+
3627
+
3628
+
3542
3629
 
3543
3630
 
3544
3631
 
@@ -3624,6 +3711,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
3624
3711
 
3625
3712
 
3626
3713
 
3714
+
3715
+
3716
+
3627
3717
 
3628
3718
 
3629
3719
 
@@ -3707,6 +3797,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
3707
3797
 
3708
3798
 
3709
3799
 
3800
+
3801
+
3802
+
3710
3803
 
3711
3804
 
3712
3805
 
@@ -3781,6 +3874,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
3781
3874
 
3782
3875
 
3783
3876
 
3877
+
3878
+
3879
+
3784
3880
 
3785
3881
 
3786
3882
 
@@ -3832,6 +3928,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
3832
3928
 
3833
3929
 
3834
3930
 
3931
+
3932
+
3933
+
3835
3934
 
3836
3935
 
3837
3936
 
@@ -3936,6 +4035,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
3936
4035
 
3937
4036
 
3938
4037
 
4038
+
4039
+
4040
+
3939
4041
 
3940
4042
 
3941
4043
 
@@ -4021,6 +4123,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4021
4123
 
4022
4124
 
4023
4125
 
4126
+
4127
+
4128
+
4024
4129
 
4025
4130
 
4026
4131
 
@@ -4068,6 +4173,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4068
4173
 
4069
4174
 
4070
4175
 
4176
+
4177
+
4178
+
4071
4179
 
4072
4180
 
4073
4181
 
@@ -4168,6 +4276,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4168
4276
 
4169
4277
 
4170
4278
 
4279
+
4280
+
4281
+
4171
4282
 
4172
4283
 
4173
4284
 
@@ -4271,6 +4382,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4271
4382
 
4272
4383
 
4273
4384
 
4385
+
4386
+
4387
+
4274
4388
 
4275
4389
 
4276
4390
 
@@ -4329,6 +4443,6 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
4329
4443
  * @license MIT License
4330
4444
  */
4331
4445
 
4332
- export { AbstractEdge, AbstractGraph, AbstractVertex, DFSOperation, DirectedEdge, DirectedGraph, DirectedVertex, ERR, Range };
4446
+ export { AbstractEdge, AbstractGraph, AbstractVertex, DFSOperation, DirectedEdge, DirectedGraph, DirectedVertex, ERR, Range, raise };
4333
4447
  //# sourceMappingURL=index.mjs.map
4334
4448
  //# sourceMappingURL=index.mjs.map