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
|
@@ -31,7 +31,8 @@ var directedGraphTyped = (() => {
|
|
|
31
31
|
DirectedGraph: () => DirectedGraph,
|
|
32
32
|
DirectedVertex: () => DirectedVertex,
|
|
33
33
|
ERR: () => ERR,
|
|
34
|
-
Range: () => Range
|
|
34
|
+
Range: () => Range,
|
|
35
|
+
raise: () => raise
|
|
35
36
|
});
|
|
36
37
|
|
|
37
38
|
// src/utils/utils.ts
|
|
@@ -56,6 +57,9 @@ var directedGraphTyped = (() => {
|
|
|
56
57
|
};
|
|
57
58
|
|
|
58
59
|
// src/common/error.ts
|
|
60
|
+
function raise(ErrorClass, message) {
|
|
61
|
+
throw new ErrorClass(message);
|
|
62
|
+
}
|
|
59
63
|
var ERR = {
|
|
60
64
|
// Range / index
|
|
61
65
|
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
@@ -77,7 +81,9 @@ var directedGraphTyped = (() => {
|
|
|
77
81
|
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
78
82
|
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
79
83
|
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
80
|
-
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}
|
|
84
|
+
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
|
|
85
|
+
// Order statistic
|
|
86
|
+
orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
|
|
81
87
|
};
|
|
82
88
|
|
|
83
89
|
// src/common/index.ts
|
|
@@ -302,7 +308,7 @@ var directedGraphTyped = (() => {
|
|
|
302
308
|
if (options) {
|
|
303
309
|
const { toElementFn } = options;
|
|
304
310
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
305
|
-
else if (toElementFn)
|
|
311
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
306
312
|
}
|
|
307
313
|
}
|
|
308
314
|
/**
|
|
@@ -458,7 +464,7 @@ var directedGraphTyped = (() => {
|
|
|
458
464
|
acc = initialValue;
|
|
459
465
|
} else {
|
|
460
466
|
const first = iter.next();
|
|
461
|
-
if (first.done)
|
|
467
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
462
468
|
acc = first.value;
|
|
463
469
|
index = 1;
|
|
464
470
|
}
|
|
@@ -705,7 +711,7 @@ var directedGraphTyped = (() => {
|
|
|
705
711
|
__publicField(this, "_elements", []);
|
|
706
712
|
__publicField(this, "_DEFAULT_COMPARATOR", (a, b) => {
|
|
707
713
|
if (typeof a === "object" || typeof b === "object") {
|
|
708
|
-
|
|
714
|
+
raise(TypeError, ERR.comparatorRequired("Heap"));
|
|
709
715
|
}
|
|
710
716
|
if (a > b) return 1;
|
|
711
717
|
if (a < b) return -1;
|
|
@@ -754,6 +760,13 @@ var directedGraphTyped = (() => {
|
|
|
754
760
|
|
|
755
761
|
|
|
756
762
|
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
757
770
|
|
|
758
771
|
|
|
759
772
|
|
|
@@ -811,7 +824,7 @@ var directedGraphTyped = (() => {
|
|
|
811
824
|
}
|
|
812
825
|
/**
|
|
813
826
|
* Insert an element.
|
|
814
|
-
* @remarks Time O(
|
|
827
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
815
828
|
* @param element - Element to insert.
|
|
816
829
|
* @returns True.
|
|
817
830
|
|
|
@@ -838,6 +851,13 @@ var directedGraphTyped = (() => {
|
|
|
838
851
|
|
|
839
852
|
|
|
840
853
|
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
|
|
841
861
|
|
|
842
862
|
|
|
843
863
|
|
|
@@ -892,6 +912,13 @@ var directedGraphTyped = (() => {
|
|
|
892
912
|
|
|
893
913
|
|
|
894
914
|
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
895
922
|
|
|
896
923
|
|
|
897
924
|
|
|
@@ -949,6 +976,12 @@ var directedGraphTyped = (() => {
|
|
|
949
976
|
|
|
950
977
|
|
|
951
978
|
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
|
|
952
985
|
|
|
953
986
|
|
|
954
987
|
|
|
@@ -956,6 +989,34 @@ var directedGraphTyped = (() => {
|
|
|
956
989
|
|
|
957
990
|
|
|
958
991
|
|
|
992
|
+
* @example
|
|
993
|
+
* // Heap with custom comparator (MaxHeap behavior)
|
|
994
|
+
* interface Task {
|
|
995
|
+
* id: number;
|
|
996
|
+
* priority: number;
|
|
997
|
+
* name: string;
|
|
998
|
+
* }
|
|
999
|
+
*
|
|
1000
|
+
* // Custom comparator for max heap behavior (higher priority first)
|
|
1001
|
+
* const tasks: Task[] = [
|
|
1002
|
+
* { id: 1, priority: 5, name: 'Email' },
|
|
1003
|
+
* { id: 2, priority: 3, name: 'Chat' },
|
|
1004
|
+
* { id: 3, priority: 8, name: 'Alert' }
|
|
1005
|
+
* ];
|
|
1006
|
+
*
|
|
1007
|
+
* const maxHeap = new Heap(tasks, {
|
|
1008
|
+
* comparator: (a: Task, b: Task) => b.priority - a.priority
|
|
1009
|
+
* });
|
|
1010
|
+
*
|
|
1011
|
+
* console.log(maxHeap.size); // 3;
|
|
1012
|
+
*
|
|
1013
|
+
* // Peek returns highest priority task
|
|
1014
|
+
* const topTask = maxHeap.peek();
|
|
1015
|
+
* console.log(topTask?.priority); // 8;
|
|
1016
|
+
* console.log(topTask?.name); // 'Alert';
|
|
1017
|
+
*/
|
|
1018
|
+
/**
|
|
1019
|
+
* @deprecated Use `pop` instead. Will be removed in a future major version.
|
|
959
1020
|
* @example
|
|
960
1021
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
961
1022
|
* interface Task {
|
|
@@ -983,6 +1044,14 @@ var directedGraphTyped = (() => {
|
|
|
983
1044
|
* console.log(topTask?.name); // 'Alert';
|
|
984
1045
|
*/
|
|
985
1046
|
poll() {
|
|
1047
|
+
return this.pop();
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Remove and return the top element (min or max depending on comparator).
|
|
1051
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
1052
|
+
* @returns The removed top element, or undefined if empty.
|
|
1053
|
+
*/
|
|
1054
|
+
pop() {
|
|
986
1055
|
if (this.elements.length === 0) return;
|
|
987
1056
|
const value = this.elements[0];
|
|
988
1057
|
const last = this.elements.pop();
|
|
@@ -1020,6 +1089,13 @@ var directedGraphTyped = (() => {
|
|
|
1020
1089
|
|
|
1021
1090
|
|
|
1022
1091
|
|
|
1092
|
+
|
|
1093
|
+
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
|
|
1097
|
+
|
|
1098
|
+
|
|
1023
1099
|
|
|
1024
1100
|
|
|
1025
1101
|
|
|
@@ -1117,6 +1193,13 @@ var directedGraphTyped = (() => {
|
|
|
1117
1193
|
|
|
1118
1194
|
|
|
1119
1195
|
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
|
|
1120
1203
|
|
|
1121
1204
|
|
|
1122
1205
|
|
|
@@ -1161,6 +1244,13 @@ var directedGraphTyped = (() => {
|
|
|
1161
1244
|
|
|
1162
1245
|
|
|
1163
1246
|
|
|
1247
|
+
|
|
1248
|
+
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1164
1254
|
|
|
1165
1255
|
|
|
1166
1256
|
|
|
@@ -1178,16 +1268,6 @@ var directedGraphTyped = (() => {
|
|
|
1178
1268
|
clear() {
|
|
1179
1269
|
this._elements = [];
|
|
1180
1270
|
}
|
|
1181
|
-
/**
|
|
1182
|
-
* Replace the backing array and rebuild the heap.
|
|
1183
|
-
* @remarks Time O(N), Space O(N)
|
|
1184
|
-
* @param elements - Iterable used to refill the heap.
|
|
1185
|
-
* @returns Array of per-node results from fixing steps.
|
|
1186
|
-
*/
|
|
1187
|
-
refill(elements) {
|
|
1188
|
-
this._elements = Array.from(elements);
|
|
1189
|
-
return this.fix();
|
|
1190
|
-
}
|
|
1191
1271
|
/**
|
|
1192
1272
|
* Check if an equal element exists in the heap.
|
|
1193
1273
|
* @remarks Time O(N), Space O(1)
|
|
@@ -1208,6 +1288,13 @@ var directedGraphTyped = (() => {
|
|
|
1208
1288
|
|
|
1209
1289
|
|
|
1210
1290
|
|
|
1291
|
+
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
|
|
1211
1298
|
|
|
1212
1299
|
|
|
1213
1300
|
|
|
@@ -1252,6 +1339,13 @@ var directedGraphTyped = (() => {
|
|
|
1252
1339
|
|
|
1253
1340
|
|
|
1254
1341
|
|
|
1342
|
+
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1255
1349
|
|
|
1256
1350
|
|
|
1257
1351
|
|
|
@@ -1276,7 +1370,7 @@ var directedGraphTyped = (() => {
|
|
|
1276
1370
|
}
|
|
1277
1371
|
if (index < 0) return false;
|
|
1278
1372
|
if (index === 0) {
|
|
1279
|
-
this.
|
|
1373
|
+
this.pop();
|
|
1280
1374
|
} else if (index === this.elements.length - 1) {
|
|
1281
1375
|
this.elements.pop();
|
|
1282
1376
|
} else {
|
|
@@ -1286,13 +1380,19 @@ var directedGraphTyped = (() => {
|
|
|
1286
1380
|
}
|
|
1287
1381
|
return true;
|
|
1288
1382
|
}
|
|
1383
|
+
/**
|
|
1384
|
+
* @deprecated Use `deleteWhere` instead. Will be removed in a future major version.
|
|
1385
|
+
*/
|
|
1386
|
+
deleteBy(predicate) {
|
|
1387
|
+
return this.deleteWhere(predicate);
|
|
1388
|
+
}
|
|
1289
1389
|
/**
|
|
1290
1390
|
* Delete the first element that matches a predicate.
|
|
1291
1391
|
* @remarks Time O(N), Space O(1)
|
|
1292
1392
|
* @param predicate - Function (element, index, heap) → boolean.
|
|
1293
1393
|
* @returns True if an element was removed.
|
|
1294
1394
|
*/
|
|
1295
|
-
|
|
1395
|
+
deleteWhere(predicate) {
|
|
1296
1396
|
let idx = -1;
|
|
1297
1397
|
for (let i = 0; i < this.elements.length; i++) {
|
|
1298
1398
|
if (predicate(this.elements[i], i, this)) {
|
|
@@ -1302,7 +1402,7 @@ var directedGraphTyped = (() => {
|
|
|
1302
1402
|
}
|
|
1303
1403
|
if (idx < 0) return false;
|
|
1304
1404
|
if (idx === 0) {
|
|
1305
|
-
this.
|
|
1405
|
+
this.pop();
|
|
1306
1406
|
} else if (idx === this.elements.length - 1) {
|
|
1307
1407
|
this.elements.pop();
|
|
1308
1408
|
} else {
|
|
@@ -1342,6 +1442,13 @@ var directedGraphTyped = (() => {
|
|
|
1342
1442
|
|
|
1343
1443
|
|
|
1344
1444
|
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
|
|
1345
1452
|
|
|
1346
1453
|
|
|
1347
1454
|
|
|
@@ -1419,6 +1526,13 @@ var directedGraphTyped = (() => {
|
|
|
1419
1526
|
|
|
1420
1527
|
|
|
1421
1528
|
|
|
1529
|
+
|
|
1530
|
+
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
|
|
1534
|
+
|
|
1535
|
+
|
|
1422
1536
|
|
|
1423
1537
|
|
|
1424
1538
|
|
|
@@ -1469,6 +1583,13 @@ var directedGraphTyped = (() => {
|
|
|
1469
1583
|
|
|
1470
1584
|
|
|
1471
1585
|
|
|
1586
|
+
|
|
1587
|
+
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
|
|
1592
|
+
|
|
1472
1593
|
|
|
1473
1594
|
|
|
1474
1595
|
|
|
@@ -1518,6 +1639,13 @@ var directedGraphTyped = (() => {
|
|
|
1518
1639
|
|
|
1519
1640
|
|
|
1520
1641
|
|
|
1642
|
+
|
|
1643
|
+
|
|
1644
|
+
|
|
1645
|
+
|
|
1646
|
+
|
|
1647
|
+
|
|
1648
|
+
|
|
1521
1649
|
|
|
1522
1650
|
|
|
1523
1651
|
|
|
@@ -1574,6 +1702,13 @@ var directedGraphTyped = (() => {
|
|
|
1574
1702
|
|
|
1575
1703
|
|
|
1576
1704
|
|
|
1705
|
+
|
|
1706
|
+
|
|
1707
|
+
|
|
1708
|
+
|
|
1709
|
+
|
|
1710
|
+
|
|
1711
|
+
|
|
1577
1712
|
|
|
1578
1713
|
|
|
1579
1714
|
|
|
@@ -1590,7 +1725,7 @@ var directedGraphTyped = (() => {
|
|
|
1590
1725
|
*/
|
|
1591
1726
|
map(callback, options, thisArg) {
|
|
1592
1727
|
const { comparator, toElementFn, ...rest } = options != null ? options : {};
|
|
1593
|
-
if (!comparator)
|
|
1728
|
+
if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
|
|
1594
1729
|
const out = this._createLike([], { ...rest, comparator, toElementFn });
|
|
1595
1730
|
let i = 0;
|
|
1596
1731
|
for (const x of this) {
|
|
@@ -1772,6 +1907,13 @@ var directedGraphTyped = (() => {
|
|
|
1772
1907
|
|
|
1773
1908
|
|
|
1774
1909
|
|
|
1910
|
+
|
|
1911
|
+
|
|
1912
|
+
|
|
1913
|
+
|
|
1914
|
+
|
|
1915
|
+
|
|
1916
|
+
|
|
1775
1917
|
|
|
1776
1918
|
|
|
1777
1919
|
|
|
@@ -1819,6 +1961,13 @@ var directedGraphTyped = (() => {
|
|
|
1819
1961
|
|
|
1820
1962
|
|
|
1821
1963
|
|
|
1964
|
+
|
|
1965
|
+
|
|
1966
|
+
|
|
1967
|
+
|
|
1968
|
+
|
|
1969
|
+
|
|
1970
|
+
|
|
1822
1971
|
|
|
1823
1972
|
|
|
1824
1973
|
|
|
@@ -1836,6 +1985,14 @@ var directedGraphTyped = (() => {
|
|
|
1836
1985
|
get first() {
|
|
1837
1986
|
return this.length > 0 ? this.elements[this._offset] : void 0;
|
|
1838
1987
|
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
1990
|
+
* @remarks Time O(1), Space O(1)
|
|
1991
|
+
* @returns Front element or undefined.
|
|
1992
|
+
*/
|
|
1993
|
+
peek() {
|
|
1994
|
+
return this.first;
|
|
1995
|
+
}
|
|
1839
1996
|
/**
|
|
1840
1997
|
* Get the last element (back) without removing it.
|
|
1841
1998
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1882,6 +2039,13 @@ var directedGraphTyped = (() => {
|
|
|
1882
2039
|
|
|
1883
2040
|
|
|
1884
2041
|
|
|
2042
|
+
|
|
2043
|
+
|
|
2044
|
+
|
|
2045
|
+
|
|
2046
|
+
|
|
2047
|
+
|
|
2048
|
+
|
|
1885
2049
|
|
|
1886
2050
|
|
|
1887
2051
|
|
|
@@ -1941,6 +2105,13 @@ var directedGraphTyped = (() => {
|
|
|
1941
2105
|
|
|
1942
2106
|
|
|
1943
2107
|
|
|
2108
|
+
|
|
2109
|
+
|
|
2110
|
+
|
|
2111
|
+
|
|
2112
|
+
|
|
2113
|
+
|
|
2114
|
+
|
|
1944
2115
|
|
|
1945
2116
|
|
|
1946
2117
|
|
|
@@ -2007,6 +2178,13 @@ var directedGraphTyped = (() => {
|
|
|
2007
2178
|
|
|
2008
2179
|
|
|
2009
2180
|
|
|
2181
|
+
|
|
2182
|
+
|
|
2183
|
+
|
|
2184
|
+
|
|
2185
|
+
|
|
2186
|
+
|
|
2187
|
+
|
|
2010
2188
|
|
|
2011
2189
|
|
|
2012
2190
|
|
|
@@ -2063,6 +2241,13 @@ var directedGraphTyped = (() => {
|
|
|
2063
2241
|
|
|
2064
2242
|
|
|
2065
2243
|
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
|
|
2066
2251
|
|
|
2067
2252
|
|
|
2068
2253
|
|
|
@@ -2112,6 +2297,13 @@ var directedGraphTyped = (() => {
|
|
|
2112
2297
|
|
|
2113
2298
|
|
|
2114
2299
|
|
|
2300
|
+
|
|
2301
|
+
|
|
2302
|
+
|
|
2303
|
+
|
|
2304
|
+
|
|
2305
|
+
|
|
2306
|
+
|
|
2115
2307
|
|
|
2116
2308
|
|
|
2117
2309
|
|
|
@@ -2166,6 +2358,21 @@ var directedGraphTyped = (() => {
|
|
|
2166
2358
|
this._elements[this._offset + index] = newElement;
|
|
2167
2359
|
return true;
|
|
2168
2360
|
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Delete the first element that satisfies a predicate.
|
|
2363
|
+
* @remarks Time O(N), Space O(N)
|
|
2364
|
+
* @param predicate - Function (value, index, queue) → boolean to decide deletion.
|
|
2365
|
+
* @returns True if a match was removed.
|
|
2366
|
+
*/
|
|
2367
|
+
deleteWhere(predicate) {
|
|
2368
|
+
for (let i = 0; i < this.length; i++) {
|
|
2369
|
+
if (predicate(this._elements[this._offset + i], i, this)) {
|
|
2370
|
+
this.deleteAt(i);
|
|
2371
|
+
return true;
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
return false;
|
|
2375
|
+
}
|
|
2169
2376
|
/**
|
|
2170
2377
|
* Reverse the queue in-place by compacting then reversing.
|
|
2171
2378
|
* @remarks Time O(N), Space O(N)
|
|
@@ -2202,6 +2409,13 @@ var directedGraphTyped = (() => {
|
|
|
2202
2409
|
|
|
2203
2410
|
|
|
2204
2411
|
|
|
2412
|
+
|
|
2413
|
+
|
|
2414
|
+
|
|
2415
|
+
|
|
2416
|
+
|
|
2417
|
+
|
|
2418
|
+
|
|
2205
2419
|
|
|
2206
2420
|
|
|
2207
2421
|
|
|
@@ -2245,6 +2459,13 @@ var directedGraphTyped = (() => {
|
|
|
2245
2459
|
|
|
2246
2460
|
|
|
2247
2461
|
|
|
2462
|
+
|
|
2463
|
+
|
|
2464
|
+
|
|
2465
|
+
|
|
2466
|
+
|
|
2467
|
+
|
|
2468
|
+
|
|
2248
2469
|
|
|
2249
2470
|
|
|
2250
2471
|
|
|
@@ -2311,6 +2532,13 @@ var directedGraphTyped = (() => {
|
|
|
2311
2532
|
|
|
2312
2533
|
|
|
2313
2534
|
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2314
2542
|
|
|
2315
2543
|
|
|
2316
2544
|
|
|
@@ -2361,6 +2589,13 @@ var directedGraphTyped = (() => {
|
|
|
2361
2589
|
|
|
2362
2590
|
|
|
2363
2591
|
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
|
|
2595
|
+
|
|
2596
|
+
|
|
2597
|
+
|
|
2598
|
+
|
|
2364
2599
|
|
|
2365
2600
|
|
|
2366
2601
|
|
|
@@ -2415,6 +2650,13 @@ var directedGraphTyped = (() => {
|
|
|
2415
2650
|
|
|
2416
2651
|
|
|
2417
2652
|
|
|
2653
|
+
|
|
2654
|
+
|
|
2655
|
+
|
|
2656
|
+
|
|
2657
|
+
|
|
2658
|
+
|
|
2659
|
+
|
|
2418
2660
|
|
|
2419
2661
|
|
|
2420
2662
|
|
|
@@ -2651,7 +2893,7 @@ var directedGraphTyped = (() => {
|
|
|
2651
2893
|
const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
|
|
2652
2894
|
return this._addEdge(newEdge);
|
|
2653
2895
|
} else {
|
|
2654
|
-
|
|
2896
|
+
raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
|
|
2655
2897
|
}
|
|
2656
2898
|
}
|
|
2657
2899
|
}
|
|
@@ -3542,6 +3784,13 @@ var directedGraphTyped = (() => {
|
|
|
3542
3784
|
|
|
3543
3785
|
|
|
3544
3786
|
|
|
3787
|
+
|
|
3788
|
+
|
|
3789
|
+
|
|
3790
|
+
|
|
3791
|
+
|
|
3792
|
+
|
|
3793
|
+
|
|
3545
3794
|
|
|
3546
3795
|
|
|
3547
3796
|
|
|
@@ -3627,6 +3876,13 @@ var directedGraphTyped = (() => {
|
|
|
3627
3876
|
|
|
3628
3877
|
|
|
3629
3878
|
|
|
3879
|
+
|
|
3880
|
+
|
|
3881
|
+
|
|
3882
|
+
|
|
3883
|
+
|
|
3884
|
+
|
|
3885
|
+
|
|
3630
3886
|
|
|
3631
3887
|
|
|
3632
3888
|
|
|
@@ -3710,6 +3966,13 @@ var directedGraphTyped = (() => {
|
|
|
3710
3966
|
|
|
3711
3967
|
|
|
3712
3968
|
|
|
3969
|
+
|
|
3970
|
+
|
|
3971
|
+
|
|
3972
|
+
|
|
3973
|
+
|
|
3974
|
+
|
|
3975
|
+
|
|
3713
3976
|
|
|
3714
3977
|
|
|
3715
3978
|
|
|
@@ -3784,6 +4047,13 @@ var directedGraphTyped = (() => {
|
|
|
3784
4047
|
|
|
3785
4048
|
|
|
3786
4049
|
|
|
4050
|
+
|
|
4051
|
+
|
|
4052
|
+
|
|
4053
|
+
|
|
4054
|
+
|
|
4055
|
+
|
|
4056
|
+
|
|
3787
4057
|
|
|
3788
4058
|
|
|
3789
4059
|
|
|
@@ -3835,6 +4105,13 @@ var directedGraphTyped = (() => {
|
|
|
3835
4105
|
|
|
3836
4106
|
|
|
3837
4107
|
|
|
4108
|
+
|
|
4109
|
+
|
|
4110
|
+
|
|
4111
|
+
|
|
4112
|
+
|
|
4113
|
+
|
|
4114
|
+
|
|
3838
4115
|
|
|
3839
4116
|
|
|
3840
4117
|
|
|
@@ -3939,6 +4216,13 @@ var directedGraphTyped = (() => {
|
|
|
3939
4216
|
|
|
3940
4217
|
|
|
3941
4218
|
|
|
4219
|
+
|
|
4220
|
+
|
|
4221
|
+
|
|
4222
|
+
|
|
4223
|
+
|
|
4224
|
+
|
|
4225
|
+
|
|
3942
4226
|
|
|
3943
4227
|
|
|
3944
4228
|
|
|
@@ -4024,6 +4308,13 @@ var directedGraphTyped = (() => {
|
|
|
4024
4308
|
|
|
4025
4309
|
|
|
4026
4310
|
|
|
4311
|
+
|
|
4312
|
+
|
|
4313
|
+
|
|
4314
|
+
|
|
4315
|
+
|
|
4316
|
+
|
|
4317
|
+
|
|
4027
4318
|
|
|
4028
4319
|
|
|
4029
4320
|
|
|
@@ -4071,6 +4362,13 @@ var directedGraphTyped = (() => {
|
|
|
4071
4362
|
|
|
4072
4363
|
|
|
4073
4364
|
|
|
4365
|
+
|
|
4366
|
+
|
|
4367
|
+
|
|
4368
|
+
|
|
4369
|
+
|
|
4370
|
+
|
|
4371
|
+
|
|
4074
4372
|
|
|
4075
4373
|
|
|
4076
4374
|
|
|
@@ -4171,6 +4469,13 @@ var directedGraphTyped = (() => {
|
|
|
4171
4469
|
|
|
4172
4470
|
|
|
4173
4471
|
|
|
4472
|
+
|
|
4473
|
+
|
|
4474
|
+
|
|
4475
|
+
|
|
4476
|
+
|
|
4477
|
+
|
|
4478
|
+
|
|
4174
4479
|
|
|
4175
4480
|
|
|
4176
4481
|
|
|
@@ -4274,6 +4579,13 @@ var directedGraphTyped = (() => {
|
|
|
4274
4579
|
|
|
4275
4580
|
|
|
4276
4581
|
|
|
4582
|
+
|
|
4583
|
+
|
|
4584
|
+
|
|
4585
|
+
|
|
4586
|
+
|
|
4587
|
+
|
|
4588
|
+
|
|
4277
4589
|
|
|
4278
4590
|
|
|
4279
4591
|
|