data-structure-typed 1.47.7 → 1.47.9
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/CHANGELOG.md +1 -1
- package/README.md +98 -17
- package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +6 -6
- package/dist/cjs/data-structures/binary-tree/segment-tree.js +7 -7
- package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +22 -17
- package/dist/cjs/data-structures/graph/abstract-graph.js +71 -30
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +24 -24
- package/dist/cjs/data-structures/graph/directed-graph.js +29 -29
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +14 -14
- package/dist/cjs/data-structures/graph/undirected-graph.js +18 -18
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +28 -28
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +33 -33
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +21 -21
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +27 -27
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js +4 -4
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +13 -13
- package/dist/cjs/data-structures/queue/queue.js +13 -13
- package/dist/cjs/data-structures/stack/stack.d.ts +6 -6
- package/dist/cjs/data-structures/stack/stack.js +7 -7
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/types/data-structures/graph/abstract-graph.d.ts +2 -2
- package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +6 -6
- package/dist/mjs/data-structures/binary-tree/segment-tree.js +7 -7
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +22 -17
- package/dist/mjs/data-structures/graph/abstract-graph.js +71 -30
- package/dist/mjs/data-structures/graph/directed-graph.d.ts +24 -24
- package/dist/mjs/data-structures/graph/directed-graph.js +29 -29
- package/dist/mjs/data-structures/graph/undirected-graph.d.ts +14 -14
- package/dist/mjs/data-structures/graph/undirected-graph.js +18 -18
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +28 -28
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +33 -33
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +21 -21
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +27 -27
- package/dist/mjs/data-structures/linked-list/skip-linked-list.js +4 -4
- package/dist/mjs/data-structures/queue/queue.d.ts +13 -13
- package/dist/mjs/data-structures/queue/queue.js +13 -13
- package/dist/mjs/data-structures/stack/stack.d.ts +6 -6
- package/dist/mjs/data-structures/stack/stack.js +7 -7
- package/dist/mjs/types/data-structures/graph/abstract-graph.d.ts +2 -2
- package/dist/umd/data-structure-typed.js +203 -162
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/binary-tree/segment-tree.ts +10 -10
- package/src/data-structures/graph/abstract-graph.ts +92 -46
- package/src/data-structures/graph/directed-graph.ts +41 -41
- package/src/data-structures/graph/undirected-graph.ts +26 -26
- package/src/data-structures/linked-list/doubly-linked-list.ts +45 -45
- package/src/data-structures/linked-list/singly-linked-list.ts +38 -38
- package/src/data-structures/linked-list/skip-linked-list.ts +4 -4
- package/src/data-structures/queue/queue.ts +13 -13
- package/src/data-structures/stack/stack.ts +9 -9
- package/src/types/data-structures/graph/abstract-graph.ts +2 -2
- package/test/integration/index.html +102 -33
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +1 -1
- package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/segment-tree.test.ts +1 -1
- package/test/unit/data-structures/graph/abstract-graph.test.ts +4 -4
- package/test/unit/data-structures/graph/directed-graph.test.ts +51 -10
- package/test/unit/data-structures/graph/undirected-graph.test.ts +3 -3
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +14 -14
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +3 -3
- package/test/unit/data-structures/linked-list/skip-list.test.ts +1 -1
- package/test/unit/data-structures/queue/deque.test.ts +1 -1
- package/test/unit/data-structures/stack/stack.test.ts +2 -2
|
@@ -868,7 +868,7 @@ var dataStructureTyped = (() => {
|
|
|
868
868
|
// src/data-structures/linked-list/singly-linked-list.ts
|
|
869
869
|
var SinglyLinkedListNode = class {
|
|
870
870
|
/**
|
|
871
|
-
* The constructor function initializes an instance of a class with a given value and sets the next property to
|
|
871
|
+
* The constructor function initializes an instance of a class with a given value and sets the next property to undefined.
|
|
872
872
|
* @param {E} value - The "value" parameter is of type E, which means it can be any data type. It represents the value that
|
|
873
873
|
* will be stored in the node of a linked list.
|
|
874
874
|
*/
|
|
@@ -876,7 +876,7 @@ var dataStructureTyped = (() => {
|
|
|
876
876
|
__publicField(this, "value");
|
|
877
877
|
__publicField(this, "next");
|
|
878
878
|
this.value = value;
|
|
879
|
-
this.next =
|
|
879
|
+
this.next = void 0;
|
|
880
880
|
}
|
|
881
881
|
};
|
|
882
882
|
var SinglyLinkedList = class _SinglyLinkedList {
|
|
@@ -887,8 +887,8 @@ var dataStructureTyped = (() => {
|
|
|
887
887
|
__publicField(this, "_head");
|
|
888
888
|
__publicField(this, "_tail");
|
|
889
889
|
__publicField(this, "_length");
|
|
890
|
-
this._head =
|
|
891
|
-
this._tail =
|
|
890
|
+
this._head = void 0;
|
|
891
|
+
this._tail = void 0;
|
|
892
892
|
this._length = 0;
|
|
893
893
|
if (elements) {
|
|
894
894
|
for (const el of elements)
|
|
@@ -973,15 +973,15 @@ var dataStructureTyped = (() => {
|
|
|
973
973
|
* The `pop()` function removes and returns the value of the last element in a linked list, updating the head and tail
|
|
974
974
|
* pointers accordingly.
|
|
975
975
|
* @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
|
|
976
|
-
* the linked list is empty, it returns `
|
|
976
|
+
* the linked list is empty, it returns `undefined`.
|
|
977
977
|
*/
|
|
978
978
|
pop() {
|
|
979
979
|
if (!this.head)
|
|
980
980
|
return void 0;
|
|
981
981
|
if (this.head === this.tail) {
|
|
982
982
|
const value2 = this.head.value;
|
|
983
|
-
this._head =
|
|
984
|
-
this._tail =
|
|
983
|
+
this._head = void 0;
|
|
984
|
+
this._tail = void 0;
|
|
985
985
|
this._length--;
|
|
986
986
|
return value2;
|
|
987
987
|
}
|
|
@@ -990,7 +990,7 @@ var dataStructureTyped = (() => {
|
|
|
990
990
|
current = current.next;
|
|
991
991
|
}
|
|
992
992
|
const value = this.tail.value;
|
|
993
|
-
current.next =
|
|
993
|
+
current.next = void 0;
|
|
994
994
|
this._tail = current;
|
|
995
995
|
this._length--;
|
|
996
996
|
return value;
|
|
@@ -1006,7 +1006,7 @@ var dataStructureTyped = (() => {
|
|
|
1006
1006
|
* The `popLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
|
|
1007
1007
|
* pointers accordingly.
|
|
1008
1008
|
* @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
|
|
1009
|
-
* the linked list is empty, it returns `
|
|
1009
|
+
* the linked list is empty, it returns `undefined`.
|
|
1010
1010
|
*/
|
|
1011
1011
|
popLast() {
|
|
1012
1012
|
return this.pop();
|
|
@@ -1090,11 +1090,11 @@ var dataStructureTyped = (() => {
|
|
|
1090
1090
|
* Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
|
|
1091
1091
|
* Space Complexity: O(1) - Constant space.
|
|
1092
1092
|
*
|
|
1093
|
-
* The function `getAt` returns the value at a specified index in a linked list, or
|
|
1093
|
+
* The function `getAt` returns the value at a specified index in a linked list, or undefined if the index is out of range.
|
|
1094
1094
|
* @param {number} index - The index parameter is a number that represents the position of the element we want to
|
|
1095
1095
|
* retrieve from the list.
|
|
1096
|
-
* @returns The method `getAt(index: number): E |
|
|
1097
|
-
* `
|
|
1096
|
+
* @returns The method `getAt(index: number): E | undefined` returns the value at the specified index in the linked list, or
|
|
1097
|
+
* `undefined` if the index is out of bounds.
|
|
1098
1098
|
*/
|
|
1099
1099
|
getAt(index) {
|
|
1100
1100
|
if (index < 0 || index >= this.length)
|
|
@@ -1117,7 +1117,7 @@ var dataStructureTyped = (() => {
|
|
|
1117
1117
|
* @param {number} index - The `index` parameter is a number that represents the position of the node we want to
|
|
1118
1118
|
* retrieve from the linked list. It indicates the zero-based index of the node we want to access.
|
|
1119
1119
|
* @returns The method `getNodeAt(index: number)` returns a `SinglyLinkedListNode<E>` object if the node at the
|
|
1120
|
-
* specified index exists, or `
|
|
1120
|
+
* specified index exists, or `undefined` if the index is out of bounds.
|
|
1121
1121
|
*/
|
|
1122
1122
|
getNodeAt(index) {
|
|
1123
1123
|
let current = this.head;
|
|
@@ -1137,7 +1137,7 @@ var dataStructureTyped = (() => {
|
|
|
1137
1137
|
* The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
|
|
1138
1138
|
* @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
|
|
1139
1139
|
* data structure. It is of type number.
|
|
1140
|
-
* @returns The method `deleteAt` returns the value of the node that was deleted, or `
|
|
1140
|
+
* @returns The method `deleteAt` returns the value of the node that was deleted, or `undefined` if the index is out of
|
|
1141
1141
|
* bounds.
|
|
1142
1142
|
*/
|
|
1143
1143
|
deleteAt(index) {
|
|
@@ -1176,13 +1176,13 @@ var dataStructureTyped = (() => {
|
|
|
1176
1176
|
} else {
|
|
1177
1177
|
value = valueOrNode;
|
|
1178
1178
|
}
|
|
1179
|
-
let current = this.head, prev =
|
|
1179
|
+
let current = this.head, prev = void 0;
|
|
1180
1180
|
while (current) {
|
|
1181
1181
|
if (current.value === value) {
|
|
1182
|
-
if (prev ===
|
|
1182
|
+
if (prev === void 0) {
|
|
1183
1183
|
this._head = current.next;
|
|
1184
1184
|
if (current === this.tail) {
|
|
1185
|
-
this._tail =
|
|
1185
|
+
this._tail = void 0;
|
|
1186
1186
|
}
|
|
1187
1187
|
} else {
|
|
1188
1188
|
prev.next = current.next;
|
|
@@ -1241,11 +1241,11 @@ var dataStructureTyped = (() => {
|
|
|
1241
1241
|
return this.length === 0;
|
|
1242
1242
|
}
|
|
1243
1243
|
/**
|
|
1244
|
-
* The `clear` function resets the linked list by setting the head, tail, and length to
|
|
1244
|
+
* The `clear` function resets the linked list by setting the head, tail, and length to undefined and 0 respectively.
|
|
1245
1245
|
*/
|
|
1246
1246
|
clear() {
|
|
1247
|
-
this._head =
|
|
1248
|
-
this._tail =
|
|
1247
|
+
this._head = void 0;
|
|
1248
|
+
this._tail = void 0;
|
|
1249
1249
|
this._length = 0;
|
|
1250
1250
|
}
|
|
1251
1251
|
/**
|
|
@@ -1282,9 +1282,9 @@ var dataStructureTyped = (() => {
|
|
|
1282
1282
|
reverse() {
|
|
1283
1283
|
if (!this.head || this.head === this.tail)
|
|
1284
1284
|
return;
|
|
1285
|
-
let prev =
|
|
1285
|
+
let prev = void 0;
|
|
1286
1286
|
let current = this.head;
|
|
1287
|
-
let next =
|
|
1287
|
+
let next = void 0;
|
|
1288
1288
|
while (current) {
|
|
1289
1289
|
next = current.next;
|
|
1290
1290
|
current.next = prev;
|
|
@@ -1305,7 +1305,7 @@ var dataStructureTyped = (() => {
|
|
|
1305
1305
|
* @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
|
|
1306
1306
|
* function is used to determine whether a particular value in the linked list satisfies a certain condition.
|
|
1307
1307
|
* @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
|
|
1308
|
-
* the callback function. If no element satisfies the condition, it returns `
|
|
1308
|
+
* the callback function. If no element satisfies the condition, it returns `undefined`.
|
|
1309
1309
|
*/
|
|
1310
1310
|
find(callback) {
|
|
1311
1311
|
let current = this.head;
|
|
@@ -1315,7 +1315,7 @@ var dataStructureTyped = (() => {
|
|
|
1315
1315
|
}
|
|
1316
1316
|
current = current.next;
|
|
1317
1317
|
}
|
|
1318
|
-
return
|
|
1318
|
+
return void 0;
|
|
1319
1319
|
}
|
|
1320
1320
|
/**
|
|
1321
1321
|
* Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
|
|
@@ -1351,10 +1351,10 @@ var dataStructureTyped = (() => {
|
|
|
1351
1351
|
* Space Complexity: O(1) - Constant space.
|
|
1352
1352
|
*
|
|
1353
1353
|
* The function finds a node in a singly linked list by its value and returns the node if found, otherwise returns
|
|
1354
|
-
*
|
|
1354
|
+
* undefined.
|
|
1355
1355
|
* @param {E} value - The value parameter is the value that we want to search for in the linked list.
|
|
1356
1356
|
* @returns a `SinglyLinkedListNode<E>` if a node with the specified value is found in the linked list. If no node with
|
|
1357
|
-
* the specified value is found, the function returns `
|
|
1357
|
+
* the specified value is found, the function returns `undefined`.
|
|
1358
1358
|
*/
|
|
1359
1359
|
getNode(value) {
|
|
1360
1360
|
let current = this.head;
|
|
@@ -1364,7 +1364,7 @@ var dataStructureTyped = (() => {
|
|
|
1364
1364
|
}
|
|
1365
1365
|
current = current.next;
|
|
1366
1366
|
}
|
|
1367
|
-
return
|
|
1367
|
+
return void 0;
|
|
1368
1368
|
}
|
|
1369
1369
|
/**
|
|
1370
1370
|
* Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
|
|
@@ -1586,8 +1586,8 @@ var dataStructureTyped = (() => {
|
|
|
1586
1586
|
__publicField(this, "next");
|
|
1587
1587
|
__publicField(this, "prev");
|
|
1588
1588
|
this.value = value;
|
|
1589
|
-
this.next =
|
|
1590
|
-
this.prev =
|
|
1589
|
+
this.next = void 0;
|
|
1590
|
+
this.prev = void 0;
|
|
1591
1591
|
}
|
|
1592
1592
|
};
|
|
1593
1593
|
var DoublyLinkedList = class _DoublyLinkedList {
|
|
@@ -1598,8 +1598,8 @@ var dataStructureTyped = (() => {
|
|
|
1598
1598
|
__publicField(this, "_head");
|
|
1599
1599
|
__publicField(this, "_tail");
|
|
1600
1600
|
__publicField(this, "_length");
|
|
1601
|
-
this._head =
|
|
1602
|
-
this._tail =
|
|
1601
|
+
this._head = void 0;
|
|
1602
|
+
this._tail = void 0;
|
|
1603
1603
|
this._length = 0;
|
|
1604
1604
|
if (elements) {
|
|
1605
1605
|
for (const el of elements) {
|
|
@@ -1686,18 +1686,18 @@ var dataStructureTyped = (() => {
|
|
|
1686
1686
|
*
|
|
1687
1687
|
* The `pop()` function removes and returns the value of the last node in a doubly linked list.
|
|
1688
1688
|
* @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
|
|
1689
|
-
* list is empty, it returns
|
|
1689
|
+
* list is empty, it returns undefined.
|
|
1690
1690
|
*/
|
|
1691
1691
|
pop() {
|
|
1692
1692
|
if (!this.tail)
|
|
1693
1693
|
return void 0;
|
|
1694
1694
|
const removedNode = this.tail;
|
|
1695
1695
|
if (this.head === this.tail) {
|
|
1696
|
-
this._head =
|
|
1697
|
-
this._tail =
|
|
1696
|
+
this._head = void 0;
|
|
1697
|
+
this._tail = void 0;
|
|
1698
1698
|
} else {
|
|
1699
1699
|
this._tail = removedNode.prev;
|
|
1700
|
-
this.tail.next =
|
|
1700
|
+
this.tail.next = void 0;
|
|
1701
1701
|
}
|
|
1702
1702
|
this._length--;
|
|
1703
1703
|
return removedNode.value;
|
|
@@ -1712,7 +1712,7 @@ var dataStructureTyped = (() => {
|
|
|
1712
1712
|
*
|
|
1713
1713
|
* The `popLast()` function removes and returns the value of the last node in a doubly linked list.
|
|
1714
1714
|
* @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
|
|
1715
|
-
* list is empty, it returns
|
|
1715
|
+
* list is empty, it returns undefined.
|
|
1716
1716
|
*/
|
|
1717
1717
|
popLast() {
|
|
1718
1718
|
return this.pop();
|
|
@@ -1734,11 +1734,11 @@ var dataStructureTyped = (() => {
|
|
|
1734
1734
|
return void 0;
|
|
1735
1735
|
const removedNode = this.head;
|
|
1736
1736
|
if (this.head === this.tail) {
|
|
1737
|
-
this._head =
|
|
1738
|
-
this._tail =
|
|
1737
|
+
this._head = void 0;
|
|
1738
|
+
this._tail = void 0;
|
|
1739
1739
|
} else {
|
|
1740
1740
|
this._head = removedNode.next;
|
|
1741
|
-
this.head.prev =
|
|
1741
|
+
this.head.prev = void 0;
|
|
1742
1742
|
}
|
|
1743
1743
|
this._length--;
|
|
1744
1744
|
return removedNode.value;
|
|
@@ -1805,8 +1805,8 @@ var dataStructureTyped = (() => {
|
|
|
1805
1805
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
1806
1806
|
* Space Complexity: O(1)
|
|
1807
1807
|
*
|
|
1808
|
-
* The `getFirst` function returns the first node in a doubly linked list, or
|
|
1809
|
-
* @returns The method `getFirst()` returns the first node of the doubly linked list, or `
|
|
1808
|
+
* The `getFirst` function returns the first node in a doubly linked list, or undefined if the list is empty.
|
|
1809
|
+
* @returns The method `getFirst()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
|
|
1810
1810
|
*/
|
|
1811
1811
|
getFirst() {
|
|
1812
1812
|
var _a;
|
|
@@ -1820,8 +1820,8 @@ var dataStructureTyped = (() => {
|
|
|
1820
1820
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
1821
1821
|
* Space Complexity: O(1)
|
|
1822
1822
|
*
|
|
1823
|
-
* The `getLast` function returns the last node in a doubly linked list, or
|
|
1824
|
-
* @returns The method `getLast()` returns the last node of the doubly linked list, or `
|
|
1823
|
+
* The `getLast` function returns the last node in a doubly linked list, or undefined if the list is empty.
|
|
1824
|
+
* @returns The method `getLast()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
|
|
1825
1825
|
*/
|
|
1826
1826
|
getLast() {
|
|
1827
1827
|
var _a;
|
|
@@ -1835,11 +1835,11 @@ var dataStructureTyped = (() => {
|
|
|
1835
1835
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
1836
1836
|
* Space Complexity: O(1)
|
|
1837
1837
|
*
|
|
1838
|
-
* The `getAt` function returns the value at a specified index in a linked list, or
|
|
1838
|
+
* The `getAt` function returns the value at a specified index in a linked list, or undefined if the index is out of bounds.
|
|
1839
1839
|
* @param {number} index - The index parameter is a number that represents the position of the element we want to
|
|
1840
1840
|
* retrieve from the list.
|
|
1841
1841
|
* @returns The method is returning the value at the specified index in the linked list. If the index is out of bounds
|
|
1842
|
-
* or the linked list is empty, it will return
|
|
1842
|
+
* or the linked list is empty, it will return undefined.
|
|
1843
1843
|
*/
|
|
1844
1844
|
getAt(index) {
|
|
1845
1845
|
if (index < 0 || index >= this.length)
|
|
@@ -1858,16 +1858,16 @@ var dataStructureTyped = (() => {
|
|
|
1858
1858
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
1859
1859
|
* Space Complexity: O(1)
|
|
1860
1860
|
*
|
|
1861
|
-
* The function `getNodeAt` returns the node at a given index in a doubly linked list, or
|
|
1861
|
+
* The function `getNodeAt` returns the node at a given index in a doubly linked list, or undefined if the index is out of
|
|
1862
1862
|
* range.
|
|
1863
1863
|
* @param {number} index - The `index` parameter is a number that represents the position of the node we want to
|
|
1864
1864
|
* retrieve from the doubly linked list. It indicates the zero-based index of the node we want to access.
|
|
1865
1865
|
* @returns The method `getNodeAt(index: number)` returns a `DoublyLinkedListNode<E>` object if the index is within the
|
|
1866
|
-
* valid range of the linked list, otherwise it returns `
|
|
1866
|
+
* valid range of the linked list, otherwise it returns `undefined`.
|
|
1867
1867
|
*/
|
|
1868
1868
|
getNodeAt(index) {
|
|
1869
1869
|
if (index < 0 || index >= this.length)
|
|
1870
|
-
return
|
|
1870
|
+
return void 0;
|
|
1871
1871
|
let current = this.head;
|
|
1872
1872
|
for (let i = 0; i < index; i++) {
|
|
1873
1873
|
current = current.next;
|
|
@@ -1883,10 +1883,10 @@ var dataStructureTyped = (() => {
|
|
|
1883
1883
|
* Space Complexity: O(1)
|
|
1884
1884
|
*
|
|
1885
1885
|
* The function `findNodeByValue` searches for a node with a specific value in a doubly linked list and returns the
|
|
1886
|
-
* node if found, otherwise it returns
|
|
1886
|
+
* node if found, otherwise it returns undefined.
|
|
1887
1887
|
* @param {E} value - The `value` parameter is the value that we want to search for in the doubly linked list.
|
|
1888
1888
|
* @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `value`
|
|
1889
|
-
* is found in the linked list. If no such node is found, it returns `
|
|
1889
|
+
* is found in the linked list. If no such node is found, it returns `undefined`.
|
|
1890
1890
|
*/
|
|
1891
1891
|
getNode(value) {
|
|
1892
1892
|
let current = this.head;
|
|
@@ -1896,7 +1896,7 @@ var dataStructureTyped = (() => {
|
|
|
1896
1896
|
}
|
|
1897
1897
|
current = current.next;
|
|
1898
1898
|
}
|
|
1899
|
-
return
|
|
1899
|
+
return void 0;
|
|
1900
1900
|
}
|
|
1901
1901
|
/**
|
|
1902
1902
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
@@ -2025,7 +2025,7 @@ var dataStructureTyped = (() => {
|
|
|
2025
2025
|
* The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
|
|
2026
2026
|
* @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
|
|
2027
2027
|
* data structure. It is of type number.
|
|
2028
|
-
* @returns The method `deleteAt` returns the value of the node that was deleted, or `
|
|
2028
|
+
* @returns The method `deleteAt` returns the value of the node that was deleted, or `undefined` if the index is out of
|
|
2029
2029
|
* bounds.
|
|
2030
2030
|
*/
|
|
2031
2031
|
deleteAt(index) {
|
|
@@ -2088,11 +2088,11 @@ var dataStructureTyped = (() => {
|
|
|
2088
2088
|
return this.length === 0;
|
|
2089
2089
|
}
|
|
2090
2090
|
/**
|
|
2091
|
-
* The `clear` function resets the linked list by setting the head, tail, and length to
|
|
2091
|
+
* The `clear` function resets the linked list by setting the head, tail, and length to undefined and 0 respectively.
|
|
2092
2092
|
*/
|
|
2093
2093
|
clear() {
|
|
2094
|
-
this._head =
|
|
2095
|
-
this._tail =
|
|
2094
|
+
this._head = void 0;
|
|
2095
|
+
this._tail = void 0;
|
|
2096
2096
|
this._length = 0;
|
|
2097
2097
|
}
|
|
2098
2098
|
/**
|
|
@@ -2107,7 +2107,7 @@ var dataStructureTyped = (() => {
|
|
|
2107
2107
|
* @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
|
|
2108
2108
|
* function is used to determine whether a particular value in the linked list satisfies a certain condition.
|
|
2109
2109
|
* @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
|
|
2110
|
-
* the callback function. If no element satisfies the condition, it returns `
|
|
2110
|
+
* the callback function. If no element satisfies the condition, it returns `undefined`.
|
|
2111
2111
|
*/
|
|
2112
2112
|
find(callback) {
|
|
2113
2113
|
let current = this.head;
|
|
@@ -2117,7 +2117,7 @@ var dataStructureTyped = (() => {
|
|
|
2117
2117
|
}
|
|
2118
2118
|
current = current.next;
|
|
2119
2119
|
}
|
|
2120
|
-
return
|
|
2120
|
+
return void 0;
|
|
2121
2121
|
}
|
|
2122
2122
|
/**
|
|
2123
2123
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
@@ -2154,11 +2154,11 @@ var dataStructureTyped = (() => {
|
|
|
2154
2154
|
* Space Complexity: O(1)
|
|
2155
2155
|
*
|
|
2156
2156
|
* The `findBackward` function iterates through a linked list from the last node to the first node and returns the last
|
|
2157
|
-
* value that satisfies the given callback function, or
|
|
2157
|
+
* value that satisfies the given callback function, or undefined if no value satisfies the callback.
|
|
2158
2158
|
* @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
|
|
2159
2159
|
* function is used to determine whether a given value satisfies a certain condition.
|
|
2160
2160
|
* @returns The method `findBackward` returns the last value in the linked list that satisfies the condition specified by
|
|
2161
|
-
* the callback function. If no value satisfies the condition, it returns `
|
|
2161
|
+
* the callback function. If no value satisfies the condition, it returns `undefined`.
|
|
2162
2162
|
*/
|
|
2163
2163
|
findBackward(callback) {
|
|
2164
2164
|
let current = this.tail;
|
|
@@ -2168,7 +2168,7 @@ var dataStructureTyped = (() => {
|
|
|
2168
2168
|
}
|
|
2169
2169
|
current = current.prev;
|
|
2170
2170
|
}
|
|
2171
|
-
return
|
|
2171
|
+
return void 0;
|
|
2172
2172
|
}
|
|
2173
2173
|
/**
|
|
2174
2174
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
@@ -2363,7 +2363,7 @@ var dataStructureTyped = (() => {
|
|
|
2363
2363
|
__publicField(this, "_level");
|
|
2364
2364
|
__publicField(this, "_maxLevel");
|
|
2365
2365
|
__publicField(this, "_probability");
|
|
2366
|
-
this._head = new SkipListNode(
|
|
2366
|
+
this._head = new SkipListNode(void 0, void 0, maxLevel);
|
|
2367
2367
|
this._level = 0;
|
|
2368
2368
|
this._maxLevel = maxLevel;
|
|
2369
2369
|
this._probability = probability;
|
|
@@ -2407,7 +2407,7 @@ var dataStructureTyped = (() => {
|
|
|
2407
2407
|
newNode.forward[i] = update[i].forward[i];
|
|
2408
2408
|
update[i].forward[i] = newNode;
|
|
2409
2409
|
}
|
|
2410
|
-
if (newNode.forward[0]
|
|
2410
|
+
if (!newNode.forward[0]) {
|
|
2411
2411
|
this._level = Math.max(this.level, newNode.forward.length);
|
|
2412
2412
|
}
|
|
2413
2413
|
}
|
|
@@ -2478,7 +2478,7 @@ var dataStructureTyped = (() => {
|
|
|
2478
2478
|
}
|
|
2479
2479
|
update[i].forward[i] = current.forward[i];
|
|
2480
2480
|
}
|
|
2481
|
-
while (this.level > 0 && this.head.forward[this.level - 1]
|
|
2481
|
+
while (this.level > 0 && !this.head.forward[this.level - 1]) {
|
|
2482
2482
|
this._level--;
|
|
2483
2483
|
}
|
|
2484
2484
|
return true;
|
|
@@ -2556,7 +2556,7 @@ var dataStructureTyped = (() => {
|
|
|
2556
2556
|
*/
|
|
2557
2557
|
lower(key) {
|
|
2558
2558
|
let current = this.head;
|
|
2559
|
-
let lastLess =
|
|
2559
|
+
let lastLess = void 0;
|
|
2560
2560
|
for (let i = this.level - 1; i >= 0; i--) {
|
|
2561
2561
|
while (current.forward[i] && current.forward[i].key < key) {
|
|
2562
2562
|
current = current.forward[i];
|
|
@@ -2645,12 +2645,12 @@ var dataStructureTyped = (() => {
|
|
|
2645
2645
|
* Time Complexity: O(1), as it only involves accessing the last element of the array.
|
|
2646
2646
|
* Space Complexity: O(1), as it does not use any additional space.
|
|
2647
2647
|
*
|
|
2648
|
-
* The `peek` function returns the last element of an array, or
|
|
2649
|
-
* @returns The `peek()` function returns the last element of the `_elements` array, or `
|
|
2648
|
+
* The `peek` function returns the last element of an array, or undefined if the array is empty.
|
|
2649
|
+
* @returns The `peek()` function returns the last element of the `_elements` array, or `undefined` if the array is empty.
|
|
2650
2650
|
*/
|
|
2651
2651
|
peek() {
|
|
2652
2652
|
if (this.isEmpty())
|
|
2653
|
-
return
|
|
2653
|
+
return void 0;
|
|
2654
2654
|
return this.elements[this.elements.length - 1];
|
|
2655
2655
|
}
|
|
2656
2656
|
/**
|
|
@@ -2677,14 +2677,14 @@ var dataStructureTyped = (() => {
|
|
|
2677
2677
|
* Time Complexity: O(1), as it only involves accessing the last element of the array.
|
|
2678
2678
|
* Space Complexity: O(1), as it does not use any additional space.
|
|
2679
2679
|
*
|
|
2680
|
-
* The `pop` function removes and returns the last element from an array, or returns
|
|
2680
|
+
* The `pop` function removes and returns the last element from an array, or returns undefined if the array is empty.
|
|
2681
2681
|
* @returns The `pop()` method is returning the last element of the array `_elements` if the array is not empty. If the
|
|
2682
|
-
* array is empty, it returns `
|
|
2682
|
+
* array is empty, it returns `undefined`.
|
|
2683
2683
|
*/
|
|
2684
2684
|
pop() {
|
|
2685
2685
|
if (this.isEmpty())
|
|
2686
|
-
return
|
|
2687
|
-
return this.elements.pop() ||
|
|
2686
|
+
return void 0;
|
|
2687
|
+
return this.elements.pop() || void 0;
|
|
2688
2688
|
}
|
|
2689
2689
|
/**
|
|
2690
2690
|
* Time Complexity: O(n)
|
|
@@ -2784,8 +2784,8 @@ var dataStructureTyped = (() => {
|
|
|
2784
2784
|
this.push(value);
|
|
2785
2785
|
}
|
|
2786
2786
|
/**
|
|
2787
|
-
* The `dequeue` function removes and returns the first element from a queue, or returns
|
|
2788
|
-
* @returns The method is returning the element at the front of the queue, or
|
|
2787
|
+
* The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
|
|
2788
|
+
* @returns The method is returning the element at the front of the queue, or undefined if the queue is empty.
|
|
2789
2789
|
*/
|
|
2790
2790
|
dequeue() {
|
|
2791
2791
|
return this.shift();
|
|
@@ -2869,7 +2869,7 @@ var dataStructureTyped = (() => {
|
|
|
2869
2869
|
*
|
|
2870
2870
|
* The `shift` function removes and returns the first element in the queue, and adjusts the internal data structure if
|
|
2871
2871
|
* necessary to optimize performance.
|
|
2872
|
-
* @returns The function `shift()` returns either the first element in the queue or `
|
|
2872
|
+
* @returns The function `shift()` returns either the first element in the queue or `undefined` if the queue is empty.
|
|
2873
2873
|
*/
|
|
2874
2874
|
shift() {
|
|
2875
2875
|
if (this.size === 0)
|
|
@@ -2890,9 +2890,9 @@ var dataStructureTyped = (() => {
|
|
|
2890
2890
|
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
|
|
2891
2891
|
* Space Complexity: O(1) - no additional space is used.
|
|
2892
2892
|
*
|
|
2893
|
-
* The `getFirst` function returns the first element of the array `_nodes` if it exists, otherwise it returns `
|
|
2893
|
+
* The `getFirst` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
|
|
2894
2894
|
* @returns The `getFirst()` method returns the first element of the data structure, represented by the `_nodes` array at
|
|
2895
|
-
* the `_offset` index. If the data structure is empty (size is 0), it returns `
|
|
2895
|
+
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
|
|
2896
2896
|
*/
|
|
2897
2897
|
getFirst() {
|
|
2898
2898
|
return this.size > 0 ? this.nodes[this.offset] : void 0;
|
|
@@ -2905,9 +2905,9 @@ var dataStructureTyped = (() => {
|
|
|
2905
2905
|
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
|
|
2906
2906
|
* Space Complexity: O(1) - no additional space is used.
|
|
2907
2907
|
*
|
|
2908
|
-
* The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `
|
|
2908
|
+
* The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
|
|
2909
2909
|
* @returns The `peek()` method returns the first element of the data structure, represented by the `_nodes` array at
|
|
2910
|
-
* the `_offset` index. If the data structure is empty (size is 0), it returns `
|
|
2910
|
+
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
|
|
2911
2911
|
*/
|
|
2912
2912
|
peek() {
|
|
2913
2913
|
return this.getFirst();
|
|
@@ -2920,9 +2920,9 @@ var dataStructureTyped = (() => {
|
|
|
2920
2920
|
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
|
|
2921
2921
|
* Space Complexity: O(1) - no additional space is used.
|
|
2922
2922
|
*
|
|
2923
|
-
* The `getLast` function returns the last element in an array-like data structure, or
|
|
2923
|
+
* The `getLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
|
|
2924
2924
|
* @returns The method `getLast()` returns the last element of the `_nodes` array if the array is not empty. If the
|
|
2925
|
-
* array is empty, it returns `
|
|
2925
|
+
* array is empty, it returns `undefined`.
|
|
2926
2926
|
*/
|
|
2927
2927
|
getLast() {
|
|
2928
2928
|
return this.size > 0 ? this.nodes[this.nodes.length - 1] : void 0;
|
|
@@ -2935,9 +2935,9 @@ var dataStructureTyped = (() => {
|
|
|
2935
2935
|
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
|
|
2936
2936
|
* Space Complexity: O(1) - no additional space is used.
|
|
2937
2937
|
*
|
|
2938
|
-
* The `peekLast` function returns the last element in an array-like data structure, or
|
|
2938
|
+
* The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
|
|
2939
2939
|
* @returns The method `peekLast()` returns the last element of the `_nodes` array if the array is not empty. If the
|
|
2940
|
-
* array is empty, it returns `
|
|
2940
|
+
* array is empty, it returns `undefined`.
|
|
2941
2941
|
*/
|
|
2942
2942
|
peekLast() {
|
|
2943
2943
|
return this.getLast();
|
|
@@ -2964,8 +2964,8 @@ var dataStructureTyped = (() => {
|
|
|
2964
2964
|
* Time Complexity: O(n) - same as shift().
|
|
2965
2965
|
* Space Complexity: O(1) - same as shift().
|
|
2966
2966
|
*
|
|
2967
|
-
* The `dequeue` function removes and returns the first element from a queue, or returns
|
|
2968
|
-
* @returns The method is returning a value of type E or
|
|
2967
|
+
* The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
|
|
2968
|
+
* @returns The method is returning a value of type E or undefined.
|
|
2969
2969
|
*/
|
|
2970
2970
|
dequeue() {
|
|
2971
2971
|
return this.shift();
|
|
@@ -4965,14 +4965,14 @@ var dataStructureTyped = (() => {
|
|
|
4965
4965
|
* Time Complexity: O(1) - Constant time for Map lookup.
|
|
4966
4966
|
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
|
4967
4967
|
*
|
|
4968
|
-
* The function "getVertex" returns the vertex with the specified ID or
|
|
4968
|
+
* The function "getVertex" returns the vertex with the specified ID or undefined if it doesn't exist.
|
|
4969
4969
|
* @param {VertexKey} vertexKey - The `vertexKey` parameter is the identifier of the vertex that you want to retrieve from
|
|
4970
4970
|
* the `_vertices` map.
|
|
4971
4971
|
* @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertices`
|
|
4972
|
-
* map. If the vertex does not exist, it returns `
|
|
4972
|
+
* map. If the vertex does not exist, it returns `undefined`.
|
|
4973
4973
|
*/
|
|
4974
4974
|
getVertex(vertexKey) {
|
|
4975
|
-
return this._vertices.get(vertexKey) ||
|
|
4975
|
+
return this._vertices.get(vertexKey) || void 0;
|
|
4976
4976
|
}
|
|
4977
4977
|
/**
|
|
4978
4978
|
* Time Complexity: O(1) - Constant time for Map lookup.
|
|
@@ -5204,7 +5204,7 @@ var dataStructureTyped = (() => {
|
|
|
5204
5204
|
const vertex2 = this._getVertex(v2);
|
|
5205
5205
|
const vertex1 = this._getVertex(v1);
|
|
5206
5206
|
if (!(vertex1 && vertex2)) {
|
|
5207
|
-
return
|
|
5207
|
+
return void 0;
|
|
5208
5208
|
}
|
|
5209
5209
|
const visited = /* @__PURE__ */ new Map();
|
|
5210
5210
|
const queue = new Queue([vertex1]);
|
|
@@ -5228,7 +5228,7 @@ var dataStructureTyped = (() => {
|
|
|
5228
5228
|
}
|
|
5229
5229
|
cost++;
|
|
5230
5230
|
}
|
|
5231
|
-
return
|
|
5231
|
+
return void 0;
|
|
5232
5232
|
}
|
|
5233
5233
|
}
|
|
5234
5234
|
/**
|
|
@@ -5252,7 +5252,7 @@ var dataStructureTyped = (() => {
|
|
|
5252
5252
|
* followed by iterative computation of the shortest path. This approach may result in exponential time complexity,
|
|
5253
5253
|
* so the default method is to use the Dijkstra algorithm to obtain the shortest weighted path.
|
|
5254
5254
|
* @returns The function `getMinPathBetween` returns an array of vertices (`VO[]`) representing the minimum path between
|
|
5255
|
-
* two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `
|
|
5255
|
+
* two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `undefined`.
|
|
5256
5256
|
*/
|
|
5257
5257
|
getMinPathBetween(v1, v2, isWeight, isDFS = false) {
|
|
5258
5258
|
var _a, _b;
|
|
@@ -5272,7 +5272,7 @@ var dataStructureTyped = (() => {
|
|
|
5272
5272
|
}
|
|
5273
5273
|
index++;
|
|
5274
5274
|
}
|
|
5275
|
-
return allPaths[minIndex] ||
|
|
5275
|
+
return allPaths[minIndex] || void 0;
|
|
5276
5276
|
} else {
|
|
5277
5277
|
return (_b = (_a = this.dijkstra(v1, v2, true, true)) == null ? void 0 : _a.minPath) != null ? _b : [];
|
|
5278
5278
|
}
|
|
@@ -5318,9 +5318,9 @@ var dataStructureTyped = (() => {
|
|
|
5318
5318
|
* a graph without using a heap data structure.
|
|
5319
5319
|
* @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
|
|
5320
5320
|
* vertex object or a vertex ID.
|
|
5321
|
-
* @param {VO | VertexKey |
|
|
5321
|
+
* @param {VO | VertexKey | undefined} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
|
|
5322
5322
|
* parameter that specifies the destination vertex for the Dijkstra algorithm. It can be either a vertex object or its
|
|
5323
|
-
* identifier. If no destination is provided, the value is set to `
|
|
5323
|
+
* identifier. If no destination is provided, the value is set to `undefined`.
|
|
5324
5324
|
* @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
|
|
5325
5325
|
* distance from the source vertex to the destination vertex should be calculated and returned in the result. If
|
|
5326
5326
|
* `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
|
|
@@ -5335,9 +5335,9 @@ var dataStructureTyped = (() => {
|
|
|
5335
5335
|
if (genPaths === void 0)
|
|
5336
5336
|
genPaths = false;
|
|
5337
5337
|
if (dest === void 0)
|
|
5338
|
-
dest =
|
|
5338
|
+
dest = void 0;
|
|
5339
5339
|
let minDist = Infinity;
|
|
5340
|
-
let minDest =
|
|
5340
|
+
let minDest = void 0;
|
|
5341
5341
|
let minPath = [];
|
|
5342
5342
|
const paths = [];
|
|
5343
5343
|
const vertices = this._vertices;
|
|
@@ -5345,9 +5345,9 @@ var dataStructureTyped = (() => {
|
|
|
5345
5345
|
const seen = /* @__PURE__ */ new Set();
|
|
5346
5346
|
const preMap = /* @__PURE__ */ new Map();
|
|
5347
5347
|
const srcVertex = this._getVertex(src);
|
|
5348
|
-
const destVertex = dest ? this._getVertex(dest) :
|
|
5348
|
+
const destVertex = dest ? this._getVertex(dest) : void 0;
|
|
5349
5349
|
if (!srcVertex) {
|
|
5350
|
-
return
|
|
5350
|
+
return void 0;
|
|
5351
5351
|
}
|
|
5352
5352
|
for (const vertex of vertices) {
|
|
5353
5353
|
const vertexOrKey = vertex[1];
|
|
@@ -5355,10 +5355,10 @@ var dataStructureTyped = (() => {
|
|
|
5355
5355
|
distMap.set(vertexOrKey, Infinity);
|
|
5356
5356
|
}
|
|
5357
5357
|
distMap.set(srcVertex, 0);
|
|
5358
|
-
preMap.set(srcVertex,
|
|
5358
|
+
preMap.set(srcVertex, void 0);
|
|
5359
5359
|
const getMinOfNoSeen = () => {
|
|
5360
5360
|
let min = Infinity;
|
|
5361
|
-
let minV =
|
|
5361
|
+
let minV = void 0;
|
|
5362
5362
|
for (const [key, value] of distMap) {
|
|
5363
5363
|
if (!seen.has(key)) {
|
|
5364
5364
|
if (value < min) {
|
|
@@ -5451,7 +5451,7 @@ var dataStructureTyped = (() => {
|
|
|
5451
5451
|
* optional destination vertex, and optionally returns the minimum distance, the paths, and other information.
|
|
5452
5452
|
* @param {VO | VertexKey} src - The `src` parameter represents the source vertex from which the Dijkstra algorithm will
|
|
5453
5453
|
* start. It can be either a vertex object or a vertex ID.
|
|
5454
|
-
* @param {VO | VertexKey |
|
|
5454
|
+
* @param {VO | VertexKey | undefined} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
|
|
5455
5455
|
* vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
|
|
5456
5456
|
* will calculate the shortest paths to all other vertices from the source vertex.
|
|
5457
5457
|
* @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
|
|
@@ -5469,9 +5469,9 @@ var dataStructureTyped = (() => {
|
|
|
5469
5469
|
if (genPaths === void 0)
|
|
5470
5470
|
genPaths = false;
|
|
5471
5471
|
if (dest === void 0)
|
|
5472
|
-
dest =
|
|
5472
|
+
dest = void 0;
|
|
5473
5473
|
let minDist = Infinity;
|
|
5474
|
-
let minDest =
|
|
5474
|
+
let minDest = void 0;
|
|
5475
5475
|
let minPath = [];
|
|
5476
5476
|
const paths = [];
|
|
5477
5477
|
const vertices = this._vertices;
|
|
@@ -5479,9 +5479,9 @@ var dataStructureTyped = (() => {
|
|
|
5479
5479
|
const seen = /* @__PURE__ */ new Set();
|
|
5480
5480
|
const preMap = /* @__PURE__ */ new Map();
|
|
5481
5481
|
const srcVertex = this._getVertex(src);
|
|
5482
|
-
const destVertex = dest ? this._getVertex(dest) :
|
|
5482
|
+
const destVertex = dest ? this._getVertex(dest) : void 0;
|
|
5483
5483
|
if (!srcVertex)
|
|
5484
|
-
return
|
|
5484
|
+
return void 0;
|
|
5485
5485
|
for (const vertex of vertices) {
|
|
5486
5486
|
const vertexOrKey = vertex[1];
|
|
5487
5487
|
if (vertexOrKey instanceof AbstractVertex)
|
|
@@ -5490,7 +5490,7 @@ var dataStructureTyped = (() => {
|
|
|
5490
5490
|
const heap = new PriorityQueue([], { comparator: (a, b) => a.key - b.key });
|
|
5491
5491
|
heap.add({ key: 0, value: srcVertex });
|
|
5492
5492
|
distMap.set(srcVertex, 0);
|
|
5493
|
-
preMap.set(srcVertex,
|
|
5493
|
+
preMap.set(srcVertex, void 0);
|
|
5494
5494
|
const getPaths = (minV) => {
|
|
5495
5495
|
for (const vertex of vertices) {
|
|
5496
5496
|
const vertexOrKey = vertex[1];
|
|
@@ -5624,7 +5624,7 @@ var dataStructureTyped = (() => {
|
|
|
5624
5624
|
}
|
|
5625
5625
|
}
|
|
5626
5626
|
}
|
|
5627
|
-
let minDest =
|
|
5627
|
+
let minDest = void 0;
|
|
5628
5628
|
if (getMin) {
|
|
5629
5629
|
distMap.forEach((d, v) => {
|
|
5630
5630
|
if (v !== srcVertex) {
|
|
@@ -5700,7 +5700,7 @@ var dataStructureTyped = (() => {
|
|
|
5700
5700
|
* graph.
|
|
5701
5701
|
* @returns The function `floydWarshall()` returns an object with two properties: `costs` and `predecessor`. The `costs`
|
|
5702
5702
|
* property is a 2D array of numbers representing the shortest path costs between vertices in a graph. The
|
|
5703
|
-
* `predecessor` property is a 2D array of vertices (or `
|
|
5703
|
+
* `predecessor` property is a 2D array of vertices (or `undefined`) representing the predecessor vertices in the shortest
|
|
5704
5704
|
* path between vertices in the
|
|
5705
5705
|
*/
|
|
5706
5706
|
floydWarshall() {
|
|
@@ -5713,7 +5713,7 @@ var dataStructureTyped = (() => {
|
|
|
5713
5713
|
costs[i] = [];
|
|
5714
5714
|
predecessor[i] = [];
|
|
5715
5715
|
for (let j = 0; j < n; j++) {
|
|
5716
|
-
predecessor[i][j] =
|
|
5716
|
+
predecessor[i][j] = void 0;
|
|
5717
5717
|
}
|
|
5718
5718
|
}
|
|
5719
5719
|
for (let i = 0; i < n; i++) {
|
|
@@ -5824,7 +5824,7 @@ var dataStructureTyped = (() => {
|
|
|
5824
5824
|
}
|
|
5825
5825
|
}
|
|
5826
5826
|
};
|
|
5827
|
-
dfs(root,
|
|
5827
|
+
dfs(root, void 0);
|
|
5828
5828
|
let SCCs = /* @__PURE__ */ new Map();
|
|
5829
5829
|
const getSCCs = () => {
|
|
5830
5830
|
const SCCs2 = /* @__PURE__ */ new Map();
|
|
@@ -5908,6 +5908,47 @@ var dataStructureTyped = (() => {
|
|
|
5908
5908
|
getBridges() {
|
|
5909
5909
|
return this.tarjan(false, true, false, false).bridges;
|
|
5910
5910
|
}
|
|
5911
|
+
*[Symbol.iterator]() {
|
|
5912
|
+
for (const vertex of this._vertices.values()) {
|
|
5913
|
+
yield [vertex.key, vertex.value];
|
|
5914
|
+
}
|
|
5915
|
+
}
|
|
5916
|
+
forEach(callback) {
|
|
5917
|
+
let index = 0;
|
|
5918
|
+
for (const vertex of this) {
|
|
5919
|
+
callback(vertex, index, this._vertices);
|
|
5920
|
+
index++;
|
|
5921
|
+
}
|
|
5922
|
+
}
|
|
5923
|
+
filter(predicate) {
|
|
5924
|
+
const filtered = [];
|
|
5925
|
+
let index = 0;
|
|
5926
|
+
for (const entry of this) {
|
|
5927
|
+
if (predicate(entry, index, this._vertices)) {
|
|
5928
|
+
filtered.push(entry);
|
|
5929
|
+
}
|
|
5930
|
+
index++;
|
|
5931
|
+
}
|
|
5932
|
+
return filtered;
|
|
5933
|
+
}
|
|
5934
|
+
map(callback) {
|
|
5935
|
+
const mapped = [];
|
|
5936
|
+
let index = 0;
|
|
5937
|
+
for (const entry of this) {
|
|
5938
|
+
mapped.push(callback(entry, index, this._vertices));
|
|
5939
|
+
index++;
|
|
5940
|
+
}
|
|
5941
|
+
return mapped;
|
|
5942
|
+
}
|
|
5943
|
+
reduce(callback, initialValue) {
|
|
5944
|
+
let accumulator = initialValue;
|
|
5945
|
+
let index = 0;
|
|
5946
|
+
for (const entry of this) {
|
|
5947
|
+
accumulator = callback(accumulator, entry, index, this._vertices);
|
|
5948
|
+
index++;
|
|
5949
|
+
}
|
|
5950
|
+
return accumulator;
|
|
5951
|
+
}
|
|
5911
5952
|
_addVertexOnly(newVertex) {
|
|
5912
5953
|
if (this.hasVertex(newVertex)) {
|
|
5913
5954
|
return false;
|
|
@@ -5917,7 +5958,7 @@ var dataStructureTyped = (() => {
|
|
|
5917
5958
|
}
|
|
5918
5959
|
_getVertex(vertexOrKey) {
|
|
5919
5960
|
const vertexKey = this._getVertexKey(vertexOrKey);
|
|
5920
|
-
return this._vertices.get(vertexKey) ||
|
|
5961
|
+
return this._vertices.get(vertexKey) || void 0;
|
|
5921
5962
|
}
|
|
5922
5963
|
_getVertexKey(vertexOrKey) {
|
|
5923
5964
|
return vertexOrKey instanceof AbstractVertex ? vertexOrKey.key : vertexOrKey;
|
|
@@ -5986,7 +6027,7 @@ var dataStructureTyped = (() => {
|
|
|
5986
6027
|
* @returns a new instance of a DirectedVertex object, casted as type VO.
|
|
5987
6028
|
*/
|
|
5988
6029
|
createVertex(key, value) {
|
|
5989
|
-
return new DirectedVertex(key, value
|
|
6030
|
+
return new DirectedVertex(key, value);
|
|
5990
6031
|
}
|
|
5991
6032
|
/**
|
|
5992
6033
|
* In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
|
|
@@ -6014,15 +6055,15 @@ var dataStructureTyped = (() => {
|
|
|
6014
6055
|
* Space Complexity: O(1)
|
|
6015
6056
|
*
|
|
6016
6057
|
* The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
|
|
6017
|
-
* @param {VO | VertexKey |
|
|
6018
|
-
* @param {VO | VertexKey |
|
|
6019
|
-
* destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `
|
|
6058
|
+
* @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
|
|
6059
|
+
* @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
|
|
6060
|
+
* destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `undefined` if the
|
|
6020
6061
|
* destination is not specified.
|
|
6021
|
-
* @returns the first edge found between the source and destination vertices, or
|
|
6062
|
+
* @returns the first edge found between the source and destination vertices, or undefined if no such edge is found.
|
|
6022
6063
|
*/
|
|
6023
6064
|
getEdge(srcOrKey, destOrKey) {
|
|
6024
6065
|
let edges = [];
|
|
6025
|
-
if (srcOrKey !==
|
|
6066
|
+
if (srcOrKey !== void 0 && destOrKey !== void 0) {
|
|
6026
6067
|
const src = this._getVertex(srcOrKey);
|
|
6027
6068
|
const dest = this._getVertex(destOrKey);
|
|
6028
6069
|
if (src && dest) {
|
|
@@ -6032,7 +6073,7 @@ var dataStructureTyped = (() => {
|
|
|
6032
6073
|
}
|
|
6033
6074
|
}
|
|
6034
6075
|
}
|
|
6035
|
-
return edges[0] ||
|
|
6076
|
+
return edges[0] || void 0;
|
|
6036
6077
|
}
|
|
6037
6078
|
/**
|
|
6038
6079
|
* Time Complexity: O(|E|) where |E| is the number of edges
|
|
@@ -6045,14 +6086,14 @@ var dataStructureTyped = (() => {
|
|
|
6045
6086
|
* The function removes an edge between two vertices in a graph and returns the removed edge.
|
|
6046
6087
|
* @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
|
|
6047
6088
|
* @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
|
|
6048
|
-
* @returns the removed edge (EO) if it exists, or
|
|
6089
|
+
* @returns the removed edge (EO) if it exists, or undefined if either the source or destination vertex does not exist.
|
|
6049
6090
|
*/
|
|
6050
6091
|
deleteEdgeSrcToDest(srcOrKey, destOrKey) {
|
|
6051
6092
|
const src = this._getVertex(srcOrKey);
|
|
6052
6093
|
const dest = this._getVertex(destOrKey);
|
|
6053
|
-
let removed =
|
|
6094
|
+
let removed = void 0;
|
|
6054
6095
|
if (!src || !dest) {
|
|
6055
|
-
return
|
|
6096
|
+
return void 0;
|
|
6056
6097
|
}
|
|
6057
6098
|
const srcOutEdges = this._outEdgeMap.get(src);
|
|
6058
6099
|
if (srcOutEdges) {
|
|
@@ -6060,7 +6101,7 @@ var dataStructureTyped = (() => {
|
|
|
6060
6101
|
}
|
|
6061
6102
|
const destInEdges = this._inEdgeMap.get(dest);
|
|
6062
6103
|
if (destInEdges) {
|
|
6063
|
-
removed = arrayRemove(destInEdges, (edge) => edge.src === src.key)[0] ||
|
|
6104
|
+
removed = arrayRemove(destInEdges, (edge) => edge.src === src.key)[0] || void 0;
|
|
6064
6105
|
}
|
|
6065
6106
|
return removed;
|
|
6066
6107
|
}
|
|
@@ -6072,13 +6113,13 @@ var dataStructureTyped = (() => {
|
|
|
6072
6113
|
* Time Complexity: O(|E|) where |E| is the number of edges
|
|
6073
6114
|
* Space Complexity: O(1)
|
|
6074
6115
|
*
|
|
6075
|
-
* The function removes an edge from a graph and returns the removed edge, or
|
|
6116
|
+
* The function removes an edge from a graph and returns the removed edge, or undefined if the edge was not found.
|
|
6076
6117
|
* @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
|
|
6077
6118
|
* and `dest`, which represent the source and destination vertices of the edge, respectively.
|
|
6078
|
-
* @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `
|
|
6119
|
+
* @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `undefined` if the edge does not exist.
|
|
6079
6120
|
*/
|
|
6080
6121
|
deleteEdge(edge) {
|
|
6081
|
-
let removed =
|
|
6122
|
+
let removed = void 0;
|
|
6082
6123
|
const src = this._getVertex(edge.src);
|
|
6083
6124
|
const dest = this._getVertex(edge.dest);
|
|
6084
6125
|
if (src && dest) {
|
|
@@ -6226,9 +6267,9 @@ var dataStructureTyped = (() => {
|
|
|
6226
6267
|
* Time Complexity: O(1)
|
|
6227
6268
|
* Space Complexity: O(1)
|
|
6228
6269
|
*
|
|
6229
|
-
* The function "getEdgeSrc" returns the source vertex of an edge, or
|
|
6270
|
+
* The function "getEdgeSrc" returns the source vertex of an edge, or undefined if the edge does not exist.
|
|
6230
6271
|
* @param {EO} e - The parameter "e" is of type EO, which represents an edge in a graph.
|
|
6231
|
-
* @returns either a vertex object (VO) or
|
|
6272
|
+
* @returns either a vertex object (VO) or undefined.
|
|
6232
6273
|
*/
|
|
6233
6274
|
getEdgeSrc(e) {
|
|
6234
6275
|
return this._getVertex(e.src);
|
|
@@ -6243,7 +6284,7 @@ var dataStructureTyped = (() => {
|
|
|
6243
6284
|
*
|
|
6244
6285
|
* The function "getEdgeDest" returns the destination vertex of an edge.
|
|
6245
6286
|
* @param {EO} e - The parameter "e" is of type "EO", which represents an edge in a graph.
|
|
6246
|
-
* @returns either a vertex object of type VO or
|
|
6287
|
+
* @returns either a vertex object of type VO or undefined.
|
|
6247
6288
|
*/
|
|
6248
6289
|
getEdgeDest(e) {
|
|
6249
6290
|
return this._getVertex(e.dest);
|
|
@@ -6257,12 +6298,12 @@ var dataStructureTyped = (() => {
|
|
|
6257
6298
|
* Space Complexity: O(1)
|
|
6258
6299
|
*
|
|
6259
6300
|
* The function `getDestinations` returns an array of destination vertices connected to a given vertex.
|
|
6260
|
-
* @param {VO | VertexKey |
|
|
6261
|
-
* find the destinations. It can be either a `VO` object, a `VertexKey` value, or `
|
|
6301
|
+
* @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
|
|
6302
|
+
* find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
|
|
6262
6303
|
* @returns an array of vertices (VO[]).
|
|
6263
6304
|
*/
|
|
6264
6305
|
getDestinations(vertex) {
|
|
6265
|
-
if (vertex ===
|
|
6306
|
+
if (vertex === void 0) {
|
|
6266
6307
|
return [];
|
|
6267
6308
|
}
|
|
6268
6309
|
const destinations = [];
|
|
@@ -6284,11 +6325,11 @@ var dataStructureTyped = (() => {
|
|
|
6284
6325
|
* Space Complexity: O(|V|)
|
|
6285
6326
|
*
|
|
6286
6327
|
* The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
|
|
6287
|
-
* in the sorted order, or
|
|
6328
|
+
* in the sorted order, or undefined if the graph contains a cycle.
|
|
6288
6329
|
* @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
|
|
6289
6330
|
* property to use for sorting the vertices. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
|
|
6290
6331
|
* specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
|
|
6291
|
-
* @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns
|
|
6332
|
+
* @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
|
|
6292
6333
|
*/
|
|
6293
6334
|
topologicalSort(propertyName) {
|
|
6294
6335
|
propertyName = propertyName != null ? propertyName : "key";
|
|
@@ -6318,7 +6359,7 @@ var dataStructureTyped = (() => {
|
|
|
6318
6359
|
}
|
|
6319
6360
|
}
|
|
6320
6361
|
if (hasCycle)
|
|
6321
|
-
return
|
|
6362
|
+
return void 0;
|
|
6322
6363
|
if (propertyName === "key")
|
|
6323
6364
|
sorted = sorted.map((vertex) => vertex instanceof DirectedVertex ? vertex.key : vertex);
|
|
6324
6365
|
return sorted.reverse();
|
|
@@ -6377,21 +6418,21 @@ var dataStructureTyped = (() => {
|
|
|
6377
6418
|
* Space Complexity: O(1)
|
|
6378
6419
|
*
|
|
6379
6420
|
* The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
|
|
6380
|
-
* otherwise it returns
|
|
6421
|
+
* otherwise it returns undefined.
|
|
6381
6422
|
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
|
|
6382
6423
|
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
|
|
6383
|
-
* graph. If the edge does not exist, it returns `
|
|
6424
|
+
* graph. If the edge does not exist, it returns `undefined`.
|
|
6384
6425
|
*/
|
|
6385
6426
|
getEndsOfEdge(edge) {
|
|
6386
6427
|
if (!this.hasEdge(edge.src, edge.dest)) {
|
|
6387
|
-
return
|
|
6428
|
+
return void 0;
|
|
6388
6429
|
}
|
|
6389
6430
|
const v1 = this._getVertex(edge.src);
|
|
6390
6431
|
const v2 = this._getVertex(edge.dest);
|
|
6391
6432
|
if (v1 && v2) {
|
|
6392
6433
|
return [v1, v2];
|
|
6393
6434
|
} else {
|
|
6394
|
-
return
|
|
6435
|
+
return void 0;
|
|
6395
6436
|
}
|
|
6396
6437
|
}
|
|
6397
6438
|
/**
|
|
@@ -6509,24 +6550,24 @@ var dataStructureTyped = (() => {
|
|
|
6509
6550
|
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
|
|
6510
6551
|
* Space Complexity: O(1)
|
|
6511
6552
|
*
|
|
6512
|
-
* The function `getEdge` returns the first edge that connects two vertices, or
|
|
6513
|
-
* @param {VO | VertexKey |
|
|
6514
|
-
* object), `
|
|
6515
|
-
* @param {VO | VertexKey |
|
|
6516
|
-
* object), `
|
|
6517
|
-
* @returns an edge (EO) or
|
|
6553
|
+
* The function `getEdge` returns the first edge that connects two vertices, or undefined if no such edge exists.
|
|
6554
|
+
* @param {VO | VertexKey | undefined} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
|
|
6555
|
+
* object), `undefined`, or `VertexKey` (a string or number representing the ID of a vertex).
|
|
6556
|
+
* @param {VO | VertexKey | undefined} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
|
|
6557
|
+
* object), `undefined`, or `VertexKey` (vertex ID).
|
|
6558
|
+
* @returns an edge (EO) or undefined.
|
|
6518
6559
|
*/
|
|
6519
6560
|
getEdge(v1, v2) {
|
|
6520
6561
|
var _a;
|
|
6521
6562
|
let edges = [];
|
|
6522
|
-
if (v1 !==
|
|
6563
|
+
if (v1 !== void 0 && v2 !== void 0) {
|
|
6523
6564
|
const vertex1 = this._getVertex(v1);
|
|
6524
6565
|
const vertex2 = this._getVertex(v2);
|
|
6525
6566
|
if (vertex1 && vertex2) {
|
|
6526
6567
|
edges = (_a = this._edges.get(vertex1)) == null ? void 0 : _a.filter((e) => e.vertices.includes(vertex2.key));
|
|
6527
6568
|
}
|
|
6528
6569
|
}
|
|
6529
|
-
return edges ? edges[0] ||
|
|
6570
|
+
return edges ? edges[0] || void 0 : void 0;
|
|
6530
6571
|
}
|
|
6531
6572
|
/**
|
|
6532
6573
|
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
|
|
@@ -6540,18 +6581,18 @@ var dataStructureTyped = (() => {
|
|
|
6540
6581
|
* @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
|
|
6541
6582
|
* @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
|
|
6542
6583
|
* (VertexKey). It represents the second vertex of the edge that needs to be removed.
|
|
6543
|
-
* @returns the removed edge (EO) if it exists, or
|
|
6584
|
+
* @returns the removed edge (EO) if it exists, or undefined if either of the vertices (VO) does not exist.
|
|
6544
6585
|
*/
|
|
6545
6586
|
deleteEdgeBetween(v1, v2) {
|
|
6546
6587
|
const vertex1 = this._getVertex(v1);
|
|
6547
6588
|
const vertex2 = this._getVertex(v2);
|
|
6548
6589
|
if (!vertex1 || !vertex2) {
|
|
6549
|
-
return
|
|
6590
|
+
return void 0;
|
|
6550
6591
|
}
|
|
6551
6592
|
const v1Edges = this._edges.get(vertex1);
|
|
6552
|
-
let removed =
|
|
6593
|
+
let removed = void 0;
|
|
6553
6594
|
if (v1Edges) {
|
|
6554
|
-
removed = arrayRemove(v1Edges, (e) => e.vertices.includes(vertex2.key))[0] ||
|
|
6595
|
+
removed = arrayRemove(v1Edges, (e) => e.vertices.includes(vertex2.key))[0] || void 0;
|
|
6555
6596
|
}
|
|
6556
6597
|
const v2Edges = this._edges.get(vertex2);
|
|
6557
6598
|
if (v2Edges) {
|
|
@@ -6569,7 +6610,7 @@ var dataStructureTyped = (() => {
|
|
|
6569
6610
|
*
|
|
6570
6611
|
* The deleteEdge function removes an edge between two vertices in a graph.
|
|
6571
6612
|
* @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
|
|
6572
|
-
* @returns The method is returning either the removed edge (of type EO) or
|
|
6613
|
+
* @returns The method is returning either the removed edge (of type EO) or undefined if the edge was not found.
|
|
6573
6614
|
*/
|
|
6574
6615
|
deleteEdge(edge) {
|
|
6575
6616
|
return this.deleteEdgeBetween(edge.vertices[0], edge.vertices[1]);
|
|
@@ -6674,21 +6715,21 @@ var dataStructureTyped = (() => {
|
|
|
6674
6715
|
* Space Complexity: O(1)
|
|
6675
6716
|
*
|
|
6676
6717
|
* The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
|
|
6677
|
-
* it returns
|
|
6718
|
+
* it returns undefined.
|
|
6678
6719
|
* @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
|
|
6679
6720
|
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
|
|
6680
|
-
* graph. If the edge does not exist, it returns `
|
|
6721
|
+
* graph. If the edge does not exist, it returns `undefined`.
|
|
6681
6722
|
*/
|
|
6682
6723
|
getEndsOfEdge(edge) {
|
|
6683
6724
|
if (!this.hasEdge(edge.vertices[0], edge.vertices[1])) {
|
|
6684
|
-
return
|
|
6725
|
+
return void 0;
|
|
6685
6726
|
}
|
|
6686
6727
|
const v1 = this._getVertex(edge.vertices[0]);
|
|
6687
6728
|
const v2 = this._getVertex(edge.vertices[1]);
|
|
6688
6729
|
if (v1 && v2) {
|
|
6689
6730
|
return [v1, v2];
|
|
6690
6731
|
} else {
|
|
6691
|
-
return
|
|
6732
|
+
return void 0;
|
|
6692
6733
|
}
|
|
6693
6734
|
}
|
|
6694
6735
|
/**
|
|
@@ -6706,7 +6747,7 @@ var dataStructureTyped = (() => {
|
|
|
6706
6747
|
_addEdgeOnly(edge) {
|
|
6707
6748
|
for (const end of edge.vertices) {
|
|
6708
6749
|
const endVertex = this._getVertex(end);
|
|
6709
|
-
if (endVertex ===
|
|
6750
|
+
if (endVertex === void 0)
|
|
6710
6751
|
return false;
|
|
6711
6752
|
if (endVertex) {
|
|
6712
6753
|
const edges = this._edges.get(endVertex);
|
|
@@ -9297,14 +9338,14 @@ var dataStructureTyped = (() => {
|
|
|
9297
9338
|
constructor(start, end, sum, value) {
|
|
9298
9339
|
__publicField(this, "start", 0);
|
|
9299
9340
|
__publicField(this, "end", 0);
|
|
9300
|
-
__publicField(this, "value"
|
|
9341
|
+
__publicField(this, "value");
|
|
9301
9342
|
__publicField(this, "sum", 0);
|
|
9302
|
-
__publicField(this, "left"
|
|
9303
|
-
__publicField(this, "right"
|
|
9343
|
+
__publicField(this, "left");
|
|
9344
|
+
__publicField(this, "right");
|
|
9304
9345
|
this.start = start;
|
|
9305
9346
|
this.end = end;
|
|
9306
9347
|
this.sum = sum;
|
|
9307
|
-
this.value = value ||
|
|
9348
|
+
this.value = value || void 0;
|
|
9308
9349
|
}
|
|
9309
9350
|
};
|
|
9310
9351
|
var SegmentTree = class {
|
|
@@ -9330,7 +9371,7 @@ var dataStructureTyped = (() => {
|
|
|
9330
9371
|
if (values.length > 0) {
|
|
9331
9372
|
this._root = this.build(start, end);
|
|
9332
9373
|
} else {
|
|
9333
|
-
this._root =
|
|
9374
|
+
this._root = void 0;
|
|
9334
9375
|
this._values = [];
|
|
9335
9376
|
}
|
|
9336
9377
|
}
|
|
@@ -9381,7 +9422,7 @@ var dataStructureTyped = (() => {
|
|
|
9381
9422
|
* @returns The function does not return anything.
|
|
9382
9423
|
*/
|
|
9383
9424
|
updateNode(index, sum, value) {
|
|
9384
|
-
const root = this.root ||
|
|
9425
|
+
const root = this.root || void 0;
|
|
9385
9426
|
if (!root) {
|
|
9386
9427
|
return;
|
|
9387
9428
|
}
|
|
@@ -9416,7 +9457,7 @@ var dataStructureTyped = (() => {
|
|
|
9416
9457
|
* @returns The function `querySumByRange` returns a number.
|
|
9417
9458
|
*/
|
|
9418
9459
|
querySumByRange(indexA, indexB) {
|
|
9419
|
-
const root = this.root ||
|
|
9460
|
+
const root = this.root || void 0;
|
|
9420
9461
|
if (!root) {
|
|
9421
9462
|
return 0;
|
|
9422
9463
|
}
|