directed-graph-typed 2.5.1 → 2.5.3
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.
- package/dist/cjs/index.cjs +333 -20
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +333 -20
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +333 -21
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +333 -21
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
- package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
- package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
- package/dist/types/data-structures/heap/heap.d.ts +140 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
- package/dist/types/data-structures/queue/deque.d.ts +127 -0
- package/dist/types/data-structures/queue/queue.d.ts +97 -0
- package/dist/types/data-structures/stack/stack.d.ts +72 -2
- package/dist/types/data-structures/trie/trie.d.ts +84 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/directed-graph-typed.js +333 -21
- package/dist/umd/directed-graph-typed.js.map +1 -1
- package/dist/umd/directed-graph-typed.min.js +2 -2
- package/dist/umd/directed-graph-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +99 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
- package/src/data-structures/binary-tree/binary-tree.ts +239 -78
- package/src/data-structures/binary-tree/bst.ts +542 -13
- package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +1223 -261
- package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
- package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
- package/src/data-structures/binary-tree/tree-set.ts +1018 -99
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +102 -16
- package/src/data-structures/heap/heap.ts +153 -23
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
- package/src/data-structures/matrix/matrix.ts +65 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +130 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +86 -2
- package/src/interfaces/binary-tree.ts +1 -9
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
package/dist/esm/index.mjs
CHANGED
|
@@ -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)
|
|
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)
|
|
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
|
}
|
|
@@ -727,6 +733,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
727
733
|
|
|
728
734
|
|
|
729
735
|
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
730
743
|
|
|
731
744
|
|
|
732
745
|
|
|
@@ -783,7 +796,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
783
796
|
}
|
|
784
797
|
/**
|
|
785
798
|
* Insert an element.
|
|
786
|
-
* @remarks Time O(
|
|
799
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
787
800
|
* @param element - Element to insert.
|
|
788
801
|
* @returns True.
|
|
789
802
|
|
|
@@ -810,6 +823,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
810
823
|
|
|
811
824
|
|
|
812
825
|
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
813
833
|
|
|
814
834
|
|
|
815
835
|
|
|
@@ -864,6 +884,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
864
884
|
|
|
865
885
|
|
|
866
886
|
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
867
894
|
|
|
868
895
|
|
|
869
896
|
|
|
@@ -921,6 +948,12 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
921
948
|
|
|
922
949
|
|
|
923
950
|
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
924
957
|
|
|
925
958
|
|
|
926
959
|
|
|
@@ -928,6 +961,34 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
928
961
|
|
|
929
962
|
|
|
930
963
|
|
|
964
|
+
* @example
|
|
965
|
+
* // Heap with custom comparator (MaxHeap behavior)
|
|
966
|
+
* interface Task {
|
|
967
|
+
* id: number;
|
|
968
|
+
* priority: number;
|
|
969
|
+
* name: string;
|
|
970
|
+
* }
|
|
971
|
+
*
|
|
972
|
+
* // Custom comparator for max heap behavior (higher priority first)
|
|
973
|
+
* const tasks: Task[] = [
|
|
974
|
+
* { id: 1, priority: 5, name: 'Email' },
|
|
975
|
+
* { id: 2, priority: 3, name: 'Chat' },
|
|
976
|
+
* { id: 3, priority: 8, name: 'Alert' }
|
|
977
|
+
* ];
|
|
978
|
+
*
|
|
979
|
+
* const maxHeap = new Heap(tasks, {
|
|
980
|
+
* comparator: (a: Task, b: Task) => b.priority - a.priority
|
|
981
|
+
* });
|
|
982
|
+
*
|
|
983
|
+
* console.log(maxHeap.size); // 3;
|
|
984
|
+
*
|
|
985
|
+
* // Peek returns highest priority task
|
|
986
|
+
* const topTask = maxHeap.peek();
|
|
987
|
+
* console.log(topTask?.priority); // 8;
|
|
988
|
+
* console.log(topTask?.name); // 'Alert';
|
|
989
|
+
*/
|
|
990
|
+
/**
|
|
991
|
+
* @deprecated Use `pop` instead. Will be removed in a future major version.
|
|
931
992
|
* @example
|
|
932
993
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
933
994
|
* interface Task {
|
|
@@ -955,6 +1016,14 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
955
1016
|
* console.log(topTask?.name); // 'Alert';
|
|
956
1017
|
*/
|
|
957
1018
|
poll() {
|
|
1019
|
+
return this.pop();
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Remove and return the top element (min or max depending on comparator).
|
|
1023
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
1024
|
+
* @returns The removed top element, or undefined if empty.
|
|
1025
|
+
*/
|
|
1026
|
+
pop() {
|
|
958
1027
|
if (this.elements.length === 0) return;
|
|
959
1028
|
const value = this.elements[0];
|
|
960
1029
|
const last = this.elements.pop();
|
|
@@ -992,6 +1061,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
992
1061
|
|
|
993
1062
|
|
|
994
1063
|
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
|
|
995
1071
|
|
|
996
1072
|
|
|
997
1073
|
|
|
@@ -1089,6 +1165,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1089
1165
|
|
|
1090
1166
|
|
|
1091
1167
|
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
|
|
1092
1175
|
|
|
1093
1176
|
|
|
1094
1177
|
|
|
@@ -1133,6 +1216,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1133
1216
|
|
|
1134
1217
|
|
|
1135
1218
|
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
|
|
1136
1226
|
|
|
1137
1227
|
|
|
1138
1228
|
|
|
@@ -1150,16 +1240,6 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1150
1240
|
clear() {
|
|
1151
1241
|
this._elements = [];
|
|
1152
1242
|
}
|
|
1153
|
-
/**
|
|
1154
|
-
* Replace the backing array and rebuild the heap.
|
|
1155
|
-
* @remarks Time O(N), Space O(N)
|
|
1156
|
-
* @param elements - Iterable used to refill the heap.
|
|
1157
|
-
* @returns Array of per-node results from fixing steps.
|
|
1158
|
-
*/
|
|
1159
|
-
refill(elements) {
|
|
1160
|
-
this._elements = Array.from(elements);
|
|
1161
|
-
return this.fix();
|
|
1162
|
-
}
|
|
1163
1243
|
/**
|
|
1164
1244
|
* Check if an equal element exists in the heap.
|
|
1165
1245
|
* @remarks Time O(N), Space O(1)
|
|
@@ -1180,6 +1260,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1180
1260
|
|
|
1181
1261
|
|
|
1182
1262
|
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
|
|
1183
1270
|
|
|
1184
1271
|
|
|
1185
1272
|
|
|
@@ -1224,6 +1311,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1224
1311
|
|
|
1225
1312
|
|
|
1226
1313
|
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
|
|
1227
1321
|
|
|
1228
1322
|
|
|
1229
1323
|
|
|
@@ -1248,7 +1342,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1248
1342
|
}
|
|
1249
1343
|
if (index < 0) return false;
|
|
1250
1344
|
if (index === 0) {
|
|
1251
|
-
this.
|
|
1345
|
+
this.pop();
|
|
1252
1346
|
} else if (index === this.elements.length - 1) {
|
|
1253
1347
|
this.elements.pop();
|
|
1254
1348
|
} else {
|
|
@@ -1258,13 +1352,19 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1258
1352
|
}
|
|
1259
1353
|
return true;
|
|
1260
1354
|
}
|
|
1355
|
+
/**
|
|
1356
|
+
* @deprecated Use `deleteWhere` instead. Will be removed in a future major version.
|
|
1357
|
+
*/
|
|
1358
|
+
deleteBy(predicate) {
|
|
1359
|
+
return this.deleteWhere(predicate);
|
|
1360
|
+
}
|
|
1261
1361
|
/**
|
|
1262
1362
|
* Delete the first element that matches a predicate.
|
|
1263
1363
|
* @remarks Time O(N), Space O(1)
|
|
1264
1364
|
* @param predicate - Function (element, index, heap) → boolean.
|
|
1265
1365
|
* @returns True if an element was removed.
|
|
1266
1366
|
*/
|
|
1267
|
-
|
|
1367
|
+
deleteWhere(predicate) {
|
|
1268
1368
|
let idx = -1;
|
|
1269
1369
|
for (let i = 0; i < this.elements.length; i++) {
|
|
1270
1370
|
if (predicate(this.elements[i], i, this)) {
|
|
@@ -1274,7 +1374,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1274
1374
|
}
|
|
1275
1375
|
if (idx < 0) return false;
|
|
1276
1376
|
if (idx === 0) {
|
|
1277
|
-
this.
|
|
1377
|
+
this.pop();
|
|
1278
1378
|
} else if (idx === this.elements.length - 1) {
|
|
1279
1379
|
this.elements.pop();
|
|
1280
1380
|
} else {
|
|
@@ -1314,6 +1414,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1314
1414
|
|
|
1315
1415
|
|
|
1316
1416
|
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
|
|
1317
1424
|
|
|
1318
1425
|
|
|
1319
1426
|
|
|
@@ -1391,6 +1498,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1391
1498
|
|
|
1392
1499
|
|
|
1393
1500
|
|
|
1501
|
+
|
|
1502
|
+
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
|
|
1394
1508
|
|
|
1395
1509
|
|
|
1396
1510
|
|
|
@@ -1441,6 +1555,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1441
1555
|
|
|
1442
1556
|
|
|
1443
1557
|
|
|
1558
|
+
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
|
|
1563
|
+
|
|
1564
|
+
|
|
1444
1565
|
|
|
1445
1566
|
|
|
1446
1567
|
|
|
@@ -1490,6 +1611,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1490
1611
|
|
|
1491
1612
|
|
|
1492
1613
|
|
|
1614
|
+
|
|
1615
|
+
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
|
|
1620
|
+
|
|
1493
1621
|
|
|
1494
1622
|
|
|
1495
1623
|
|
|
@@ -1546,6 +1674,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1546
1674
|
|
|
1547
1675
|
|
|
1548
1676
|
|
|
1677
|
+
|
|
1678
|
+
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
|
|
1682
|
+
|
|
1683
|
+
|
|
1549
1684
|
|
|
1550
1685
|
|
|
1551
1686
|
|
|
@@ -1562,7 +1697,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1562
1697
|
*/
|
|
1563
1698
|
map(callback, options, thisArg) {
|
|
1564
1699
|
const { comparator, toElementFn, ...rest } = options ?? {};
|
|
1565
|
-
if (!comparator)
|
|
1700
|
+
if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
|
|
1566
1701
|
const out = this._createLike([], { ...rest, comparator, toElementFn });
|
|
1567
1702
|
let i = 0;
|
|
1568
1703
|
for (const x of this) {
|
|
@@ -1589,7 +1724,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1589
1724
|
}
|
|
1590
1725
|
_DEFAULT_COMPARATOR = /* @__PURE__ */ __name((a, b) => {
|
|
1591
1726
|
if (typeof a === "object" || typeof b === "object") {
|
|
1592
|
-
|
|
1727
|
+
raise(TypeError, ERR.comparatorRequired("Heap"));
|
|
1593
1728
|
}
|
|
1594
1729
|
if (a > b) return 1;
|
|
1595
1730
|
if (a < b) return -1;
|
|
@@ -1756,6 +1891,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1756
1891
|
|
|
1757
1892
|
|
|
1758
1893
|
|
|
1894
|
+
|
|
1895
|
+
|
|
1896
|
+
|
|
1897
|
+
|
|
1898
|
+
|
|
1899
|
+
|
|
1900
|
+
|
|
1759
1901
|
|
|
1760
1902
|
|
|
1761
1903
|
|
|
@@ -1803,6 +1945,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1803
1945
|
|
|
1804
1946
|
|
|
1805
1947
|
|
|
1948
|
+
|
|
1949
|
+
|
|
1950
|
+
|
|
1951
|
+
|
|
1952
|
+
|
|
1953
|
+
|
|
1954
|
+
|
|
1806
1955
|
|
|
1807
1956
|
|
|
1808
1957
|
|
|
@@ -1820,6 +1969,14 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1820
1969
|
get first() {
|
|
1821
1970
|
return this.length > 0 ? this.elements[this._offset] : void 0;
|
|
1822
1971
|
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
1974
|
+
* @remarks Time O(1), Space O(1)
|
|
1975
|
+
* @returns Front element or undefined.
|
|
1976
|
+
*/
|
|
1977
|
+
peek() {
|
|
1978
|
+
return this.first;
|
|
1979
|
+
}
|
|
1823
1980
|
/**
|
|
1824
1981
|
* Get the last element (back) without removing it.
|
|
1825
1982
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1866,6 +2023,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1866
2023
|
|
|
1867
2024
|
|
|
1868
2025
|
|
|
2026
|
+
|
|
2027
|
+
|
|
2028
|
+
|
|
2029
|
+
|
|
2030
|
+
|
|
2031
|
+
|
|
2032
|
+
|
|
1869
2033
|
|
|
1870
2034
|
|
|
1871
2035
|
|
|
@@ -1925,6 +2089,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1925
2089
|
|
|
1926
2090
|
|
|
1927
2091
|
|
|
2092
|
+
|
|
2093
|
+
|
|
2094
|
+
|
|
2095
|
+
|
|
2096
|
+
|
|
2097
|
+
|
|
2098
|
+
|
|
1928
2099
|
|
|
1929
2100
|
|
|
1930
2101
|
|
|
@@ -1991,6 +2162,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1991
2162
|
|
|
1992
2163
|
|
|
1993
2164
|
|
|
2165
|
+
|
|
2166
|
+
|
|
2167
|
+
|
|
2168
|
+
|
|
2169
|
+
|
|
2170
|
+
|
|
2171
|
+
|
|
1994
2172
|
|
|
1995
2173
|
|
|
1996
2174
|
|
|
@@ -2047,6 +2225,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2047
2225
|
|
|
2048
2226
|
|
|
2049
2227
|
|
|
2228
|
+
|
|
2229
|
+
|
|
2230
|
+
|
|
2231
|
+
|
|
2232
|
+
|
|
2233
|
+
|
|
2234
|
+
|
|
2050
2235
|
|
|
2051
2236
|
|
|
2052
2237
|
|
|
@@ -2096,6 +2281,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2096
2281
|
|
|
2097
2282
|
|
|
2098
2283
|
|
|
2284
|
+
|
|
2285
|
+
|
|
2286
|
+
|
|
2287
|
+
|
|
2288
|
+
|
|
2289
|
+
|
|
2290
|
+
|
|
2099
2291
|
|
|
2100
2292
|
|
|
2101
2293
|
|
|
@@ -2150,6 +2342,21 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2150
2342
|
this._elements[this._offset + index] = newElement;
|
|
2151
2343
|
return true;
|
|
2152
2344
|
}
|
|
2345
|
+
/**
|
|
2346
|
+
* Delete the first element that satisfies a predicate.
|
|
2347
|
+
* @remarks Time O(N), Space O(N)
|
|
2348
|
+
* @param predicate - Function (value, index, queue) → boolean to decide deletion.
|
|
2349
|
+
* @returns True if a match was removed.
|
|
2350
|
+
*/
|
|
2351
|
+
deleteWhere(predicate) {
|
|
2352
|
+
for (let i = 0; i < this.length; i++) {
|
|
2353
|
+
if (predicate(this._elements[this._offset + i], i, this)) {
|
|
2354
|
+
this.deleteAt(i);
|
|
2355
|
+
return true;
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
return false;
|
|
2359
|
+
}
|
|
2153
2360
|
/**
|
|
2154
2361
|
* Reverse the queue in-place by compacting then reversing.
|
|
2155
2362
|
* @remarks Time O(N), Space O(N)
|
|
@@ -2186,6 +2393,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2186
2393
|
|
|
2187
2394
|
|
|
2188
2395
|
|
|
2396
|
+
|
|
2397
|
+
|
|
2398
|
+
|
|
2399
|
+
|
|
2400
|
+
|
|
2401
|
+
|
|
2402
|
+
|
|
2189
2403
|
|
|
2190
2404
|
|
|
2191
2405
|
|
|
@@ -2229,6 +2443,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2229
2443
|
|
|
2230
2444
|
|
|
2231
2445
|
|
|
2446
|
+
|
|
2447
|
+
|
|
2448
|
+
|
|
2449
|
+
|
|
2450
|
+
|
|
2451
|
+
|
|
2452
|
+
|
|
2232
2453
|
|
|
2233
2454
|
|
|
2234
2455
|
|
|
@@ -2295,6 +2516,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2295
2516
|
|
|
2296
2517
|
|
|
2297
2518
|
|
|
2519
|
+
|
|
2520
|
+
|
|
2521
|
+
|
|
2522
|
+
|
|
2523
|
+
|
|
2524
|
+
|
|
2525
|
+
|
|
2298
2526
|
|
|
2299
2527
|
|
|
2300
2528
|
|
|
@@ -2345,6 +2573,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2345
2573
|
|
|
2346
2574
|
|
|
2347
2575
|
|
|
2576
|
+
|
|
2577
|
+
|
|
2578
|
+
|
|
2579
|
+
|
|
2580
|
+
|
|
2581
|
+
|
|
2582
|
+
|
|
2348
2583
|
|
|
2349
2584
|
|
|
2350
2585
|
|
|
@@ -2399,6 +2634,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2399
2634
|
|
|
2400
2635
|
|
|
2401
2636
|
|
|
2637
|
+
|
|
2638
|
+
|
|
2639
|
+
|
|
2640
|
+
|
|
2641
|
+
|
|
2642
|
+
|
|
2643
|
+
|
|
2402
2644
|
|
|
2403
2645
|
|
|
2404
2646
|
|
|
@@ -2642,7 +2884,7 @@ var AbstractGraph = class extends IterableEntryBase {
|
|
|
2642
2884
|
const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
|
|
2643
2885
|
return this._addEdge(newEdge);
|
|
2644
2886
|
} else {
|
|
2645
|
-
|
|
2887
|
+
raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
|
|
2646
2888
|
}
|
|
2647
2889
|
}
|
|
2648
2890
|
}
|
|
@@ -3535,6 +3777,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3535
3777
|
|
|
3536
3778
|
|
|
3537
3779
|
|
|
3780
|
+
|
|
3781
|
+
|
|
3782
|
+
|
|
3783
|
+
|
|
3784
|
+
|
|
3785
|
+
|
|
3786
|
+
|
|
3538
3787
|
|
|
3539
3788
|
|
|
3540
3789
|
|
|
@@ -3620,6 +3869,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3620
3869
|
|
|
3621
3870
|
|
|
3622
3871
|
|
|
3872
|
+
|
|
3873
|
+
|
|
3874
|
+
|
|
3875
|
+
|
|
3876
|
+
|
|
3877
|
+
|
|
3878
|
+
|
|
3623
3879
|
|
|
3624
3880
|
|
|
3625
3881
|
|
|
@@ -3703,6 +3959,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3703
3959
|
|
|
3704
3960
|
|
|
3705
3961
|
|
|
3962
|
+
|
|
3963
|
+
|
|
3964
|
+
|
|
3965
|
+
|
|
3966
|
+
|
|
3967
|
+
|
|
3968
|
+
|
|
3706
3969
|
|
|
3707
3970
|
|
|
3708
3971
|
|
|
@@ -3777,6 +4040,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3777
4040
|
|
|
3778
4041
|
|
|
3779
4042
|
|
|
4043
|
+
|
|
4044
|
+
|
|
4045
|
+
|
|
4046
|
+
|
|
4047
|
+
|
|
4048
|
+
|
|
4049
|
+
|
|
3780
4050
|
|
|
3781
4051
|
|
|
3782
4052
|
|
|
@@ -3828,6 +4098,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3828
4098
|
|
|
3829
4099
|
|
|
3830
4100
|
|
|
4101
|
+
|
|
4102
|
+
|
|
4103
|
+
|
|
4104
|
+
|
|
4105
|
+
|
|
4106
|
+
|
|
4107
|
+
|
|
3831
4108
|
|
|
3832
4109
|
|
|
3833
4110
|
|
|
@@ -3932,6 +4209,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3932
4209
|
|
|
3933
4210
|
|
|
3934
4211
|
|
|
4212
|
+
|
|
4213
|
+
|
|
4214
|
+
|
|
4215
|
+
|
|
4216
|
+
|
|
4217
|
+
|
|
4218
|
+
|
|
3935
4219
|
|
|
3936
4220
|
|
|
3937
4221
|
|
|
@@ -4017,6 +4301,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4017
4301
|
|
|
4018
4302
|
|
|
4019
4303
|
|
|
4304
|
+
|
|
4305
|
+
|
|
4306
|
+
|
|
4307
|
+
|
|
4308
|
+
|
|
4309
|
+
|
|
4310
|
+
|
|
4020
4311
|
|
|
4021
4312
|
|
|
4022
4313
|
|
|
@@ -4064,6 +4355,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4064
4355
|
|
|
4065
4356
|
|
|
4066
4357
|
|
|
4358
|
+
|
|
4359
|
+
|
|
4360
|
+
|
|
4361
|
+
|
|
4362
|
+
|
|
4363
|
+
|
|
4364
|
+
|
|
4067
4365
|
|
|
4068
4366
|
|
|
4069
4367
|
|
|
@@ -4164,6 +4462,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4164
4462
|
|
|
4165
4463
|
|
|
4166
4464
|
|
|
4465
|
+
|
|
4466
|
+
|
|
4467
|
+
|
|
4468
|
+
|
|
4469
|
+
|
|
4470
|
+
|
|
4471
|
+
|
|
4167
4472
|
|
|
4168
4473
|
|
|
4169
4474
|
|
|
@@ -4267,6 +4572,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4267
4572
|
|
|
4268
4573
|
|
|
4269
4574
|
|
|
4575
|
+
|
|
4576
|
+
|
|
4577
|
+
|
|
4578
|
+
|
|
4579
|
+
|
|
4580
|
+
|
|
4581
|
+
|
|
4270
4582
|
|
|
4271
4583
|
|
|
4272
4584
|
|
|
@@ -4329,6 +4641,6 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4329
4641
|
* @license MIT License
|
|
4330
4642
|
*/
|
|
4331
4643
|
|
|
4332
|
-
export { AbstractEdge, AbstractGraph, AbstractVertex, DFSOperation, DirectedEdge, DirectedGraph, DirectedVertex, ERR, Range };
|
|
4644
|
+
export { AbstractEdge, AbstractGraph, AbstractVertex, DFSOperation, DirectedEdge, DirectedGraph, DirectedVertex, ERR, Range, raise };
|
|
4333
4645
|
//# sourceMappingURL=index.mjs.map
|
|
4334
4646
|
//# sourceMappingURL=index.mjs.map
|