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
@@ -27,6 +27,10 @@ var arrayRemove = /* @__PURE__ */ __name(function(array, predicate) {
27
27
  }, "arrayRemove");
28
28
 
29
29
  // src/common/error.ts
30
+ function raise(ErrorClass, message) {
31
+ throw new ErrorClass(message);
32
+ }
33
+ __name(raise, "raise");
30
34
  var ERR = {
31
35
  // Range / index
32
36
  indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
@@ -48,7 +52,9 @@ var ERR = {
48
52
  matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
49
53
  matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
50
54
  matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
51
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
55
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
56
+ // Order statistic
57
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
52
58
  };
53
59
 
54
60
  // src/common/index.ts
@@ -277,7 +283,7 @@ var _IterableElementBase = class _IterableElementBase {
277
283
  if (options) {
278
284
  const { toElementFn } = options;
279
285
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
280
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
286
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
281
287
  }
282
288
  }
283
289
  /**
@@ -433,7 +439,7 @@ var _IterableElementBase = class _IterableElementBase {
433
439
  acc = initialValue;
434
440
  } else {
435
441
  const first = iter.next();
436
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
442
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
437
443
  acc = first.value;
438
444
  index = 1;
439
445
  }
@@ -684,7 +690,7 @@ var _Heap = class _Heap extends IterableElementBase {
684
690
  __publicField(this, "_elements", []);
685
691
  __publicField(this, "_DEFAULT_COMPARATOR", /* @__PURE__ */ __name((a, b) => {
686
692
  if (typeof a === "object" || typeof b === "object") {
687
- throw new TypeError(ERR.comparatorRequired("Heap"));
693
+ raise(TypeError, ERR.comparatorRequired("Heap"));
688
694
  }
689
695
  if (a > b) return 1;
690
696
  if (a < b) return -1;
@@ -737,6 +743,9 @@ var _Heap = class _Heap extends IterableElementBase {
737
743
 
738
744
 
739
745
 
746
+
747
+
748
+
740
749
 
741
750
 
742
751
 
@@ -821,6 +830,9 @@ var _Heap = class _Heap extends IterableElementBase {
821
830
 
822
831
 
823
832
 
833
+
834
+
835
+
824
836
 
825
837
 
826
838
 
@@ -875,6 +887,9 @@ var _Heap = class _Heap extends IterableElementBase {
875
887
 
876
888
 
877
889
 
890
+
891
+
892
+
878
893
 
879
894
 
880
895
 
@@ -931,6 +946,9 @@ var _Heap = class _Heap extends IterableElementBase {
931
946
 
932
947
 
933
948
 
949
+
950
+
951
+
934
952
 
935
953
 
936
954
 
@@ -1003,6 +1021,9 @@ var _Heap = class _Heap extends IterableElementBase {
1003
1021
 
1004
1022
 
1005
1023
 
1024
+
1025
+
1026
+
1006
1027
 
1007
1028
 
1008
1029
 
@@ -1100,6 +1121,9 @@ var _Heap = class _Heap extends IterableElementBase {
1100
1121
 
1101
1122
 
1102
1123
 
1124
+
1125
+
1126
+
1103
1127
 
1104
1128
 
1105
1129
 
@@ -1144,6 +1168,9 @@ var _Heap = class _Heap extends IterableElementBase {
1144
1168
 
1145
1169
 
1146
1170
 
1171
+
1172
+
1173
+
1147
1174
 
1148
1175
 
1149
1176
 
@@ -1191,6 +1218,9 @@ var _Heap = class _Heap extends IterableElementBase {
1191
1218
 
1192
1219
 
1193
1220
 
1221
+
1222
+
1223
+
1194
1224
 
1195
1225
 
1196
1226
 
@@ -1235,6 +1265,9 @@ var _Heap = class _Heap extends IterableElementBase {
1235
1265
 
1236
1266
 
1237
1267
 
1268
+
1269
+
1270
+
1238
1271
 
1239
1272
 
1240
1273
 
@@ -1325,6 +1358,9 @@ var _Heap = class _Heap extends IterableElementBase {
1325
1358
 
1326
1359
 
1327
1360
 
1361
+
1362
+
1363
+
1328
1364
 
1329
1365
 
1330
1366
 
@@ -1402,6 +1438,9 @@ var _Heap = class _Heap extends IterableElementBase {
1402
1438
 
1403
1439
 
1404
1440
 
1441
+
1442
+
1443
+
1405
1444
 
1406
1445
 
1407
1446
 
@@ -1452,6 +1491,9 @@ var _Heap = class _Heap extends IterableElementBase {
1452
1491
 
1453
1492
 
1454
1493
 
1494
+
1495
+
1496
+
1455
1497
 
1456
1498
 
1457
1499
 
@@ -1501,6 +1543,9 @@ var _Heap = class _Heap extends IterableElementBase {
1501
1543
 
1502
1544
 
1503
1545
 
1546
+
1547
+
1548
+
1504
1549
 
1505
1550
 
1506
1551
 
@@ -1557,6 +1602,9 @@ var _Heap = class _Heap extends IterableElementBase {
1557
1602
 
1558
1603
 
1559
1604
 
1605
+
1606
+
1607
+
1560
1608
 
1561
1609
 
1562
1610
 
@@ -1569,7 +1617,7 @@ var _Heap = class _Heap extends IterableElementBase {
1569
1617
  */
1570
1618
  map(callback, options, thisArg) {
1571
1619
  const { comparator, toElementFn, ...rest } = options != null ? options : {};
1572
- if (!comparator) throw new TypeError(ERR.comparatorRequired("Heap.map"));
1620
+ if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
1573
1621
  const out = this._createLike([], { ...rest, comparator, toElementFn });
1574
1622
  let i = 0;
1575
1623
  for (const x of this) {
@@ -1757,6 +1805,9 @@ var _Queue = class _Queue extends LinearBase {
1757
1805
 
1758
1806
 
1759
1807
 
1808
+
1809
+
1810
+
1760
1811
 
1761
1812
 
1762
1813
 
@@ -1804,6 +1855,9 @@ var _Queue = class _Queue extends LinearBase {
1804
1855
 
1805
1856
 
1806
1857
 
1858
+
1859
+
1860
+
1807
1861
 
1808
1862
 
1809
1863
 
@@ -1867,6 +1921,9 @@ var _Queue = class _Queue extends LinearBase {
1867
1921
 
1868
1922
 
1869
1923
 
1924
+
1925
+
1926
+
1870
1927
 
1871
1928
 
1872
1929
 
@@ -1926,6 +1983,9 @@ var _Queue = class _Queue extends LinearBase {
1926
1983
 
1927
1984
 
1928
1985
 
1986
+
1987
+
1988
+
1929
1989
 
1930
1990
 
1931
1991
 
@@ -1992,6 +2052,9 @@ var _Queue = class _Queue extends LinearBase {
1992
2052
 
1993
2053
 
1994
2054
 
2055
+
2056
+
2057
+
1995
2058
 
1996
2059
 
1997
2060
 
@@ -2048,6 +2111,9 @@ var _Queue = class _Queue extends LinearBase {
2048
2111
 
2049
2112
 
2050
2113
 
2114
+
2115
+
2116
+
2051
2117
 
2052
2118
 
2053
2119
 
@@ -2097,6 +2163,9 @@ var _Queue = class _Queue extends LinearBase {
2097
2163
 
2098
2164
 
2099
2165
 
2166
+
2167
+
2168
+
2100
2169
 
2101
2170
 
2102
2171
 
@@ -2187,6 +2256,9 @@ var _Queue = class _Queue extends LinearBase {
2187
2256
 
2188
2257
 
2189
2258
 
2259
+
2260
+
2261
+
2190
2262
 
2191
2263
 
2192
2264
 
@@ -2230,6 +2302,9 @@ var _Queue = class _Queue extends LinearBase {
2230
2302
 
2231
2303
 
2232
2304
 
2305
+
2306
+
2307
+
2233
2308
 
2234
2309
 
2235
2310
 
@@ -2296,6 +2371,9 @@ var _Queue = class _Queue extends LinearBase {
2296
2371
 
2297
2372
 
2298
2373
 
2374
+
2375
+
2376
+
2299
2377
 
2300
2378
 
2301
2379
 
@@ -2346,6 +2424,9 @@ var _Queue = class _Queue extends LinearBase {
2346
2424
 
2347
2425
 
2348
2426
 
2427
+
2428
+
2429
+
2349
2430
 
2350
2431
 
2351
2432
 
@@ -2400,6 +2481,9 @@ var _Queue = class _Queue extends LinearBase {
2400
2481
 
2401
2482
 
2402
2483
 
2484
+
2485
+
2486
+
2403
2487
 
2404
2488
 
2405
2489
 
@@ -2638,7 +2722,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
2638
2722
  const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
2639
2723
  return this._addEdge(newEdge);
2640
2724
  } else {
2641
- throw new TypeError(ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
2725
+ raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
2642
2726
  }
2643
2727
  }
2644
2728
  }
@@ -3528,6 +3612,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3528
3612
 
3529
3613
 
3530
3614
 
3615
+
3616
+
3617
+
3531
3618
 
3532
3619
 
3533
3620
 
@@ -3610,6 +3697,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3610
3697
 
3611
3698
 
3612
3699
 
3700
+
3701
+
3702
+
3613
3703
 
3614
3704
 
3615
3705
 
@@ -3691,6 +3781,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3691
3781
 
3692
3782
 
3693
3783
 
3784
+
3785
+
3786
+
3694
3787
 
3695
3788
 
3696
3789
 
@@ -3787,6 +3880,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3787
3880
 
3788
3881
 
3789
3882
 
3883
+
3884
+
3885
+
3790
3886
 
3791
3887
 
3792
3888
 
@@ -3838,6 +3934,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3838
3934
 
3839
3935
 
3840
3936
 
3937
+
3938
+
3939
+
3841
3940
 
3842
3941
 
3843
3942
 
@@ -3959,6 +4058,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
3959
4058
 
3960
4059
 
3961
4060
 
4061
+
4062
+
4063
+
3962
4064
 
3963
4065
 
3964
4066
 
@@ -4102,6 +4204,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
4102
4204
 
4103
4205
 
4104
4206
 
4207
+
4208
+
4209
+
4105
4210
 
4106
4211
 
4107
4212
 
@@ -4167,6 +4272,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
4167
4272
 
4168
4273
 
4169
4274
 
4275
+
4276
+
4277
+
4170
4278
 
4171
4279
 
4172
4280
 
@@ -4214,6 +4322,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
4214
4322
 
4215
4323
 
4216
4324
 
4325
+
4326
+
4327
+
4217
4328
 
4218
4329
 
4219
4330
 
@@ -4287,5 +4398,6 @@ exports.Range = Range;
4287
4398
  exports.UndirectedEdge = UndirectedEdge;
4288
4399
  exports.UndirectedGraph = UndirectedGraph;
4289
4400
  exports.UndirectedVertex = UndirectedVertex;
4401
+ exports.raise = raise;
4290
4402
  //# sourceMappingURL=index.cjs.map
4291
4403
  //# sourceMappingURL=index.cjs.map