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/cjs/index.cjs
CHANGED
|
@@ -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
|
|
@@ -273,7 +279,7 @@ var IterableElementBase = class {
|
|
|
273
279
|
if (options) {
|
|
274
280
|
const { toElementFn } = options;
|
|
275
281
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
276
|
-
else if (toElementFn)
|
|
282
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
277
283
|
}
|
|
278
284
|
}
|
|
279
285
|
/**
|
|
@@ -436,7 +442,7 @@ var IterableElementBase = class {
|
|
|
436
442
|
acc = initialValue;
|
|
437
443
|
} else {
|
|
438
444
|
const first = iter.next();
|
|
439
|
-
if (first.done)
|
|
445
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
440
446
|
acc = first.value;
|
|
441
447
|
index = 1;
|
|
442
448
|
}
|
|
@@ -729,6 +735,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
729
735
|
|
|
730
736
|
|
|
731
737
|
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
732
745
|
|
|
733
746
|
|
|
734
747
|
|
|
@@ -785,7 +798,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
785
798
|
}
|
|
786
799
|
/**
|
|
787
800
|
* Insert an element.
|
|
788
|
-
* @remarks Time O(
|
|
801
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
789
802
|
* @param element - Element to insert.
|
|
790
803
|
* @returns True.
|
|
791
804
|
|
|
@@ -812,6 +825,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
812
825
|
|
|
813
826
|
|
|
814
827
|
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
815
835
|
|
|
816
836
|
|
|
817
837
|
|
|
@@ -866,6 +886,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
866
886
|
|
|
867
887
|
|
|
868
888
|
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
869
896
|
|
|
870
897
|
|
|
871
898
|
|
|
@@ -923,6 +950,12 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
923
950
|
|
|
924
951
|
|
|
925
952
|
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
926
959
|
|
|
927
960
|
|
|
928
961
|
|
|
@@ -930,6 +963,34 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
930
963
|
|
|
931
964
|
|
|
932
965
|
|
|
966
|
+
* @example
|
|
967
|
+
* // Heap with custom comparator (MaxHeap behavior)
|
|
968
|
+
* interface Task {
|
|
969
|
+
* id: number;
|
|
970
|
+
* priority: number;
|
|
971
|
+
* name: string;
|
|
972
|
+
* }
|
|
973
|
+
*
|
|
974
|
+
* // Custom comparator for max heap behavior (higher priority first)
|
|
975
|
+
* const tasks: Task[] = [
|
|
976
|
+
* { id: 1, priority: 5, name: 'Email' },
|
|
977
|
+
* { id: 2, priority: 3, name: 'Chat' },
|
|
978
|
+
* { id: 3, priority: 8, name: 'Alert' }
|
|
979
|
+
* ];
|
|
980
|
+
*
|
|
981
|
+
* const maxHeap = new Heap(tasks, {
|
|
982
|
+
* comparator: (a: Task, b: Task) => b.priority - a.priority
|
|
983
|
+
* });
|
|
984
|
+
*
|
|
985
|
+
* console.log(maxHeap.size); // 3;
|
|
986
|
+
*
|
|
987
|
+
* // Peek returns highest priority task
|
|
988
|
+
* const topTask = maxHeap.peek();
|
|
989
|
+
* console.log(topTask?.priority); // 8;
|
|
990
|
+
* console.log(topTask?.name); // 'Alert';
|
|
991
|
+
*/
|
|
992
|
+
/**
|
|
993
|
+
* @deprecated Use `pop` instead. Will be removed in a future major version.
|
|
933
994
|
* @example
|
|
934
995
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
935
996
|
* interface Task {
|
|
@@ -957,6 +1018,14 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
957
1018
|
* console.log(topTask?.name); // 'Alert';
|
|
958
1019
|
*/
|
|
959
1020
|
poll() {
|
|
1021
|
+
return this.pop();
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Remove and return the top element (min or max depending on comparator).
|
|
1025
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
1026
|
+
* @returns The removed top element, or undefined if empty.
|
|
1027
|
+
*/
|
|
1028
|
+
pop() {
|
|
960
1029
|
if (this.elements.length === 0) return;
|
|
961
1030
|
const value = this.elements[0];
|
|
962
1031
|
const last = this.elements.pop();
|
|
@@ -994,6 +1063,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
994
1063
|
|
|
995
1064
|
|
|
996
1065
|
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
997
1073
|
|
|
998
1074
|
|
|
999
1075
|
|
|
@@ -1091,6 +1167,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1091
1167
|
|
|
1092
1168
|
|
|
1093
1169
|
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
|
|
1094
1177
|
|
|
1095
1178
|
|
|
1096
1179
|
|
|
@@ -1135,6 +1218,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1135
1218
|
|
|
1136
1219
|
|
|
1137
1220
|
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
|
|
1138
1228
|
|
|
1139
1229
|
|
|
1140
1230
|
|
|
@@ -1152,16 +1242,6 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1152
1242
|
clear() {
|
|
1153
1243
|
this._elements = [];
|
|
1154
1244
|
}
|
|
1155
|
-
/**
|
|
1156
|
-
* Replace the backing array and rebuild the heap.
|
|
1157
|
-
* @remarks Time O(N), Space O(N)
|
|
1158
|
-
* @param elements - Iterable used to refill the heap.
|
|
1159
|
-
* @returns Array of per-node results from fixing steps.
|
|
1160
|
-
*/
|
|
1161
|
-
refill(elements) {
|
|
1162
|
-
this._elements = Array.from(elements);
|
|
1163
|
-
return this.fix();
|
|
1164
|
-
}
|
|
1165
1245
|
/**
|
|
1166
1246
|
* Check if an equal element exists in the heap.
|
|
1167
1247
|
* @remarks Time O(N), Space O(1)
|
|
@@ -1182,6 +1262,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1182
1262
|
|
|
1183
1263
|
|
|
1184
1264
|
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
|
|
1271
|
+
|
|
1185
1272
|
|
|
1186
1273
|
|
|
1187
1274
|
|
|
@@ -1226,6 +1313,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1226
1313
|
|
|
1227
1314
|
|
|
1228
1315
|
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
|
|
1229
1323
|
|
|
1230
1324
|
|
|
1231
1325
|
|
|
@@ -1250,7 +1344,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1250
1344
|
}
|
|
1251
1345
|
if (index < 0) return false;
|
|
1252
1346
|
if (index === 0) {
|
|
1253
|
-
this.
|
|
1347
|
+
this.pop();
|
|
1254
1348
|
} else if (index === this.elements.length - 1) {
|
|
1255
1349
|
this.elements.pop();
|
|
1256
1350
|
} else {
|
|
@@ -1260,13 +1354,19 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1260
1354
|
}
|
|
1261
1355
|
return true;
|
|
1262
1356
|
}
|
|
1357
|
+
/**
|
|
1358
|
+
* @deprecated Use `deleteWhere` instead. Will be removed in a future major version.
|
|
1359
|
+
*/
|
|
1360
|
+
deleteBy(predicate) {
|
|
1361
|
+
return this.deleteWhere(predicate);
|
|
1362
|
+
}
|
|
1263
1363
|
/**
|
|
1264
1364
|
* Delete the first element that matches a predicate.
|
|
1265
1365
|
* @remarks Time O(N), Space O(1)
|
|
1266
1366
|
* @param predicate - Function (element, index, heap) → boolean.
|
|
1267
1367
|
* @returns True if an element was removed.
|
|
1268
1368
|
*/
|
|
1269
|
-
|
|
1369
|
+
deleteWhere(predicate) {
|
|
1270
1370
|
let idx = -1;
|
|
1271
1371
|
for (let i = 0; i < this.elements.length; i++) {
|
|
1272
1372
|
if (predicate(this.elements[i], i, this)) {
|
|
@@ -1276,7 +1376,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1276
1376
|
}
|
|
1277
1377
|
if (idx < 0) return false;
|
|
1278
1378
|
if (idx === 0) {
|
|
1279
|
-
this.
|
|
1379
|
+
this.pop();
|
|
1280
1380
|
} else if (idx === this.elements.length - 1) {
|
|
1281
1381
|
this.elements.pop();
|
|
1282
1382
|
} else {
|
|
@@ -1316,6 +1416,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1316
1416
|
|
|
1317
1417
|
|
|
1318
1418
|
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1319
1426
|
|
|
1320
1427
|
|
|
1321
1428
|
|
|
@@ -1393,6 +1500,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1393
1500
|
|
|
1394
1501
|
|
|
1395
1502
|
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
|
|
1396
1510
|
|
|
1397
1511
|
|
|
1398
1512
|
|
|
@@ -1443,6 +1557,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1443
1557
|
|
|
1444
1558
|
|
|
1445
1559
|
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
|
|
1563
|
+
|
|
1564
|
+
|
|
1565
|
+
|
|
1566
|
+
|
|
1446
1567
|
|
|
1447
1568
|
|
|
1448
1569
|
|
|
@@ -1492,6 +1613,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1492
1613
|
|
|
1493
1614
|
|
|
1494
1615
|
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
|
|
1495
1623
|
|
|
1496
1624
|
|
|
1497
1625
|
|
|
@@ -1548,6 +1676,13 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1548
1676
|
|
|
1549
1677
|
|
|
1550
1678
|
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
|
|
1682
|
+
|
|
1683
|
+
|
|
1684
|
+
|
|
1685
|
+
|
|
1551
1686
|
|
|
1552
1687
|
|
|
1553
1688
|
|
|
@@ -1564,7 +1699,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1564
1699
|
*/
|
|
1565
1700
|
map(callback, options, thisArg) {
|
|
1566
1701
|
const { comparator, toElementFn, ...rest } = options ?? {};
|
|
1567
|
-
if (!comparator)
|
|
1702
|
+
if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
|
|
1568
1703
|
const out = this._createLike([], { ...rest, comparator, toElementFn });
|
|
1569
1704
|
let i = 0;
|
|
1570
1705
|
for (const x of this) {
|
|
@@ -1591,7 +1726,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1591
1726
|
}
|
|
1592
1727
|
_DEFAULT_COMPARATOR = /* @__PURE__ */ __name((a, b) => {
|
|
1593
1728
|
if (typeof a === "object" || typeof b === "object") {
|
|
1594
|
-
|
|
1729
|
+
raise(TypeError, ERR.comparatorRequired("Heap"));
|
|
1595
1730
|
}
|
|
1596
1731
|
if (a > b) return 1;
|
|
1597
1732
|
if (a < b) return -1;
|
|
@@ -1758,6 +1893,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1758
1893
|
|
|
1759
1894
|
|
|
1760
1895
|
|
|
1896
|
+
|
|
1897
|
+
|
|
1898
|
+
|
|
1899
|
+
|
|
1900
|
+
|
|
1901
|
+
|
|
1902
|
+
|
|
1761
1903
|
|
|
1762
1904
|
|
|
1763
1905
|
|
|
@@ -1805,6 +1947,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1805
1947
|
|
|
1806
1948
|
|
|
1807
1949
|
|
|
1950
|
+
|
|
1951
|
+
|
|
1952
|
+
|
|
1953
|
+
|
|
1954
|
+
|
|
1955
|
+
|
|
1956
|
+
|
|
1808
1957
|
|
|
1809
1958
|
|
|
1810
1959
|
|
|
@@ -1822,6 +1971,14 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1822
1971
|
get first() {
|
|
1823
1972
|
return this.length > 0 ? this.elements[this._offset] : void 0;
|
|
1824
1973
|
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
1976
|
+
* @remarks Time O(1), Space O(1)
|
|
1977
|
+
* @returns Front element or undefined.
|
|
1978
|
+
*/
|
|
1979
|
+
peek() {
|
|
1980
|
+
return this.first;
|
|
1981
|
+
}
|
|
1825
1982
|
/**
|
|
1826
1983
|
* Get the last element (back) without removing it.
|
|
1827
1984
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1868,6 +2025,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1868
2025
|
|
|
1869
2026
|
|
|
1870
2027
|
|
|
2028
|
+
|
|
2029
|
+
|
|
2030
|
+
|
|
2031
|
+
|
|
2032
|
+
|
|
2033
|
+
|
|
2034
|
+
|
|
1871
2035
|
|
|
1872
2036
|
|
|
1873
2037
|
|
|
@@ -1927,6 +2091,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1927
2091
|
|
|
1928
2092
|
|
|
1929
2093
|
|
|
2094
|
+
|
|
2095
|
+
|
|
2096
|
+
|
|
2097
|
+
|
|
2098
|
+
|
|
2099
|
+
|
|
2100
|
+
|
|
1930
2101
|
|
|
1931
2102
|
|
|
1932
2103
|
|
|
@@ -1993,6 +2164,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1993
2164
|
|
|
1994
2165
|
|
|
1995
2166
|
|
|
2167
|
+
|
|
2168
|
+
|
|
2169
|
+
|
|
2170
|
+
|
|
2171
|
+
|
|
2172
|
+
|
|
2173
|
+
|
|
1996
2174
|
|
|
1997
2175
|
|
|
1998
2176
|
|
|
@@ -2049,6 +2227,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2049
2227
|
|
|
2050
2228
|
|
|
2051
2229
|
|
|
2230
|
+
|
|
2231
|
+
|
|
2232
|
+
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
|
|
2052
2237
|
|
|
2053
2238
|
|
|
2054
2239
|
|
|
@@ -2098,6 +2283,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2098
2283
|
|
|
2099
2284
|
|
|
2100
2285
|
|
|
2286
|
+
|
|
2287
|
+
|
|
2288
|
+
|
|
2289
|
+
|
|
2290
|
+
|
|
2291
|
+
|
|
2292
|
+
|
|
2101
2293
|
|
|
2102
2294
|
|
|
2103
2295
|
|
|
@@ -2152,6 +2344,21 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2152
2344
|
this._elements[this._offset + index] = newElement;
|
|
2153
2345
|
return true;
|
|
2154
2346
|
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Delete the first element that satisfies a predicate.
|
|
2349
|
+
* @remarks Time O(N), Space O(N)
|
|
2350
|
+
* @param predicate - Function (value, index, queue) → boolean to decide deletion.
|
|
2351
|
+
* @returns True if a match was removed.
|
|
2352
|
+
*/
|
|
2353
|
+
deleteWhere(predicate) {
|
|
2354
|
+
for (let i = 0; i < this.length; i++) {
|
|
2355
|
+
if (predicate(this._elements[this._offset + i], i, this)) {
|
|
2356
|
+
this.deleteAt(i);
|
|
2357
|
+
return true;
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
return false;
|
|
2361
|
+
}
|
|
2155
2362
|
/**
|
|
2156
2363
|
* Reverse the queue in-place by compacting then reversing.
|
|
2157
2364
|
* @remarks Time O(N), Space O(N)
|
|
@@ -2188,6 +2395,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2188
2395
|
|
|
2189
2396
|
|
|
2190
2397
|
|
|
2398
|
+
|
|
2399
|
+
|
|
2400
|
+
|
|
2401
|
+
|
|
2402
|
+
|
|
2403
|
+
|
|
2404
|
+
|
|
2191
2405
|
|
|
2192
2406
|
|
|
2193
2407
|
|
|
@@ -2231,6 +2445,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2231
2445
|
|
|
2232
2446
|
|
|
2233
2447
|
|
|
2448
|
+
|
|
2449
|
+
|
|
2450
|
+
|
|
2451
|
+
|
|
2452
|
+
|
|
2453
|
+
|
|
2454
|
+
|
|
2234
2455
|
|
|
2235
2456
|
|
|
2236
2457
|
|
|
@@ -2297,6 +2518,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2297
2518
|
|
|
2298
2519
|
|
|
2299
2520
|
|
|
2521
|
+
|
|
2522
|
+
|
|
2523
|
+
|
|
2524
|
+
|
|
2525
|
+
|
|
2526
|
+
|
|
2527
|
+
|
|
2300
2528
|
|
|
2301
2529
|
|
|
2302
2530
|
|
|
@@ -2347,6 +2575,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2347
2575
|
|
|
2348
2576
|
|
|
2349
2577
|
|
|
2578
|
+
|
|
2579
|
+
|
|
2580
|
+
|
|
2581
|
+
|
|
2582
|
+
|
|
2583
|
+
|
|
2584
|
+
|
|
2350
2585
|
|
|
2351
2586
|
|
|
2352
2587
|
|
|
@@ -2401,6 +2636,13 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2401
2636
|
|
|
2402
2637
|
|
|
2403
2638
|
|
|
2639
|
+
|
|
2640
|
+
|
|
2641
|
+
|
|
2642
|
+
|
|
2643
|
+
|
|
2644
|
+
|
|
2645
|
+
|
|
2404
2646
|
|
|
2405
2647
|
|
|
2406
2648
|
|
|
@@ -2644,7 +2886,7 @@ var AbstractGraph = class extends IterableEntryBase {
|
|
|
2644
2886
|
const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
|
|
2645
2887
|
return this._addEdge(newEdge);
|
|
2646
2888
|
} else {
|
|
2647
|
-
|
|
2889
|
+
raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
|
|
2648
2890
|
}
|
|
2649
2891
|
}
|
|
2650
2892
|
}
|
|
@@ -3537,6 +3779,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3537
3779
|
|
|
3538
3780
|
|
|
3539
3781
|
|
|
3782
|
+
|
|
3783
|
+
|
|
3784
|
+
|
|
3785
|
+
|
|
3786
|
+
|
|
3787
|
+
|
|
3788
|
+
|
|
3540
3789
|
|
|
3541
3790
|
|
|
3542
3791
|
|
|
@@ -3622,6 +3871,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3622
3871
|
|
|
3623
3872
|
|
|
3624
3873
|
|
|
3874
|
+
|
|
3875
|
+
|
|
3876
|
+
|
|
3877
|
+
|
|
3878
|
+
|
|
3879
|
+
|
|
3880
|
+
|
|
3625
3881
|
|
|
3626
3882
|
|
|
3627
3883
|
|
|
@@ -3705,6 +3961,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3705
3961
|
|
|
3706
3962
|
|
|
3707
3963
|
|
|
3964
|
+
|
|
3965
|
+
|
|
3966
|
+
|
|
3967
|
+
|
|
3968
|
+
|
|
3969
|
+
|
|
3970
|
+
|
|
3708
3971
|
|
|
3709
3972
|
|
|
3710
3973
|
|
|
@@ -3779,6 +4042,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3779
4042
|
|
|
3780
4043
|
|
|
3781
4044
|
|
|
4045
|
+
|
|
4046
|
+
|
|
4047
|
+
|
|
4048
|
+
|
|
4049
|
+
|
|
4050
|
+
|
|
4051
|
+
|
|
3782
4052
|
|
|
3783
4053
|
|
|
3784
4054
|
|
|
@@ -3830,6 +4100,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3830
4100
|
|
|
3831
4101
|
|
|
3832
4102
|
|
|
4103
|
+
|
|
4104
|
+
|
|
4105
|
+
|
|
4106
|
+
|
|
4107
|
+
|
|
4108
|
+
|
|
4109
|
+
|
|
3833
4110
|
|
|
3834
4111
|
|
|
3835
4112
|
|
|
@@ -3934,6 +4211,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3934
4211
|
|
|
3935
4212
|
|
|
3936
4213
|
|
|
4214
|
+
|
|
4215
|
+
|
|
4216
|
+
|
|
4217
|
+
|
|
4218
|
+
|
|
4219
|
+
|
|
4220
|
+
|
|
3937
4221
|
|
|
3938
4222
|
|
|
3939
4223
|
|
|
@@ -4019,6 +4303,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4019
4303
|
|
|
4020
4304
|
|
|
4021
4305
|
|
|
4306
|
+
|
|
4307
|
+
|
|
4308
|
+
|
|
4309
|
+
|
|
4310
|
+
|
|
4311
|
+
|
|
4312
|
+
|
|
4022
4313
|
|
|
4023
4314
|
|
|
4024
4315
|
|
|
@@ -4066,6 +4357,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4066
4357
|
|
|
4067
4358
|
|
|
4068
4359
|
|
|
4360
|
+
|
|
4361
|
+
|
|
4362
|
+
|
|
4363
|
+
|
|
4364
|
+
|
|
4365
|
+
|
|
4366
|
+
|
|
4069
4367
|
|
|
4070
4368
|
|
|
4071
4369
|
|
|
@@ -4166,6 +4464,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4166
4464
|
|
|
4167
4465
|
|
|
4168
4466
|
|
|
4467
|
+
|
|
4468
|
+
|
|
4469
|
+
|
|
4470
|
+
|
|
4471
|
+
|
|
4472
|
+
|
|
4473
|
+
|
|
4169
4474
|
|
|
4170
4475
|
|
|
4171
4476
|
|
|
@@ -4269,6 +4574,13 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4269
4574
|
|
|
4270
4575
|
|
|
4271
4576
|
|
|
4577
|
+
|
|
4578
|
+
|
|
4579
|
+
|
|
4580
|
+
|
|
4581
|
+
|
|
4582
|
+
|
|
4583
|
+
|
|
4272
4584
|
|
|
4273
4585
|
|
|
4274
4586
|
|
|
@@ -4340,5 +4652,6 @@ exports.DirectedGraph = DirectedGraph;
|
|
|
4340
4652
|
exports.DirectedVertex = DirectedVertex;
|
|
4341
4653
|
exports.ERR = ERR;
|
|
4342
4654
|
exports.Range = Range;
|
|
4655
|
+
exports.raise = raise;
|
|
4343
4656
|
//# sourceMappingURL=index.cjs.map
|
|
4344
4657
|
//# sourceMappingURL=index.cjs.map
|