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
|
@@ -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
|
|
@@ -275,7 +281,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
275
281
|
if (options) {
|
|
276
282
|
const { toElementFn } = options;
|
|
277
283
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
278
|
-
else if (toElementFn)
|
|
284
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
279
285
|
}
|
|
280
286
|
}
|
|
281
287
|
/**
|
|
@@ -431,7 +437,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
431
437
|
acc = initialValue;
|
|
432
438
|
} else {
|
|
433
439
|
const first = iter.next();
|
|
434
|
-
if (first.done)
|
|
440
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
435
441
|
acc = first.value;
|
|
436
442
|
index = 1;
|
|
437
443
|
}
|
|
@@ -682,7 +688,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
682
688
|
__publicField(this, "_elements", []);
|
|
683
689
|
__publicField(this, "_DEFAULT_COMPARATOR", /* @__PURE__ */ __name((a, b) => {
|
|
684
690
|
if (typeof a === "object" || typeof b === "object") {
|
|
685
|
-
|
|
691
|
+
raise(TypeError, ERR.comparatorRequired("Heap"));
|
|
686
692
|
}
|
|
687
693
|
if (a > b) return 1;
|
|
688
694
|
if (a < b) return -1;
|
|
@@ -731,6 +737,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
731
737
|
|
|
732
738
|
|
|
733
739
|
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
734
747
|
|
|
735
748
|
|
|
736
749
|
|
|
@@ -788,7 +801,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
788
801
|
}
|
|
789
802
|
/**
|
|
790
803
|
* Insert an element.
|
|
791
|
-
* @remarks Time O(
|
|
804
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
792
805
|
* @param element - Element to insert.
|
|
793
806
|
* @returns True.
|
|
794
807
|
|
|
@@ -815,6 +828,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
815
828
|
|
|
816
829
|
|
|
817
830
|
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
818
838
|
|
|
819
839
|
|
|
820
840
|
|
|
@@ -869,6 +889,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
869
889
|
|
|
870
890
|
|
|
871
891
|
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
872
899
|
|
|
873
900
|
|
|
874
901
|
|
|
@@ -926,6 +953,12 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
926
953
|
|
|
927
954
|
|
|
928
955
|
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
929
962
|
|
|
930
963
|
|
|
931
964
|
|
|
@@ -933,6 +966,34 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
933
966
|
|
|
934
967
|
|
|
935
968
|
|
|
969
|
+
* @example
|
|
970
|
+
* // Heap with custom comparator (MaxHeap behavior)
|
|
971
|
+
* interface Task {
|
|
972
|
+
* id: number;
|
|
973
|
+
* priority: number;
|
|
974
|
+
* name: string;
|
|
975
|
+
* }
|
|
976
|
+
*
|
|
977
|
+
* // Custom comparator for max heap behavior (higher priority first)
|
|
978
|
+
* const tasks: Task[] = [
|
|
979
|
+
* { id: 1, priority: 5, name: 'Email' },
|
|
980
|
+
* { id: 2, priority: 3, name: 'Chat' },
|
|
981
|
+
* { id: 3, priority: 8, name: 'Alert' }
|
|
982
|
+
* ];
|
|
983
|
+
*
|
|
984
|
+
* const maxHeap = new Heap(tasks, {
|
|
985
|
+
* comparator: (a: Task, b: Task) => b.priority - a.priority
|
|
986
|
+
* });
|
|
987
|
+
*
|
|
988
|
+
* console.log(maxHeap.size); // 3;
|
|
989
|
+
*
|
|
990
|
+
* // Peek returns highest priority task
|
|
991
|
+
* const topTask = maxHeap.peek();
|
|
992
|
+
* console.log(topTask?.priority); // 8;
|
|
993
|
+
* console.log(topTask?.name); // 'Alert';
|
|
994
|
+
*/
|
|
995
|
+
/**
|
|
996
|
+
* @deprecated Use `pop` instead. Will be removed in a future major version.
|
|
936
997
|
* @example
|
|
937
998
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
938
999
|
* interface Task {
|
|
@@ -960,6 +1021,14 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
960
1021
|
* console.log(topTask?.name); // 'Alert';
|
|
961
1022
|
*/
|
|
962
1023
|
poll() {
|
|
1024
|
+
return this.pop();
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Remove and return the top element (min or max depending on comparator).
|
|
1028
|
+
* @remarks Time O(log N) amortized, Space O(1)
|
|
1029
|
+
* @returns The removed top element, or undefined if empty.
|
|
1030
|
+
*/
|
|
1031
|
+
pop() {
|
|
963
1032
|
if (this.elements.length === 0) return;
|
|
964
1033
|
const value = this.elements[0];
|
|
965
1034
|
const last = this.elements.pop();
|
|
@@ -997,6 +1066,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
997
1066
|
|
|
998
1067
|
|
|
999
1068
|
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
|
|
1000
1076
|
|
|
1001
1077
|
|
|
1002
1078
|
|
|
@@ -1094,6 +1170,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1094
1170
|
|
|
1095
1171
|
|
|
1096
1172
|
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
|
|
1097
1180
|
|
|
1098
1181
|
|
|
1099
1182
|
|
|
@@ -1138,6 +1221,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1138
1221
|
|
|
1139
1222
|
|
|
1140
1223
|
|
|
1224
|
+
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
|
|
1141
1231
|
|
|
1142
1232
|
|
|
1143
1233
|
|
|
@@ -1155,16 +1245,6 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1155
1245
|
clear() {
|
|
1156
1246
|
this._elements = [];
|
|
1157
1247
|
}
|
|
1158
|
-
/**
|
|
1159
|
-
* Replace the backing array and rebuild the heap.
|
|
1160
|
-
* @remarks Time O(N), Space O(N)
|
|
1161
|
-
* @param elements - Iterable used to refill the heap.
|
|
1162
|
-
* @returns Array of per-node results from fixing steps.
|
|
1163
|
-
*/
|
|
1164
|
-
refill(elements) {
|
|
1165
|
-
this._elements = Array.from(elements);
|
|
1166
|
-
return this.fix();
|
|
1167
|
-
}
|
|
1168
1248
|
/**
|
|
1169
1249
|
* Check if an equal element exists in the heap.
|
|
1170
1250
|
* @remarks Time O(N), Space O(1)
|
|
@@ -1185,6 +1265,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1185
1265
|
|
|
1186
1266
|
|
|
1187
1267
|
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
|
|
1271
|
+
|
|
1272
|
+
|
|
1273
|
+
|
|
1274
|
+
|
|
1188
1275
|
|
|
1189
1276
|
|
|
1190
1277
|
|
|
@@ -1229,6 +1316,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1229
1316
|
|
|
1230
1317
|
|
|
1231
1318
|
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
|
|
1232
1326
|
|
|
1233
1327
|
|
|
1234
1328
|
|
|
@@ -1253,7 +1347,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1253
1347
|
}
|
|
1254
1348
|
if (index < 0) return false;
|
|
1255
1349
|
if (index === 0) {
|
|
1256
|
-
this.
|
|
1350
|
+
this.pop();
|
|
1257
1351
|
} else if (index === this.elements.length - 1) {
|
|
1258
1352
|
this.elements.pop();
|
|
1259
1353
|
} else {
|
|
@@ -1263,13 +1357,19 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1263
1357
|
}
|
|
1264
1358
|
return true;
|
|
1265
1359
|
}
|
|
1360
|
+
/**
|
|
1361
|
+
* @deprecated Use `deleteWhere` instead. Will be removed in a future major version.
|
|
1362
|
+
*/
|
|
1363
|
+
deleteBy(predicate) {
|
|
1364
|
+
return this.deleteWhere(predicate);
|
|
1365
|
+
}
|
|
1266
1366
|
/**
|
|
1267
1367
|
* Delete the first element that matches a predicate.
|
|
1268
1368
|
* @remarks Time O(N), Space O(1)
|
|
1269
1369
|
* @param predicate - Function (element, index, heap) → boolean.
|
|
1270
1370
|
* @returns True if an element was removed.
|
|
1271
1371
|
*/
|
|
1272
|
-
|
|
1372
|
+
deleteWhere(predicate) {
|
|
1273
1373
|
let idx = -1;
|
|
1274
1374
|
for (let i = 0; i < this.elements.length; i++) {
|
|
1275
1375
|
if (predicate(this.elements[i], i, this)) {
|
|
@@ -1279,7 +1379,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1279
1379
|
}
|
|
1280
1380
|
if (idx < 0) return false;
|
|
1281
1381
|
if (idx === 0) {
|
|
1282
|
-
this.
|
|
1382
|
+
this.pop();
|
|
1283
1383
|
} else if (idx === this.elements.length - 1) {
|
|
1284
1384
|
this.elements.pop();
|
|
1285
1385
|
} else {
|
|
@@ -1319,6 +1419,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1319
1419
|
|
|
1320
1420
|
|
|
1321
1421
|
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1322
1429
|
|
|
1323
1430
|
|
|
1324
1431
|
|
|
@@ -1396,6 +1503,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1396
1503
|
|
|
1397
1504
|
|
|
1398
1505
|
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
|
|
1510
|
+
|
|
1511
|
+
|
|
1512
|
+
|
|
1399
1513
|
|
|
1400
1514
|
|
|
1401
1515
|
|
|
@@ -1446,6 +1560,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1446
1560
|
|
|
1447
1561
|
|
|
1448
1562
|
|
|
1563
|
+
|
|
1564
|
+
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
|
|
1449
1570
|
|
|
1450
1571
|
|
|
1451
1572
|
|
|
@@ -1495,6 +1616,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1495
1616
|
|
|
1496
1617
|
|
|
1497
1618
|
|
|
1619
|
+
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
|
|
1498
1626
|
|
|
1499
1627
|
|
|
1500
1628
|
|
|
@@ -1551,6 +1679,13 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1551
1679
|
|
|
1552
1680
|
|
|
1553
1681
|
|
|
1682
|
+
|
|
1683
|
+
|
|
1684
|
+
|
|
1685
|
+
|
|
1686
|
+
|
|
1687
|
+
|
|
1688
|
+
|
|
1554
1689
|
|
|
1555
1690
|
|
|
1556
1691
|
|
|
@@ -1567,7 +1702,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1567
1702
|
*/
|
|
1568
1703
|
map(callback, options, thisArg) {
|
|
1569
1704
|
const { comparator, toElementFn, ...rest } = options != null ? options : {};
|
|
1570
|
-
if (!comparator)
|
|
1705
|
+
if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
|
|
1571
1706
|
const out = this._createLike([], { ...rest, comparator, toElementFn });
|
|
1572
1707
|
let i = 0;
|
|
1573
1708
|
for (const x of this) {
|
|
@@ -1751,6 +1886,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1751
1886
|
|
|
1752
1887
|
|
|
1753
1888
|
|
|
1889
|
+
|
|
1890
|
+
|
|
1891
|
+
|
|
1892
|
+
|
|
1893
|
+
|
|
1894
|
+
|
|
1895
|
+
|
|
1754
1896
|
|
|
1755
1897
|
|
|
1756
1898
|
|
|
@@ -1798,6 +1940,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1798
1940
|
|
|
1799
1941
|
|
|
1800
1942
|
|
|
1943
|
+
|
|
1944
|
+
|
|
1945
|
+
|
|
1946
|
+
|
|
1947
|
+
|
|
1948
|
+
|
|
1949
|
+
|
|
1801
1950
|
|
|
1802
1951
|
|
|
1803
1952
|
|
|
@@ -1815,6 +1964,14 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1815
1964
|
get first() {
|
|
1816
1965
|
return this.length > 0 ? this.elements[this._offset] : void 0;
|
|
1817
1966
|
}
|
|
1967
|
+
/**
|
|
1968
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
1969
|
+
* @remarks Time O(1), Space O(1)
|
|
1970
|
+
* @returns Front element or undefined.
|
|
1971
|
+
*/
|
|
1972
|
+
peek() {
|
|
1973
|
+
return this.first;
|
|
1974
|
+
}
|
|
1818
1975
|
/**
|
|
1819
1976
|
* Get the last element (back) without removing it.
|
|
1820
1977
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1861,6 +2018,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1861
2018
|
|
|
1862
2019
|
|
|
1863
2020
|
|
|
2021
|
+
|
|
2022
|
+
|
|
2023
|
+
|
|
2024
|
+
|
|
2025
|
+
|
|
2026
|
+
|
|
2027
|
+
|
|
1864
2028
|
|
|
1865
2029
|
|
|
1866
2030
|
|
|
@@ -1920,6 +2084,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1920
2084
|
|
|
1921
2085
|
|
|
1922
2086
|
|
|
2087
|
+
|
|
2088
|
+
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
|
|
2092
|
+
|
|
2093
|
+
|
|
1923
2094
|
|
|
1924
2095
|
|
|
1925
2096
|
|
|
@@ -1986,6 +2157,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1986
2157
|
|
|
1987
2158
|
|
|
1988
2159
|
|
|
2160
|
+
|
|
2161
|
+
|
|
2162
|
+
|
|
2163
|
+
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
|
|
1989
2167
|
|
|
1990
2168
|
|
|
1991
2169
|
|
|
@@ -2042,6 +2220,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2042
2220
|
|
|
2043
2221
|
|
|
2044
2222
|
|
|
2223
|
+
|
|
2224
|
+
|
|
2225
|
+
|
|
2226
|
+
|
|
2227
|
+
|
|
2228
|
+
|
|
2229
|
+
|
|
2045
2230
|
|
|
2046
2231
|
|
|
2047
2232
|
|
|
@@ -2091,6 +2276,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2091
2276
|
|
|
2092
2277
|
|
|
2093
2278
|
|
|
2279
|
+
|
|
2280
|
+
|
|
2281
|
+
|
|
2282
|
+
|
|
2283
|
+
|
|
2284
|
+
|
|
2285
|
+
|
|
2094
2286
|
|
|
2095
2287
|
|
|
2096
2288
|
|
|
@@ -2145,6 +2337,21 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2145
2337
|
this._elements[this._offset + index] = newElement;
|
|
2146
2338
|
return true;
|
|
2147
2339
|
}
|
|
2340
|
+
/**
|
|
2341
|
+
* Delete the first element that satisfies a predicate.
|
|
2342
|
+
* @remarks Time O(N), Space O(N)
|
|
2343
|
+
* @param predicate - Function (value, index, queue) → boolean to decide deletion.
|
|
2344
|
+
* @returns True if a match was removed.
|
|
2345
|
+
*/
|
|
2346
|
+
deleteWhere(predicate) {
|
|
2347
|
+
for (let i = 0; i < this.length; i++) {
|
|
2348
|
+
if (predicate(this._elements[this._offset + i], i, this)) {
|
|
2349
|
+
this.deleteAt(i);
|
|
2350
|
+
return true;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
return false;
|
|
2354
|
+
}
|
|
2148
2355
|
/**
|
|
2149
2356
|
* Reverse the queue in-place by compacting then reversing.
|
|
2150
2357
|
* @remarks Time O(N), Space O(N)
|
|
@@ -2181,6 +2388,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2181
2388
|
|
|
2182
2389
|
|
|
2183
2390
|
|
|
2391
|
+
|
|
2392
|
+
|
|
2393
|
+
|
|
2394
|
+
|
|
2395
|
+
|
|
2396
|
+
|
|
2397
|
+
|
|
2184
2398
|
|
|
2185
2399
|
|
|
2186
2400
|
|
|
@@ -2224,6 +2438,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2224
2438
|
|
|
2225
2439
|
|
|
2226
2440
|
|
|
2441
|
+
|
|
2442
|
+
|
|
2443
|
+
|
|
2444
|
+
|
|
2445
|
+
|
|
2446
|
+
|
|
2447
|
+
|
|
2227
2448
|
|
|
2228
2449
|
|
|
2229
2450
|
|
|
@@ -2290,6 +2511,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2290
2511
|
|
|
2291
2512
|
|
|
2292
2513
|
|
|
2514
|
+
|
|
2515
|
+
|
|
2516
|
+
|
|
2517
|
+
|
|
2518
|
+
|
|
2519
|
+
|
|
2520
|
+
|
|
2293
2521
|
|
|
2294
2522
|
|
|
2295
2523
|
|
|
@@ -2340,6 +2568,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2340
2568
|
|
|
2341
2569
|
|
|
2342
2570
|
|
|
2571
|
+
|
|
2572
|
+
|
|
2573
|
+
|
|
2574
|
+
|
|
2575
|
+
|
|
2576
|
+
|
|
2577
|
+
|
|
2343
2578
|
|
|
2344
2579
|
|
|
2345
2580
|
|
|
@@ -2394,6 +2629,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2394
2629
|
|
|
2395
2630
|
|
|
2396
2631
|
|
|
2632
|
+
|
|
2633
|
+
|
|
2634
|
+
|
|
2635
|
+
|
|
2636
|
+
|
|
2637
|
+
|
|
2638
|
+
|
|
2397
2639
|
|
|
2398
2640
|
|
|
2399
2641
|
|
|
@@ -2636,7 +2878,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
|
|
|
2636
2878
|
const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
|
|
2637
2879
|
return this._addEdge(newEdge);
|
|
2638
2880
|
} else {
|
|
2639
|
-
|
|
2881
|
+
raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
|
|
2640
2882
|
}
|
|
2641
2883
|
}
|
|
2642
2884
|
}
|
|
@@ -3533,6 +3775,13 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3533
3775
|
|
|
3534
3776
|
|
|
3535
3777
|
|
|
3778
|
+
|
|
3779
|
+
|
|
3780
|
+
|
|
3781
|
+
|
|
3782
|
+
|
|
3783
|
+
|
|
3784
|
+
|
|
3536
3785
|
|
|
3537
3786
|
|
|
3538
3787
|
|
|
@@ -3618,6 +3867,13 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3618
3867
|
|
|
3619
3868
|
|
|
3620
3869
|
|
|
3870
|
+
|
|
3871
|
+
|
|
3872
|
+
|
|
3873
|
+
|
|
3874
|
+
|
|
3875
|
+
|
|
3876
|
+
|
|
3621
3877
|
|
|
3622
3878
|
|
|
3623
3879
|
|
|
@@ -3701,6 +3957,13 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3701
3957
|
|
|
3702
3958
|
|
|
3703
3959
|
|
|
3960
|
+
|
|
3961
|
+
|
|
3962
|
+
|
|
3963
|
+
|
|
3964
|
+
|
|
3965
|
+
|
|
3966
|
+
|
|
3704
3967
|
|
|
3705
3968
|
|
|
3706
3969
|
|
|
@@ -3775,6 +4038,13 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3775
4038
|
|
|
3776
4039
|
|
|
3777
4040
|
|
|
4041
|
+
|
|
4042
|
+
|
|
4043
|
+
|
|
4044
|
+
|
|
4045
|
+
|
|
4046
|
+
|
|
4047
|
+
|
|
3778
4048
|
|
|
3779
4049
|
|
|
3780
4050
|
|
|
@@ -3826,6 +4096,13 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3826
4096
|
|
|
3827
4097
|
|
|
3828
4098
|
|
|
4099
|
+
|
|
4100
|
+
|
|
4101
|
+
|
|
4102
|
+
|
|
4103
|
+
|
|
4104
|
+
|
|
4105
|
+
|
|
3829
4106
|
|
|
3830
4107
|
|
|
3831
4108
|
|
|
@@ -3930,6 +4207,13 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3930
4207
|
|
|
3931
4208
|
|
|
3932
4209
|
|
|
4210
|
+
|
|
4211
|
+
|
|
4212
|
+
|
|
4213
|
+
|
|
4214
|
+
|
|
4215
|
+
|
|
4216
|
+
|
|
3933
4217
|
|
|
3934
4218
|
|
|
3935
4219
|
|
|
@@ -4015,6 +4299,13 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4015
4299
|
|
|
4016
4300
|
|
|
4017
4301
|
|
|
4302
|
+
|
|
4303
|
+
|
|
4304
|
+
|
|
4305
|
+
|
|
4306
|
+
|
|
4307
|
+
|
|
4308
|
+
|
|
4018
4309
|
|
|
4019
4310
|
|
|
4020
4311
|
|
|
@@ -4062,6 +4353,13 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4062
4353
|
|
|
4063
4354
|
|
|
4064
4355
|
|
|
4356
|
+
|
|
4357
|
+
|
|
4358
|
+
|
|
4359
|
+
|
|
4360
|
+
|
|
4361
|
+
|
|
4362
|
+
|
|
4065
4363
|
|
|
4066
4364
|
|
|
4067
4365
|
|
|
@@ -4162,6 +4460,13 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4162
4460
|
|
|
4163
4461
|
|
|
4164
4462
|
|
|
4463
|
+
|
|
4464
|
+
|
|
4465
|
+
|
|
4466
|
+
|
|
4467
|
+
|
|
4468
|
+
|
|
4469
|
+
|
|
4165
4470
|
|
|
4166
4471
|
|
|
4167
4472
|
|
|
@@ -4265,6 +4570,13 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4265
4570
|
|
|
4266
4571
|
|
|
4267
4572
|
|
|
4573
|
+
|
|
4574
|
+
|
|
4575
|
+
|
|
4576
|
+
|
|
4577
|
+
|
|
4578
|
+
|
|
4579
|
+
|
|
4268
4580
|
|
|
4269
4581
|
|
|
4270
4582
|
|
|
@@ -4329,6 +4641,6 @@ var DirectedGraph = _DirectedGraph;
|
|
|
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
|