undirected-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 +118 -6
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +118 -6
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +118 -7
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +118 -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/undirected-graph-typed.js +118 -7
  38. package/dist/umd/undirected-graph-typed.js.map +1 -1
  39. package/dist/umd/undirected-graph-typed.min.js +2 -2
  40. package/dist/umd/undirected-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
@@ -25,6 +25,10 @@ var arrayRemove = /* @__PURE__ */ __name(function(array, predicate) {
25
25
  }, "arrayRemove");
26
26
 
27
27
  // src/common/error.ts
28
+ function raise(ErrorClass, message) {
29
+ throw new ErrorClass(message);
30
+ }
31
+ __name(raise, "raise");
28
32
  var ERR = {
29
33
  // Range / index
30
34
  indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
@@ -46,7 +50,9 @@ var ERR = {
46
50
  matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
47
51
  matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
48
52
  matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
49
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
53
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
54
+ // Order statistic
55
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
50
56
  };
51
57
 
52
58
  // src/common/index.ts
@@ -275,7 +281,7 @@ var _IterableElementBase = class _IterableElementBase {
275
281
  if (options) {
276
282
  const { toElementFn } = options;
277
283
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
278
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
284
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
279
285
  }
280
286
  }
281
287
  /**
@@ -431,7 +437,7 @@ var _IterableElementBase = class _IterableElementBase {
431
437
  acc = initialValue;
432
438
  } else {
433
439
  const first = iter.next();
434
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
440
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
435
441
  acc = first.value;
436
442
  index = 1;
437
443
  }
@@ -682,7 +688,7 @@ var _Heap = class _Heap extends IterableElementBase {
682
688
  __publicField(this, "_elements", []);
683
689
  __publicField(this, "_DEFAULT_COMPARATOR", /* @__PURE__ */ __name((a, b) => {
684
690
  if (typeof a === "object" || typeof b === "object") {
685
- throw new TypeError(ERR.comparatorRequired("Heap"));
691
+ raise(TypeError, ERR.comparatorRequired("Heap"));
686
692
  }
687
693
  if (a > b) return 1;
688
694
  if (a < b) return -1;
@@ -735,6 +741,9 @@ var _Heap = class _Heap extends IterableElementBase {
735
741
 
736
742
 
737
743
 
744
+
745
+
746
+
738
747
 
739
748
 
740
749
 
@@ -819,6 +828,9 @@ var _Heap = class _Heap extends IterableElementBase {
819
828
 
820
829
 
821
830
 
831
+
832
+
833
+
822
834
 
823
835
 
824
836
 
@@ -873,6 +885,9 @@ var _Heap = class _Heap extends IterableElementBase {
873
885
 
874
886
 
875
887
 
888
+
889
+
890
+
876
891
 
877
892
 
878
893
 
@@ -929,6 +944,9 @@ var _Heap = class _Heap extends IterableElementBase {
929
944
 
930
945
 
931
946
 
947
+
948
+
949
+
932
950
 
933
951
 
934
952
 
@@ -1001,6 +1019,9 @@ var _Heap = class _Heap extends IterableElementBase {
1001
1019
 
1002
1020
 
1003
1021
 
1022
+
1023
+
1024
+
1004
1025
 
1005
1026
 
1006
1027
 
@@ -1098,6 +1119,9 @@ var _Heap = class _Heap extends IterableElementBase {
1098
1119
 
1099
1120
 
1100
1121
 
1122
+
1123
+
1124
+
1101
1125
 
1102
1126
 
1103
1127
 
@@ -1142,6 +1166,9 @@ var _Heap = class _Heap extends IterableElementBase {
1142
1166
 
1143
1167
 
1144
1168
 
1169
+
1170
+
1171
+
1145
1172
 
1146
1173
 
1147
1174
 
@@ -1189,6 +1216,9 @@ var _Heap = class _Heap extends IterableElementBase {
1189
1216
 
1190
1217
 
1191
1218
 
1219
+
1220
+
1221
+
1192
1222
 
1193
1223
 
1194
1224
 
@@ -1233,6 +1263,9 @@ var _Heap = class _Heap extends IterableElementBase {
1233
1263
 
1234
1264
 
1235
1265
 
1266
+
1267
+
1268
+
1236
1269
 
1237
1270
 
1238
1271
 
@@ -1323,6 +1356,9 @@ var _Heap = class _Heap extends IterableElementBase {
1323
1356
 
1324
1357
 
1325
1358
 
1359
+
1360
+
1361
+
1326
1362
 
1327
1363
 
1328
1364
 
@@ -1400,6 +1436,9 @@ var _Heap = class _Heap extends IterableElementBase {
1400
1436
 
1401
1437
 
1402
1438
 
1439
+
1440
+
1441
+
1403
1442
 
1404
1443
 
1405
1444
 
@@ -1450,6 +1489,9 @@ var _Heap = class _Heap extends IterableElementBase {
1450
1489
 
1451
1490
 
1452
1491
 
1492
+
1493
+
1494
+
1453
1495
 
1454
1496
 
1455
1497
 
@@ -1499,6 +1541,9 @@ var _Heap = class _Heap extends IterableElementBase {
1499
1541
 
1500
1542
 
1501
1543
 
1544
+
1545
+
1546
+
1502
1547
 
1503
1548
 
1504
1549
 
@@ -1555,6 +1600,9 @@ var _Heap = class _Heap extends IterableElementBase {
1555
1600
 
1556
1601
 
1557
1602
 
1603
+
1604
+
1605
+
1558
1606
 
1559
1607
 
1560
1608
 
@@ -1567,7 +1615,7 @@ var _Heap = class _Heap extends IterableElementBase {
1567
1615
  */
1568
1616
  map(callback, options, thisArg) {
1569
1617
  const { comparator, toElementFn, ...rest } = options != null ? options : {};
1570
- if (!comparator) throw new TypeError(ERR.comparatorRequired("Heap.map"));
1618
+ if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
1571
1619
  const out = this._createLike([], { ...rest, comparator, toElementFn });
1572
1620
  let i = 0;
1573
1621
  for (const x of this) {
@@ -1755,6 +1803,9 @@ var _Queue = class _Queue extends LinearBase {
1755
1803
 
1756
1804
 
1757
1805
 
1806
+
1807
+
1808
+
1758
1809
 
1759
1810
 
1760
1811
 
@@ -1802,6 +1853,9 @@ var _Queue = class _Queue extends LinearBase {
1802
1853
 
1803
1854
 
1804
1855
 
1856
+
1857
+
1858
+
1805
1859
 
1806
1860
 
1807
1861
 
@@ -1865,6 +1919,9 @@ var _Queue = class _Queue extends LinearBase {
1865
1919
 
1866
1920
 
1867
1921
 
1922
+
1923
+
1924
+
1868
1925
 
1869
1926
 
1870
1927
 
@@ -1924,6 +1981,9 @@ var _Queue = class _Queue extends LinearBase {
1924
1981
 
1925
1982
 
1926
1983
 
1984
+
1985
+
1986
+
1927
1987
 
1928
1988
 
1929
1989
 
@@ -1990,6 +2050,9 @@ var _Queue = class _Queue extends LinearBase {
1990
2050
 
1991
2051
 
1992
2052
 
2053
+
2054
+
2055
+
1993
2056
 
1994
2057
 
1995
2058
 
@@ -2046,6 +2109,9 @@ var _Queue = class _Queue extends LinearBase {
2046
2109
 
2047
2110
 
2048
2111
 
2112
+
2113
+
2114
+
2049
2115
 
2050
2116
 
2051
2117
 
@@ -2095,6 +2161,9 @@ var _Queue = class _Queue extends LinearBase {
2095
2161
 
2096
2162
 
2097
2163
 
2164
+
2165
+
2166
+
2098
2167
 
2099
2168
 
2100
2169
 
@@ -2185,6 +2254,9 @@ var _Queue = class _Queue extends LinearBase {
2185
2254
 
2186
2255
 
2187
2256
 
2257
+
2258
+
2259
+
2188
2260
 
2189
2261
 
2190
2262
 
@@ -2228,6 +2300,9 @@ var _Queue = class _Queue extends LinearBase {
2228
2300
 
2229
2301
 
2230
2302
 
2303
+
2304
+
2305
+
2231
2306
 
2232
2307
 
2233
2308
 
@@ -2294,6 +2369,9 @@ var _Queue = class _Queue extends LinearBase {
2294
2369
 
2295
2370
 
2296
2371
 
2372
+
2373
+
2374
+
2297
2375
 
2298
2376
 
2299
2377
 
@@ -2344,6 +2422,9 @@ var _Queue = class _Queue extends LinearBase {
2344
2422
 
2345
2423
 
2346
2424
 
2425
+
2426
+
2427
+
2347
2428
 
2348
2429
 
2349
2430
 
@@ -2398,6 +2479,9 @@ var _Queue = class _Queue extends LinearBase {
2398
2479
 
2399
2480
 
2400
2481
 
2482
+
2483
+
2484
+
2401
2485
 
2402
2486
 
2403
2487
 
@@ -2636,7 +2720,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
2636
2720
  const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
2637
2721
  return this._addEdge(newEdge);
2638
2722
  } else {
2639
- throw new TypeError(ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
2723
+ raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
2640
2724
  }
2641
2725
  }
2642
2726
  }
@@ -3526,6 +3610,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3526
3610
 
3527
3611
 
3528
3612
 
3613
+
3614
+
3615
+
3529
3616
 
3530
3617
 
3531
3618
 
@@ -3608,6 +3695,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3608
3695
 
3609
3696
 
3610
3697
 
3698
+
3699
+
3700
+
3611
3701
 
3612
3702
 
3613
3703
 
@@ -3689,6 +3779,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3689
3779
 
3690
3780
 
3691
3781
 
3782
+
3783
+
3784
+
3692
3785
 
3693
3786
 
3694
3787
 
@@ -3785,6 +3878,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3785
3878
 
3786
3879
 
3787
3880
 
3881
+
3882
+
3883
+
3788
3884
 
3789
3885
 
3790
3886
 
@@ -3836,6 +3932,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3836
3932
 
3837
3933
 
3838
3934
 
3935
+
3936
+
3937
+
3839
3938
 
3840
3939
 
3841
3940
 
@@ -3957,6 +4056,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3957
4056
 
3958
4057
 
3959
4058
 
4059
+
4060
+
4061
+
3960
4062
 
3961
4063
 
3962
4064
 
@@ -4100,6 +4202,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
4100
4202
 
4101
4203
 
4102
4204
 
4205
+
4206
+
4207
+
4103
4208
 
4104
4209
 
4105
4210
 
@@ -4165,6 +4270,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
4165
4270
 
4166
4271
 
4167
4272
 
4273
+
4274
+
4275
+
4168
4276
 
4169
4277
 
4170
4278
 
@@ -4212,6 +4320,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
4212
4320
 
4213
4321
 
4214
4322
 
4323
+
4324
+
4325
+
4215
4326
 
4216
4327
 
4217
4328
 
@@ -4279,6 +4390,6 @@ var UndirectedGraph = _UndirectedGraph;
4279
4390
  * @license MIT License
4280
4391
  */
4281
4392
 
4282
- export { DFSOperation, ERR, Range, UndirectedEdge, UndirectedGraph, UndirectedVertex };
4393
+ export { DFSOperation, ERR, Range, UndirectedEdge, UndirectedGraph, UndirectedVertex, raise };
4283
4394
  //# sourceMappingURL=index.mjs.map
4284
4395
  //# sourceMappingURL=index.mjs.map