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 +396 -20
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +396 -20
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +396 -21
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +396 -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/graph-typed.js +396 -21
- package/dist/umd/graph-typed.js.map +1 -1
- package/dist/umd/graph-typed.min.js +2 -2
- package/dist/umd/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
|
@@ -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)
|
|
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)
|
|
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
|
-
|
|
693
|
+
raise(TypeError, ERR.comparatorRequired("Heap"));
|
|
688
694
|
}
|
|
689
695
|
if (a > b) return 1;
|
|
690
696
|
if (a < b) return -1;
|
|
@@ -733,6 +739,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
733
739
|
|
|
734
740
|
|
|
735
741
|
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
736
749
|
|
|
737
750
|
|
|
738
751
|
|
|
@@ -790,7 +803,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
790
803
|
}
|
|
791
804
|
/**
|
|
792
805
|
* Insert an element.
|
|
793
|
-
* @remarks Time O(
|
|
806
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
794
807
|
* @param element - Element to insert.
|
|
795
808
|
* @returns True.
|
|
796
809
|
|
|
@@ -817,6 +830,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
817
830
|
|
|
818
831
|
|
|
819
832
|
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
820
840
|
|
|
821
841
|
|
|
822
842
|
|
|
@@ -871,6 +891,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
871
891
|
|
|
872
892
|
|
|
873
893
|
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
874
901
|
|
|
875
902
|
|
|
876
903
|
|
|
@@ -928,6 +955,12 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
928
955
|
|
|
929
956
|
|
|
930
957
|
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
931
964
|
|
|
932
965
|
|
|
933
966
|
|
|
@@ -935,6 +968,34 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
935
968
|
|
|
936
969
|
|
|
937
970
|
|
|
971
|
+
* @example
|
|
972
|
+
* // Heap with custom comparator (MaxHeap behavior)
|
|
973
|
+
* interface Task {
|
|
974
|
+
* id: number;
|
|
975
|
+
* priority: number;
|
|
976
|
+
* name: string;
|
|
977
|
+
* }
|
|
978
|
+
*
|
|
979
|
+
* // Custom comparator for max heap behavior (higher priority first)
|
|
980
|
+
* const tasks: Task[] = [
|
|
981
|
+
* { id: 1, priority: 5, name: 'Email' },
|
|
982
|
+
* { id: 2, priority: 3, name: 'Chat' },
|
|
983
|
+
* { id: 3, priority: 8, name: 'Alert' }
|
|
984
|
+
* ];
|
|
985
|
+
*
|
|
986
|
+
* const maxHeap = new Heap(tasks, {
|
|
987
|
+
* comparator: (a: Task, b: Task) => b.priority - a.priority
|
|
988
|
+
* });
|
|
989
|
+
*
|
|
990
|
+
* console.log(maxHeap.size); // 3;
|
|
991
|
+
*
|
|
992
|
+
* // Peek returns highest priority task
|
|
993
|
+
* const topTask = maxHeap.peek();
|
|
994
|
+
* console.log(topTask?.priority); // 8;
|
|
995
|
+
* console.log(topTask?.name); // 'Alert';
|
|
996
|
+
*/
|
|
997
|
+
/**
|
|
998
|
+
* @deprecated Use `pop` instead. Will be removed in a future major version.
|
|
938
999
|
* @example
|
|
939
1000
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
940
1001
|
* interface Task {
|
|
@@ -962,6 +1023,14 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
962
1023
|
* console.log(topTask?.name); // 'Alert';
|
|
963
1024
|
*/
|
|
964
1025
|
poll() {
|
|
1026
|
+
return this.pop();
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Remove and return the top element (min or max depending on comparator).
|
|
1030
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
1031
|
+
* @returns The removed top element, or undefined if empty.
|
|
1032
|
+
*/
|
|
1033
|
+
pop() {
|
|
965
1034
|
if (this.elements.length === 0) return;
|
|
966
1035
|
const value = this.elements[0];
|
|
967
1036
|
const last = this.elements.pop();
|
|
@@ -999,6 +1068,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
999
1068
|
|
|
1000
1069
|
|
|
1001
1070
|
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1002
1078
|
|
|
1003
1079
|
|
|
1004
1080
|
|
|
@@ -1096,6 +1172,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1096
1172
|
|
|
1097
1173
|
|
|
1098
1174
|
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
|
|
1181
|
+
|
|
1099
1182
|
|
|
1100
1183
|
|
|
1101
1184
|
|
|
@@ -1140,6 +1223,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1140
1223
|
|
|
1141
1224
|
|
|
1142
1225
|
|
|
1226
|
+
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
|
|
1143
1233
|
|
|
1144
1234
|
|
|
1145
1235
|
|
|
@@ -1157,16 +1247,6 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1157
1247
|
clear() {
|
|
1158
1248
|
this._elements = [];
|
|
1159
1249
|
}
|
|
1160
|
-
/**
|
|
1161
|
-
* Replace the backing array and rebuild the heap.
|
|
1162
|
-
* @remarks Time O(N), Space O(N)
|
|
1163
|
-
* @param elements - Iterable used to refill the heap.
|
|
1164
|
-
* @returns Array of per-node results from fixing steps.
|
|
1165
|
-
*/
|
|
1166
|
-
refill(elements) {
|
|
1167
|
-
this._elements = Array.from(elements);
|
|
1168
|
-
return this.fix();
|
|
1169
|
-
}
|
|
1170
1250
|
/**
|
|
1171
1251
|
* Check if an equal element exists in the heap.
|
|
1172
1252
|
* @remarks Time O(N), Space O(1)
|
|
@@ -1187,6 +1267,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1187
1267
|
|
|
1188
1268
|
|
|
1189
1269
|
|
|
1270
|
+
|
|
1271
|
+
|
|
1272
|
+
|
|
1273
|
+
|
|
1274
|
+
|
|
1275
|
+
|
|
1276
|
+
|
|
1190
1277
|
|
|
1191
1278
|
|
|
1192
1279
|
|
|
@@ -1231,6 +1318,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1231
1318
|
|
|
1232
1319
|
|
|
1233
1320
|
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
|
|
1326
|
+
|
|
1327
|
+
|
|
1234
1328
|
|
|
1235
1329
|
|
|
1236
1330
|
|
|
@@ -1255,7 +1349,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1255
1349
|
}
|
|
1256
1350
|
if (index < 0) return false;
|
|
1257
1351
|
if (index === 0) {
|
|
1258
|
-
this.
|
|
1352
|
+
this.pop();
|
|
1259
1353
|
} else if (index === this.elements.length - 1) {
|
|
1260
1354
|
this.elements.pop();
|
|
1261
1355
|
} else {
|
|
@@ -1265,13 +1359,19 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1265
1359
|
}
|
|
1266
1360
|
return true;
|
|
1267
1361
|
}
|
|
1362
|
+
/**
|
|
1363
|
+
* @deprecated Use `deleteWhere` instead. Will be removed in a future major version.
|
|
1364
|
+
*/
|
|
1365
|
+
deleteBy(predicate) {
|
|
1366
|
+
return this.deleteWhere(predicate);
|
|
1367
|
+
}
|
|
1268
1368
|
/**
|
|
1269
1369
|
* Delete the first element that matches a predicate.
|
|
1270
1370
|
* @remarks Time O(N), Space O(1)
|
|
1271
1371
|
* @param predicate - Function (element, index, heap) → boolean.
|
|
1272
1372
|
* @returns True if an element was removed.
|
|
1273
1373
|
*/
|
|
1274
|
-
|
|
1374
|
+
deleteWhere(predicate) {
|
|
1275
1375
|
let idx = -1;
|
|
1276
1376
|
for (let i = 0; i < this.elements.length; i++) {
|
|
1277
1377
|
if (predicate(this.elements[i], i, this)) {
|
|
@@ -1281,7 +1381,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1281
1381
|
}
|
|
1282
1382
|
if (idx < 0) return false;
|
|
1283
1383
|
if (idx === 0) {
|
|
1284
|
-
this.
|
|
1384
|
+
this.pop();
|
|
1285
1385
|
} else if (idx === this.elements.length - 1) {
|
|
1286
1386
|
this.elements.pop();
|
|
1287
1387
|
} else {
|
|
@@ -1321,6 +1421,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1321
1421
|
|
|
1322
1422
|
|
|
1323
1423
|
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
|
|
1324
1431
|
|
|
1325
1432
|
|
|
1326
1433
|
|
|
@@ -1398,6 +1505,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1398
1505
|
|
|
1399
1506
|
|
|
1400
1507
|
|
|
1508
|
+
|
|
1509
|
+
|
|
1510
|
+
|
|
1511
|
+
|
|
1512
|
+
|
|
1513
|
+
|
|
1514
|
+
|
|
1401
1515
|
|
|
1402
1516
|
|
|
1403
1517
|
|
|
@@ -1448,6 +1562,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1448
1562
|
|
|
1449
1563
|
|
|
1450
1564
|
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
|
|
1571
|
+
|
|
1451
1572
|
|
|
1452
1573
|
|
|
1453
1574
|
|
|
@@ -1497,6 +1618,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1497
1618
|
|
|
1498
1619
|
|
|
1499
1620
|
|
|
1621
|
+
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
|
|
1500
1628
|
|
|
1501
1629
|
|
|
1502
1630
|
|
|
@@ -1553,6 +1681,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1553
1681
|
|
|
1554
1682
|
|
|
1555
1683
|
|
|
1684
|
+
|
|
1685
|
+
|
|
1686
|
+
|
|
1687
|
+
|
|
1688
|
+
|
|
1689
|
+
|
|
1690
|
+
|
|
1556
1691
|
|
|
1557
1692
|
|
|
1558
1693
|
|
|
@@ -1569,7 +1704,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1569
1704
|
*/
|
|
1570
1705
|
map(callback, options, thisArg) {
|
|
1571
1706
|
const { comparator, toElementFn, ...rest } = options != null ? options : {};
|
|
1572
|
-
if (!comparator)
|
|
1707
|
+
if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
|
|
1573
1708
|
const out = this._createLike([], { ...rest, comparator, toElementFn });
|
|
1574
1709
|
let i = 0;
|
|
1575
1710
|
for (const x of this) {
|
|
@@ -1753,6 +1888,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1753
1888
|
|
|
1754
1889
|
|
|
1755
1890
|
|
|
1891
|
+
|
|
1892
|
+
|
|
1893
|
+
|
|
1894
|
+
|
|
1895
|
+
|
|
1896
|
+
|
|
1897
|
+
|
|
1756
1898
|
|
|
1757
1899
|
|
|
1758
1900
|
|
|
@@ -1800,6 +1942,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1800
1942
|
|
|
1801
1943
|
|
|
1802
1944
|
|
|
1945
|
+
|
|
1946
|
+
|
|
1947
|
+
|
|
1948
|
+
|
|
1949
|
+
|
|
1950
|
+
|
|
1951
|
+
|
|
1803
1952
|
|
|
1804
1953
|
|
|
1805
1954
|
|
|
@@ -1817,6 +1966,14 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1817
1966
|
get first() {
|
|
1818
1967
|
return this.length > 0 ? this.elements[this._offset] : void 0;
|
|
1819
1968
|
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
1971
|
+
* @remarks Time O(1), Space O(1)
|
|
1972
|
+
* @returns Front element or undefined.
|
|
1973
|
+
*/
|
|
1974
|
+
peek() {
|
|
1975
|
+
return this.first;
|
|
1976
|
+
}
|
|
1820
1977
|
/**
|
|
1821
1978
|
* Get the last element (back) without removing it.
|
|
1822
1979
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1863,6 +2020,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1863
2020
|
|
|
1864
2021
|
|
|
1865
2022
|
|
|
2023
|
+
|
|
2024
|
+
|
|
2025
|
+
|
|
2026
|
+
|
|
2027
|
+
|
|
2028
|
+
|
|
2029
|
+
|
|
1866
2030
|
|
|
1867
2031
|
|
|
1868
2032
|
|
|
@@ -1922,6 +2086,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1922
2086
|
|
|
1923
2087
|
|
|
1924
2088
|
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
|
|
2092
|
+
|
|
2093
|
+
|
|
2094
|
+
|
|
2095
|
+
|
|
1925
2096
|
|
|
1926
2097
|
|
|
1927
2098
|
|
|
@@ -1988,6 +2159,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1988
2159
|
|
|
1989
2160
|
|
|
1990
2161
|
|
|
2162
|
+
|
|
2163
|
+
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
|
|
2167
|
+
|
|
2168
|
+
|
|
1991
2169
|
|
|
1992
2170
|
|
|
1993
2171
|
|
|
@@ -2044,6 +2222,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2044
2222
|
|
|
2045
2223
|
|
|
2046
2224
|
|
|
2225
|
+
|
|
2226
|
+
|
|
2227
|
+
|
|
2228
|
+
|
|
2229
|
+
|
|
2230
|
+
|
|
2231
|
+
|
|
2047
2232
|
|
|
2048
2233
|
|
|
2049
2234
|
|
|
@@ -2093,6 +2278,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2093
2278
|
|
|
2094
2279
|
|
|
2095
2280
|
|
|
2281
|
+
|
|
2282
|
+
|
|
2283
|
+
|
|
2284
|
+
|
|
2285
|
+
|
|
2286
|
+
|
|
2287
|
+
|
|
2096
2288
|
|
|
2097
2289
|
|
|
2098
2290
|
|
|
@@ -2147,6 +2339,21 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2147
2339
|
this._elements[this._offset + index] = newElement;
|
|
2148
2340
|
return true;
|
|
2149
2341
|
}
|
|
2342
|
+
/**
|
|
2343
|
+
* Delete the first element that satisfies a predicate.
|
|
2344
|
+
* @remarks Time O(N), Space O(N)
|
|
2345
|
+
* @param predicate - Function (value, index, queue) → boolean to decide deletion.
|
|
2346
|
+
* @returns True if a match was removed.
|
|
2347
|
+
*/
|
|
2348
|
+
deleteWhere(predicate) {
|
|
2349
|
+
for (let i = 0; i < this.length; i++) {
|
|
2350
|
+
if (predicate(this._elements[this._offset + i], i, this)) {
|
|
2351
|
+
this.deleteAt(i);
|
|
2352
|
+
return true;
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
return false;
|
|
2356
|
+
}
|
|
2150
2357
|
/**
|
|
2151
2358
|
* Reverse the queue in-place by compacting then reversing.
|
|
2152
2359
|
* @remarks Time O(N), Space O(N)
|
|
@@ -2183,6 +2390,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2183
2390
|
|
|
2184
2391
|
|
|
2185
2392
|
|
|
2393
|
+
|
|
2394
|
+
|
|
2395
|
+
|
|
2396
|
+
|
|
2397
|
+
|
|
2398
|
+
|
|
2399
|
+
|
|
2186
2400
|
|
|
2187
2401
|
|
|
2188
2402
|
|
|
@@ -2226,6 +2440,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2226
2440
|
|
|
2227
2441
|
|
|
2228
2442
|
|
|
2443
|
+
|
|
2444
|
+
|
|
2445
|
+
|
|
2446
|
+
|
|
2447
|
+
|
|
2448
|
+
|
|
2449
|
+
|
|
2229
2450
|
|
|
2230
2451
|
|
|
2231
2452
|
|
|
@@ -2292,6 +2513,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2292
2513
|
|
|
2293
2514
|
|
|
2294
2515
|
|
|
2516
|
+
|
|
2517
|
+
|
|
2518
|
+
|
|
2519
|
+
|
|
2520
|
+
|
|
2521
|
+
|
|
2522
|
+
|
|
2295
2523
|
|
|
2296
2524
|
|
|
2297
2525
|
|
|
@@ -2342,6 +2570,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2342
2570
|
|
|
2343
2571
|
|
|
2344
2572
|
|
|
2573
|
+
|
|
2574
|
+
|
|
2575
|
+
|
|
2576
|
+
|
|
2577
|
+
|
|
2578
|
+
|
|
2579
|
+
|
|
2345
2580
|
|
|
2346
2581
|
|
|
2347
2582
|
|
|
@@ -2396,6 +2631,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2396
2631
|
|
|
2397
2632
|
|
|
2398
2633
|
|
|
2634
|
+
|
|
2635
|
+
|
|
2636
|
+
|
|
2637
|
+
|
|
2638
|
+
|
|
2639
|
+
|
|
2640
|
+
|
|
2399
2641
|
|
|
2400
2642
|
|
|
2401
2643
|
|
|
@@ -2638,7 +2880,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
|
|
|
2638
2880
|
const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
|
|
2639
2881
|
return this._addEdge(newEdge);
|
|
2640
2882
|
} else {
|
|
2641
|
-
|
|
2883
|
+
raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
|
|
2642
2884
|
}
|
|
2643
2885
|
}
|
|
2644
2886
|
}
|
|
@@ -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
|
|
|
@@ -4434,6 +4746,13 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4434
4746
|
|
|
4435
4747
|
|
|
4436
4748
|
|
|
4749
|
+
|
|
4750
|
+
|
|
4751
|
+
|
|
4752
|
+
|
|
4753
|
+
|
|
4754
|
+
|
|
4755
|
+
|
|
4437
4756
|
|
|
4438
4757
|
|
|
4439
4758
|
|
|
@@ -4516,6 +4835,13 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4516
4835
|
|
|
4517
4836
|
|
|
4518
4837
|
|
|
4838
|
+
|
|
4839
|
+
|
|
4840
|
+
|
|
4841
|
+
|
|
4842
|
+
|
|
4843
|
+
|
|
4844
|
+
|
|
4519
4845
|
|
|
4520
4846
|
|
|
4521
4847
|
|
|
@@ -4597,6 +4923,13 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4597
4923
|
|
|
4598
4924
|
|
|
4599
4925
|
|
|
4926
|
+
|
|
4927
|
+
|
|
4928
|
+
|
|
4929
|
+
|
|
4930
|
+
|
|
4931
|
+
|
|
4932
|
+
|
|
4600
4933
|
|
|
4601
4934
|
|
|
4602
4935
|
|
|
@@ -4693,6 +5026,13 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4693
5026
|
|
|
4694
5027
|
|
|
4695
5028
|
|
|
5029
|
+
|
|
5030
|
+
|
|
5031
|
+
|
|
5032
|
+
|
|
5033
|
+
|
|
5034
|
+
|
|
5035
|
+
|
|
4696
5036
|
|
|
4697
5037
|
|
|
4698
5038
|
|
|
@@ -4744,6 +5084,13 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4744
5084
|
|
|
4745
5085
|
|
|
4746
5086
|
|
|
5087
|
+
|
|
5088
|
+
|
|
5089
|
+
|
|
5090
|
+
|
|
5091
|
+
|
|
5092
|
+
|
|
5093
|
+
|
|
4747
5094
|
|
|
4748
5095
|
|
|
4749
5096
|
|
|
@@ -4865,6 +5212,13 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4865
5212
|
|
|
4866
5213
|
|
|
4867
5214
|
|
|
5215
|
+
|
|
5216
|
+
|
|
5217
|
+
|
|
5218
|
+
|
|
5219
|
+
|
|
5220
|
+
|
|
5221
|
+
|
|
4868
5222
|
|
|
4869
5223
|
|
|
4870
5224
|
|
|
@@ -5008,6 +5362,13 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5008
5362
|
|
|
5009
5363
|
|
|
5010
5364
|
|
|
5365
|
+
|
|
5366
|
+
|
|
5367
|
+
|
|
5368
|
+
|
|
5369
|
+
|
|
5370
|
+
|
|
5371
|
+
|
|
5011
5372
|
|
|
5012
5373
|
|
|
5013
5374
|
|
|
@@ -5073,6 +5434,13 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5073
5434
|
|
|
5074
5435
|
|
|
5075
5436
|
|
|
5437
|
+
|
|
5438
|
+
|
|
5439
|
+
|
|
5440
|
+
|
|
5441
|
+
|
|
5442
|
+
|
|
5443
|
+
|
|
5076
5444
|
|
|
5077
5445
|
|
|
5078
5446
|
|
|
@@ -5120,6 +5488,13 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5120
5488
|
|
|
5121
5489
|
|
|
5122
5490
|
|
|
5491
|
+
|
|
5492
|
+
|
|
5493
|
+
|
|
5494
|
+
|
|
5495
|
+
|
|
5496
|
+
|
|
5497
|
+
|
|
5123
5498
|
|
|
5124
5499
|
|
|
5125
5500
|
|
|
@@ -5301,5 +5676,6 @@ exports.Range = Range;
|
|
|
5301
5676
|
exports.UndirectedEdge = UndirectedEdge;
|
|
5302
5677
|
exports.UndirectedGraph = UndirectedGraph;
|
|
5303
5678
|
exports.UndirectedVertex = UndirectedVertex;
|
|
5679
|
+
exports.raise = raise;
|
|
5304
5680
|
//# sourceMappingURL=index.cjs.map
|
|
5305
5681
|
//# sourceMappingURL=index.cjs.map
|