data-structure-typed 1.17.3 → 1.18.0
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/README.md +9 -0
- package/dist/data-structures/binary-tree/avl-tree.js +4 -4
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +10 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +41 -68
- package/dist/data-structures/binary-tree/binary-tree.js +126 -103
- package/dist/data-structures/binary-tree/bst.js +18 -19
- package/dist/data-structures/binary-tree/segment-tree.d.ts +17 -39
- package/dist/data-structures/binary-tree/segment-tree.js +34 -47
- package/dist/data-structures/graph/abstract-graph.d.ts +3 -16
- package/dist/data-structures/graph/abstract-graph.js +3 -24
- package/dist/data-structures/graph/directed-graph.d.ts +3 -11
- package/dist/data-structures/graph/directed-graph.js +2 -14
- package/dist/data-structures/graph/undirected-graph.d.ts +1 -5
- package/dist/data-structures/graph/undirected-graph.js +3 -9
- package/dist/data-structures/hash/coordinate-map.d.ts +1 -5
- package/dist/data-structures/hash/coordinate-map.js +3 -9
- package/dist/data-structures/hash/coordinate-set.d.ts +1 -5
- package/dist/data-structures/hash/coordinate-set.js +3 -9
- package/dist/data-structures/hash/hash-table.d.ts +2 -1
- package/dist/data-structures/hash/hash-table.js +7 -0
- package/dist/data-structures/hash/pair.d.ts +2 -1
- package/dist/data-structures/hash/pair.js +7 -0
- package/dist/data-structures/hash/tree-map.d.ts +2 -1
- package/dist/data-structures/hash/tree-map.js +7 -0
- package/dist/data-structures/hash/tree-set.d.ts +2 -1
- package/dist/data-structures/hash/tree-set.js +7 -0
- package/dist/data-structures/heap/heap.d.ts +0 -14
- package/dist/data-structures/heap/heap.js +3 -27
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -2
- package/dist/data-structures/linked-list/doubly-linked-list.js +12 -18
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +0 -1
- package/dist/data-structures/linked-list/singly-linked-list.js +12 -15
- package/dist/data-structures/tree/tree.d.ts +12 -4
- package/dist/data-structures/tree/tree.js +44 -12
- package/dist/data-structures/trie/trie.d.ts +3 -3
- package/dist/data-structures/trie/trie.js +10 -10
- package/dist/data-structures/types/doubly-linked-list.d.ts +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/AVLTree.html +370 -224
- package/docs/classes/AVLTreeNode.html +24 -202
- package/docs/classes/AaTree.html +5 -2
- package/docs/classes/AbstractEdge.html +32 -57
- package/docs/classes/AbstractGraph.html +35 -32
- package/docs/classes/AbstractVertex.html +10 -25
- package/docs/classes/ArrayDeque.html +18 -15
- package/docs/classes/BST.html +363 -217
- package/docs/classes/BSTNode.html +24 -202
- package/docs/classes/BTree.html +5 -2
- package/docs/classes/BinaryIndexedTree.html +43 -10
- package/docs/classes/BinaryTree.html +385 -182
- package/docs/classes/BinaryTreeNode.html +64 -165
- package/docs/classes/Character.html +8 -5
- package/docs/classes/CoordinateMap.html +36 -41
- package/docs/classes/CoordinateSet.html +35 -40
- package/docs/classes/Deque.html +38 -57
- package/docs/classes/DirectedEdge.html +44 -82
- package/docs/classes/DirectedGraph.html +50 -47
- package/docs/classes/DirectedVertex.html +10 -26
- package/docs/classes/DoublyLinkedList.html +41 -58
- package/docs/classes/DoublyLinkedListNode.html +15 -12
- package/docs/classes/HashTable.html +153 -0
- package/docs/classes/Heap.html +19 -97
- package/docs/classes/HeapItem.html +12 -9
- package/docs/classes/Matrix2D.html +20 -17
- package/docs/classes/MatrixNTI2D.html +8 -5
- package/docs/classes/MaxHeap.html +19 -102
- package/docs/classes/MaxPriorityQueue.html +38 -35
- package/docs/classes/MinHeap.html +19 -102
- package/docs/classes/MinPriorityQueue.html +38 -35
- package/docs/classes/Navigator.html +14 -11
- package/docs/classes/ObjectDeque.html +29 -26
- package/docs/classes/Pair.html +153 -0
- package/docs/classes/PriorityQueue.html +36 -33
- package/docs/classes/Queue.html +18 -15
- package/docs/classes/RBTree.html +5 -2
- package/docs/classes/SegmentTree.html +116 -46
- package/docs/classes/SegmentTreeNode.html +49 -129
- package/docs/classes/SinglyLinkedList.html +38 -45
- package/docs/classes/SinglyLinkedListNode.html +12 -9
- package/docs/classes/SkipLinkedList.html +5 -2
- package/docs/classes/SplayTree.html +5 -2
- package/docs/classes/Stack.html +16 -13
- package/docs/classes/TreeMap.html +153 -0
- package/docs/classes/TreeMultiSet.html +363 -217
- package/docs/classes/TreeNode.html +112 -24
- package/docs/classes/TreeSet.html +153 -0
- package/docs/classes/Trie.html +17 -14
- package/docs/classes/TrieNode.html +20 -17
- package/docs/classes/TwoThreeTree.html +5 -2
- package/docs/classes/UndirectedEdge.html +44 -56
- package/docs/classes/UndirectedGraph.html +49 -54
- package/docs/classes/UndirectedVertex.html +10 -26
- package/docs/classes/Vector2D.html +32 -29
- package/docs/enums/CP.html +8 -5
- package/docs/enums/FamilyPosition.html +8 -5
- package/docs/enums/LoopType.html +7 -4
- package/docs/index.html +8 -1
- package/docs/interfaces/AVLTreeDeleted.html +7 -4
- package/docs/interfaces/HeapOptions.html +6 -3
- package/docs/interfaces/IDirectedGraph.html +11 -8
- package/docs/interfaces/IGraph.html +23 -20
- package/docs/interfaces/NavigatorParams.html +9 -6
- package/docs/interfaces/PriorityQueueOptions.html +8 -5
- package/docs/modules.html +8 -2
- package/docs/types/BSTComparator.html +5 -2
- package/docs/types/BSTDeletedResult.html +5 -2
- package/docs/types/BinaryTreeDeleted.html +5 -2
- package/docs/types/BinaryTreeNodeId.html +5 -2
- package/docs/types/BinaryTreeNodePropertyName.html +5 -2
- package/docs/types/DFSOrderPattern.html +5 -2
- package/docs/types/DijkstraResult.html +5 -2
- package/docs/types/Direction.html +5 -2
- package/docs/types/NodeOrPropertyName.html +5 -2
- package/docs/types/PriorityQueueComparator.html +5 -2
- package/docs/types/PriorityQueueDFSOrderPattern.html +5 -2
- package/docs/types/ResultByProperty.html +5 -2
- package/docs/types/ResultsByProperty.html +5 -2
- package/docs/types/SegmentTreeNodeVal.html +5 -2
- package/docs/types/SpecifyOptional.html +5 -2
- package/docs/types/Thunk.html +5 -2
- package/docs/types/ToThunkFn.html +5 -2
- package/docs/types/TopologicalStatus.html +5 -2
- package/docs/types/TreeMultiSetDeletedResult.html +5 -2
- package/docs/types/TrlAsyncFn.html +5 -2
- package/docs/types/TrlFn.html +5 -2
- package/docs/types/Turning.html +5 -2
- package/docs/types/VertexId.html +5 -2
- package/notes/note.md +5 -1
- package/package.json +2 -2
- package/tsconfig.json +2 -2
- package/docs/types/DoublyLinkedListGetBy.html +0 -125
|
@@ -38,7 +38,7 @@ var CP;
|
|
|
38
38
|
CP[CP["lt"] = -1] = "lt";
|
|
39
39
|
CP[CP["eq"] = 0] = "eq";
|
|
40
40
|
CP[CP["gt"] = 1] = "gt";
|
|
41
|
-
})(CP
|
|
41
|
+
})(CP || (exports.CP = CP = {}));
|
|
42
42
|
var BSTNode = /** @class */ (function (_super) {
|
|
43
43
|
__extends(BSTNode, _super);
|
|
44
44
|
function BSTNode() {
|
|
@@ -83,14 +83,13 @@ var BST = /** @class */ (function (_super) {
|
|
|
83
83
|
* @returns The method `add` returns a `BSTNode<T>` object or `null`.
|
|
84
84
|
*/
|
|
85
85
|
BST.prototype.add = function (id, val, count) {
|
|
86
|
-
var _a;
|
|
87
86
|
if (count === void 0) { count = 1; }
|
|
88
87
|
var inserted = null;
|
|
89
88
|
var newNode = this.createNode(id, val, count);
|
|
90
89
|
if (this.root === null) {
|
|
91
|
-
this.
|
|
92
|
-
this.size
|
|
93
|
-
this.count
|
|
90
|
+
this._setRoot(newNode);
|
|
91
|
+
this._setSize(this.size + 1);
|
|
92
|
+
this._setCount(this.count + count);
|
|
94
93
|
inserted = (this.root);
|
|
95
94
|
}
|
|
96
95
|
else {
|
|
@@ -101,7 +100,7 @@ var BST = /** @class */ (function (_super) {
|
|
|
101
100
|
if (this._compare(cur.id, id) === CP.eq) {
|
|
102
101
|
if (newNode) {
|
|
103
102
|
cur.count += newNode.count;
|
|
104
|
-
this.count
|
|
103
|
+
this._setCount(this.count + newNode.count);
|
|
105
104
|
cur.val = newNode.val;
|
|
106
105
|
}
|
|
107
106
|
//Duplicates are not accepted.
|
|
@@ -117,8 +116,8 @@ var BST = /** @class */ (function (_super) {
|
|
|
117
116
|
}
|
|
118
117
|
//Add to the left of the current node
|
|
119
118
|
cur.left = newNode;
|
|
120
|
-
this.size
|
|
121
|
-
this.count
|
|
119
|
+
this._setSize(this.size + 1);
|
|
120
|
+
this._setCount(this.count + newNode.count);
|
|
122
121
|
traversing = false;
|
|
123
122
|
inserted = cur.left;
|
|
124
123
|
}
|
|
@@ -137,8 +136,8 @@ var BST = /** @class */ (function (_super) {
|
|
|
137
136
|
}
|
|
138
137
|
//Add to the right of the current node
|
|
139
138
|
cur.right = newNode;
|
|
140
|
-
this.size
|
|
141
|
-
this.count
|
|
139
|
+
this._setSize(this.size + 1);
|
|
140
|
+
this._setCount(this.count + newNode.count);
|
|
142
141
|
traversing = false;
|
|
143
142
|
inserted = (cur.right);
|
|
144
143
|
}
|
|
@@ -208,13 +207,13 @@ var BST = /** @class */ (function (_super) {
|
|
|
208
207
|
var needBalanced = null, orgCurrent = curr;
|
|
209
208
|
if (curr.count > 1 && !ignoreCount) {
|
|
210
209
|
curr.count--;
|
|
211
|
-
this.count
|
|
210
|
+
this._setCount(this.count - 1);
|
|
212
211
|
}
|
|
213
212
|
else {
|
|
214
213
|
if (!curr.left) {
|
|
215
214
|
if (!parent) {
|
|
216
215
|
if (curr.right !== undefined)
|
|
217
|
-
this.
|
|
216
|
+
this._setRoot(curr.right);
|
|
218
217
|
}
|
|
219
218
|
else {
|
|
220
219
|
switch (curr.familyPosition) {
|
|
@@ -242,8 +241,8 @@ var BST = /** @class */ (function (_super) {
|
|
|
242
241
|
}
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
|
-
this.size
|
|
246
|
-
this.count
|
|
244
|
+
this._setSize(this.size - 1);
|
|
245
|
+
this._setCount(this.count - curr.count);
|
|
247
246
|
}
|
|
248
247
|
bstDeletedResult.push({ deleted: orgCurrent, needBalanced: needBalanced });
|
|
249
248
|
return bstDeletedResult;
|
|
@@ -267,7 +266,7 @@ var BST = /** @class */ (function (_super) {
|
|
|
267
266
|
if (!this.root)
|
|
268
267
|
return [];
|
|
269
268
|
var result = [];
|
|
270
|
-
if (this.
|
|
269
|
+
if (this.loopType === binary_tree_1.LoopType.recursive) {
|
|
271
270
|
var _traverse_1 = function (cur) {
|
|
272
271
|
if (_this._pushByPropertyNameStopOrNot(cur, result, nodeProperty, propertyName, onlyOne))
|
|
273
272
|
return;
|
|
@@ -340,7 +339,7 @@ var BST = /** @class */ (function (_super) {
|
|
|
340
339
|
return needSum;
|
|
341
340
|
};
|
|
342
341
|
var sum = 0;
|
|
343
|
-
if (this.
|
|
342
|
+
if (this.loopType === binary_tree_1.LoopType.recursive) {
|
|
344
343
|
var _traverse_2 = function (cur) {
|
|
345
344
|
var compared = _this._compare(cur.id, id);
|
|
346
345
|
if (compared === CP.eq) {
|
|
@@ -427,7 +426,7 @@ var BST = /** @class */ (function (_super) {
|
|
|
427
426
|
break;
|
|
428
427
|
}
|
|
429
428
|
};
|
|
430
|
-
if (this.
|
|
429
|
+
if (this.loopType === binary_tree_1.LoopType.recursive) {
|
|
431
430
|
var _traverse_3 = function (cur) {
|
|
432
431
|
var compared = _this._compare(cur.id, node.id);
|
|
433
432
|
_sumByPropertyName(cur);
|
|
@@ -468,7 +467,7 @@ var BST = /** @class */ (function (_super) {
|
|
|
468
467
|
this.clear();
|
|
469
468
|
if (sorted.length < 1)
|
|
470
469
|
return false;
|
|
471
|
-
if (this.
|
|
470
|
+
if (this.loopType === binary_tree_1.LoopType.recursive) {
|
|
472
471
|
var buildBalanceBST_1 = function (l, r) {
|
|
473
472
|
if (l > r)
|
|
474
473
|
return;
|
|
@@ -509,7 +508,7 @@ var BST = /** @class */ (function (_super) {
|
|
|
509
508
|
if (!this.root)
|
|
510
509
|
return true;
|
|
511
510
|
var balanced = true;
|
|
512
|
-
if (this.
|
|
511
|
+
if (this.loopType === binary_tree_1.LoopType.recursive) {
|
|
513
512
|
var _height_1 = function (cur) {
|
|
514
513
|
if (!cur)
|
|
515
514
|
return 0;
|
|
@@ -8,53 +8,26 @@
|
|
|
8
8
|
import type { SegmentTreeNodeVal } from '../types';
|
|
9
9
|
export declare class SegmentTreeNode {
|
|
10
10
|
constructor(start: number, end: number, sum: number, val?: SegmentTreeNodeVal | null);
|
|
11
|
-
|
|
11
|
+
private _start;
|
|
12
12
|
get start(): number;
|
|
13
13
|
set start(v: number);
|
|
14
|
-
|
|
14
|
+
private _end;
|
|
15
15
|
get end(): number;
|
|
16
16
|
set end(v: number);
|
|
17
|
-
|
|
17
|
+
private _val;
|
|
18
18
|
get val(): SegmentTreeNodeVal | null;
|
|
19
19
|
set val(v: SegmentTreeNodeVal | null);
|
|
20
|
-
|
|
20
|
+
private _sum;
|
|
21
21
|
get sum(): number;
|
|
22
22
|
set sum(v: number);
|
|
23
|
-
|
|
23
|
+
private _left;
|
|
24
24
|
get left(): SegmentTreeNode | null;
|
|
25
25
|
set left(v: SegmentTreeNode | null);
|
|
26
|
-
|
|
26
|
+
private _right;
|
|
27
27
|
get right(): SegmentTreeNode | null;
|
|
28
28
|
set right(v: SegmentTreeNode | null);
|
|
29
|
-
/**
|
|
30
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
31
|
-
*/
|
|
32
|
-
getStart(): number;
|
|
33
|
-
/**
|
|
34
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
35
|
-
*/
|
|
36
|
-
getEnd(): number;
|
|
37
|
-
/**
|
|
38
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
39
|
-
*/
|
|
40
|
-
getVal(): SegmentTreeNodeVal | null;
|
|
41
|
-
/**
|
|
42
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
43
|
-
*/
|
|
44
|
-
getSum(): number;
|
|
45
|
-
/**
|
|
46
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
47
|
-
*/
|
|
48
|
-
getLeft(): SegmentTreeNode | null;
|
|
49
|
-
/**
|
|
50
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
51
|
-
*/
|
|
52
|
-
getRight(): SegmentTreeNode | null;
|
|
53
29
|
}
|
|
54
30
|
export declare class SegmentTree {
|
|
55
|
-
protected _values: number[];
|
|
56
|
-
protected _start: number;
|
|
57
|
-
protected _end: number;
|
|
58
31
|
/**
|
|
59
32
|
* The constructor initializes the values, start, end, and root properties of an object.
|
|
60
33
|
* @param {number[]} values - An array of numbers that will be used to build a binary search tree.
|
|
@@ -65,13 +38,14 @@ export declare class SegmentTree {
|
|
|
65
38
|
* included in the range. If not provided, it defaults to the index of the last element in the "values" array.
|
|
66
39
|
*/
|
|
67
40
|
constructor(values: number[], start?: number, end?: number);
|
|
68
|
-
|
|
41
|
+
private _values;
|
|
42
|
+
get values(): number[];
|
|
43
|
+
private _start;
|
|
44
|
+
get start(): number;
|
|
45
|
+
private _end;
|
|
46
|
+
get end(): number;
|
|
47
|
+
private _root;
|
|
69
48
|
get root(): SegmentTreeNode | null;
|
|
70
|
-
set root(v: SegmentTreeNode | null);
|
|
71
|
-
/**
|
|
72
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
73
|
-
*/
|
|
74
|
-
getRoot(): SegmentTreeNode | null;
|
|
75
49
|
/**
|
|
76
50
|
* The function builds a segment tree by recursively dividing the given range into smaller segments and creating nodes
|
|
77
51
|
* for each segment.
|
|
@@ -102,4 +76,8 @@ export declare class SegmentTree {
|
|
|
102
76
|
* @returns The function `querySumByRange` returns a number.
|
|
103
77
|
*/
|
|
104
78
|
querySumByRange(indexA: number, indexB: number): number;
|
|
79
|
+
protected _setValues(value: number[]): void;
|
|
80
|
+
protected _setStart(value: number): void;
|
|
81
|
+
protected _setEnd(value: number): void;
|
|
82
|
+
protected _setRoot(v: SegmentTreeNode | null): void;
|
|
105
83
|
}
|
|
@@ -81,42 +81,6 @@ var SegmentTreeNode = /** @class */ (function () {
|
|
|
81
81
|
enumerable: false,
|
|
82
82
|
configurable: true
|
|
83
83
|
});
|
|
84
|
-
/**
|
|
85
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
86
|
-
*/
|
|
87
|
-
SegmentTreeNode.prototype.getStart = function () {
|
|
88
|
-
return this._start;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
92
|
-
*/
|
|
93
|
-
SegmentTreeNode.prototype.getEnd = function () {
|
|
94
|
-
return this._end;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
98
|
-
*/
|
|
99
|
-
SegmentTreeNode.prototype.getVal = function () {
|
|
100
|
-
return this._val;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
104
|
-
*/
|
|
105
|
-
SegmentTreeNode.prototype.getSum = function () {
|
|
106
|
-
return this._sum;
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
110
|
-
*/
|
|
111
|
-
SegmentTreeNode.prototype.getLeft = function () {
|
|
112
|
-
return this._left;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
116
|
-
*/
|
|
117
|
-
SegmentTreeNode.prototype.getRight = function () {
|
|
118
|
-
return this._right;
|
|
119
|
-
};
|
|
120
84
|
return SegmentTreeNode;
|
|
121
85
|
}());
|
|
122
86
|
exports.SegmentTreeNode = SegmentTreeNode;
|
|
@@ -140,22 +104,34 @@ var SegmentTree = /** @class */ (function () {
|
|
|
140
104
|
this._end = end;
|
|
141
105
|
this._root = this.build(start, end);
|
|
142
106
|
}
|
|
107
|
+
Object.defineProperty(SegmentTree.prototype, "values", {
|
|
108
|
+
get: function () {
|
|
109
|
+
return this._values;
|
|
110
|
+
},
|
|
111
|
+
enumerable: false,
|
|
112
|
+
configurable: true
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(SegmentTree.prototype, "start", {
|
|
115
|
+
get: function () {
|
|
116
|
+
return this._start;
|
|
117
|
+
},
|
|
118
|
+
enumerable: false,
|
|
119
|
+
configurable: true
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(SegmentTree.prototype, "end", {
|
|
122
|
+
get: function () {
|
|
123
|
+
return this._end;
|
|
124
|
+
},
|
|
125
|
+
enumerable: false,
|
|
126
|
+
configurable: true
|
|
127
|
+
});
|
|
143
128
|
Object.defineProperty(SegmentTree.prototype, "root", {
|
|
144
129
|
get: function () {
|
|
145
130
|
return this._root;
|
|
146
131
|
},
|
|
147
|
-
set: function (v) {
|
|
148
|
-
this._root = v;
|
|
149
|
-
},
|
|
150
132
|
enumerable: false,
|
|
151
133
|
configurable: true
|
|
152
134
|
});
|
|
153
|
-
/**
|
|
154
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
155
|
-
*/
|
|
156
|
-
SegmentTree.prototype.getRoot = function () {
|
|
157
|
-
return this._root;
|
|
158
|
-
};
|
|
159
135
|
/**
|
|
160
136
|
* The function builds a segment tree by recursively dividing the given range into smaller segments and creating nodes
|
|
161
137
|
* for each segment.
|
|
@@ -166,9 +142,8 @@ var SegmentTree = /** @class */ (function () {
|
|
|
166
142
|
* @returns a SegmentTreeNode object.
|
|
167
143
|
*/
|
|
168
144
|
SegmentTree.prototype.build = function (start, end) {
|
|
169
|
-
if (start === end)
|
|
145
|
+
if (start === end)
|
|
170
146
|
return new SegmentTreeNode(start, end, this._values[start]);
|
|
171
|
-
}
|
|
172
147
|
var mid = start + Math.floor((end - start) / 2);
|
|
173
148
|
var left = this.build(start, mid);
|
|
174
149
|
var right = this.build(mid + 1, end);
|
|
@@ -264,6 +239,18 @@ var SegmentTree = /** @class */ (function () {
|
|
|
264
239
|
};
|
|
265
240
|
return dfs(root, indexA, indexB);
|
|
266
241
|
};
|
|
242
|
+
SegmentTree.prototype._setValues = function (value) {
|
|
243
|
+
this._values = value;
|
|
244
|
+
};
|
|
245
|
+
SegmentTree.prototype._setStart = function (value) {
|
|
246
|
+
this._start = value;
|
|
247
|
+
};
|
|
248
|
+
SegmentTree.prototype._setEnd = function (value) {
|
|
249
|
+
this._end = value;
|
|
250
|
+
};
|
|
251
|
+
SegmentTree.prototype._setRoot = function (v) {
|
|
252
|
+
this._root = v;
|
|
253
|
+
};
|
|
267
254
|
return SegmentTree;
|
|
268
255
|
}());
|
|
269
256
|
exports.SegmentTree = SegmentTree;
|
|
@@ -4,33 +4,20 @@ export declare class AbstractVertex {
|
|
|
4
4
|
protected _id: VertexId;
|
|
5
5
|
get id(): VertexId;
|
|
6
6
|
set id(v: VertexId);
|
|
7
|
-
/**
|
|
8
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
9
|
-
*/
|
|
10
|
-
getId(): VertexId;
|
|
11
7
|
}
|
|
12
8
|
export declare abstract class AbstractEdge {
|
|
13
|
-
static DEFAULT_EDGE_WEIGHT: number;
|
|
14
9
|
/**
|
|
15
10
|
* The function is a protected constructor that initializes the weight and generates a unique hash code for an edge.
|
|
16
11
|
* @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
|
|
17
12
|
* no weight is provided, it will default to the value of `AbstractEdge.DEFAULT_EDGE_WEIGHT`.
|
|
18
13
|
*/
|
|
19
14
|
protected constructor(weight?: number);
|
|
20
|
-
|
|
15
|
+
protected _weight: number;
|
|
21
16
|
get weight(): number;
|
|
22
17
|
set weight(v: number);
|
|
23
|
-
|
|
18
|
+
protected _hashCode: string;
|
|
24
19
|
get hashCode(): string;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
28
|
-
*/
|
|
29
|
-
getWeight(): number;
|
|
30
|
-
/**
|
|
31
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
32
|
-
*/
|
|
33
|
-
getHashCode(): string;
|
|
20
|
+
protected _setHashCode(v: string): void;
|
|
34
21
|
}
|
|
35
22
|
export declare abstract class AbstractGraph<V extends AbstractVertex, E extends AbstractEdge> implements IGraph<V, E> {
|
|
36
23
|
protected _vertices: Map<VertexId, V>;
|
|
@@ -60,12 +60,6 @@ var AbstractVertex = /** @class */ (function () {
|
|
|
60
60
|
enumerable: false,
|
|
61
61
|
configurable: true
|
|
62
62
|
});
|
|
63
|
-
/**
|
|
64
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
65
|
-
*/
|
|
66
|
-
AbstractVertex.prototype.getId = function () {
|
|
67
|
-
return this._id;
|
|
68
|
-
};
|
|
69
63
|
return AbstractVertex;
|
|
70
64
|
}());
|
|
71
65
|
exports.AbstractVertex = AbstractVertex;
|
|
@@ -76,9 +70,7 @@ var AbstractEdge = /** @class */ (function () {
|
|
|
76
70
|
* no weight is provided, it will default to the value of `AbstractEdge.DEFAULT_EDGE_WEIGHT`.
|
|
77
71
|
*/
|
|
78
72
|
function AbstractEdge(weight) {
|
|
79
|
-
|
|
80
|
-
weight = AbstractEdge.DEFAULT_EDGE_WEIGHT;
|
|
81
|
-
this._weight = weight;
|
|
73
|
+
this._weight = weight !== undefined ? weight : 1;
|
|
82
74
|
this._hashCode = (0, utils_1.uuidV4)();
|
|
83
75
|
}
|
|
84
76
|
Object.defineProperty(AbstractEdge.prototype, "weight", {
|
|
@@ -95,25 +87,12 @@ var AbstractEdge = /** @class */ (function () {
|
|
|
95
87
|
get: function () {
|
|
96
88
|
return this._hashCode;
|
|
97
89
|
},
|
|
98
|
-
set: function (v) {
|
|
99
|
-
this._hashCode = v;
|
|
100
|
-
},
|
|
101
90
|
enumerable: false,
|
|
102
91
|
configurable: true
|
|
103
92
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
*/
|
|
107
|
-
AbstractEdge.prototype.getWeight = function () {
|
|
108
|
-
return this._weight;
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
112
|
-
*/
|
|
113
|
-
AbstractEdge.prototype.getHashCode = function () {
|
|
114
|
-
return this._hashCode;
|
|
93
|
+
AbstractEdge.prototype._setHashCode = function (v) {
|
|
94
|
+
this._hashCode = v;
|
|
115
95
|
};
|
|
116
|
-
AbstractEdge.DEFAULT_EDGE_WEIGHT = 1;
|
|
117
96
|
return AbstractEdge;
|
|
118
97
|
}());
|
|
119
98
|
exports.AbstractEdge = AbstractEdge;
|
|
@@ -25,14 +25,6 @@ export declare class DirectedEdge extends AbstractEdge {
|
|
|
25
25
|
private _dest;
|
|
26
26
|
get dest(): VertexId;
|
|
27
27
|
set dest(v: VertexId);
|
|
28
|
-
/**
|
|
29
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
30
|
-
*/
|
|
31
|
-
getSrc(): VertexId;
|
|
32
|
-
/**
|
|
33
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
34
|
-
*/
|
|
35
|
-
getDest(): VertexId;
|
|
36
28
|
}
|
|
37
29
|
export declare class DirectedGraph<V extends DirectedVertex, E extends DirectedEdge> extends AbstractGraph<V, E> implements IDirectedGraph<V, E> {
|
|
38
30
|
protected _outEdgeMap: Map<V, E[]>;
|
|
@@ -147,10 +139,10 @@ export declare class DirectedGraph<V extends DirectedVertex, E extends DirectedE
|
|
|
147
139
|
* when stored with adjacency matrix time: O(V^2)
|
|
148
140
|
* The `topologicalSort` function performs a topological sort on a graph and returns the sorted vertices in reverse
|
|
149
141
|
* order, or null if the graph contains a cycle.
|
|
150
|
-
* @returns The `topologicalSort()`
|
|
151
|
-
*
|
|
142
|
+
* @returns The function `topologicalSort()` returns an array of vertices in topological order if there is no cycle in
|
|
143
|
+
* the graph. If there is a cycle, it returns `null`.
|
|
152
144
|
*/
|
|
153
|
-
topologicalSort(): V
|
|
145
|
+
topologicalSort(): Array<V | VertexId> | null;
|
|
154
146
|
/**--- end find cycles --- */
|
|
155
147
|
/**
|
|
156
148
|
* The `edgeSet` function returns an array of all the edges in the graph.
|
|
@@ -111,18 +111,6 @@ var DirectedEdge = /** @class */ (function (_super) {
|
|
|
111
111
|
enumerable: false,
|
|
112
112
|
configurable: true
|
|
113
113
|
});
|
|
114
|
-
/**
|
|
115
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
116
|
-
*/
|
|
117
|
-
DirectedEdge.prototype.getSrc = function () {
|
|
118
|
-
return this._src;
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
122
|
-
*/
|
|
123
|
-
DirectedEdge.prototype.getDest = function () {
|
|
124
|
-
return this._dest;
|
|
125
|
-
};
|
|
126
114
|
return DirectedEdge;
|
|
127
115
|
}(abstract_graph_1.AbstractEdge));
|
|
128
116
|
exports.DirectedEdge = DirectedEdge;
|
|
@@ -373,8 +361,8 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
373
361
|
* when stored with adjacency matrix time: O(V^2)
|
|
374
362
|
* The `topologicalSort` function performs a topological sort on a graph and returns the sorted vertices in reverse
|
|
375
363
|
* order, or null if the graph contains a cycle.
|
|
376
|
-
* @returns The `topologicalSort()`
|
|
377
|
-
*
|
|
364
|
+
* @returns The function `topologicalSort()` returns an array of vertices in topological order if there is no cycle in
|
|
365
|
+
* the graph. If there is a cycle, it returns `null`.
|
|
378
366
|
*/
|
|
379
367
|
DirectedGraph.prototype.topologicalSort = function () {
|
|
380
368
|
var e_2, _a, e_3, _b;
|
|
@@ -30,11 +30,6 @@ export declare class UndirectedGraph<V extends UndirectedVertex, E extends Undir
|
|
|
30
30
|
constructor();
|
|
31
31
|
protected _edges: Map<V, E[]>;
|
|
32
32
|
get edges(): Map<V, E[]>;
|
|
33
|
-
protected set edges(v: Map<V, E[]>);
|
|
34
|
-
/**
|
|
35
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
36
|
-
*/
|
|
37
|
-
getEdges(): Map<V, E[]>;
|
|
38
33
|
/**
|
|
39
34
|
* The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
|
|
40
35
|
* @param {V | null | VertexId} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID
|
|
@@ -108,4 +103,5 @@ export declare class UndirectedGraph<V extends UndirectedVertex, E extends Undir
|
|
|
108
103
|
* `null`.
|
|
109
104
|
*/
|
|
110
105
|
getEndsOfEdge(edge: E): [V, V] | null;
|
|
106
|
+
protected _setEdges(v: Map<V, E[]>): void;
|
|
111
107
|
}
|
|
@@ -119,18 +119,9 @@ var UndirectedGraph = /** @class */ (function (_super) {
|
|
|
119
119
|
get: function () {
|
|
120
120
|
return this._edges;
|
|
121
121
|
},
|
|
122
|
-
set: function (v) {
|
|
123
|
-
this._edges = v;
|
|
124
|
-
},
|
|
125
122
|
enumerable: false,
|
|
126
123
|
configurable: true
|
|
127
124
|
});
|
|
128
|
-
/**
|
|
129
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
130
|
-
*/
|
|
131
|
-
UndirectedGraph.prototype.getEdges = function () {
|
|
132
|
-
return this._edges;
|
|
133
|
-
};
|
|
134
125
|
/**
|
|
135
126
|
* The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
|
|
136
127
|
* @param {V | null | VertexId} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID
|
|
@@ -327,6 +318,9 @@ var UndirectedGraph = /** @class */ (function (_super) {
|
|
|
327
318
|
return null;
|
|
328
319
|
}
|
|
329
320
|
};
|
|
321
|
+
UndirectedGraph.prototype._setEdges = function (v) {
|
|
322
|
+
this._edges = v;
|
|
323
|
+
};
|
|
330
324
|
return UndirectedGraph;
|
|
331
325
|
}(abstract_graph_1.AbstractGraph));
|
|
332
326
|
exports.UndirectedGraph = UndirectedGraph;
|
|
@@ -9,11 +9,6 @@ export declare class CoordinateMap<V> extends Map<any, V> {
|
|
|
9
9
|
constructor(joint?: string);
|
|
10
10
|
protected _joint: string;
|
|
11
11
|
get joint(): string;
|
|
12
|
-
protected set joint(v: string);
|
|
13
|
-
/**
|
|
14
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
15
|
-
*/
|
|
16
|
-
getJoint(): string;
|
|
17
12
|
/**
|
|
18
13
|
* The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
|
|
19
14
|
* key array with a specified delimiter.
|
|
@@ -46,4 +41,5 @@ export declare class CoordinateMap<V> extends Map<any, V> {
|
|
|
46
41
|
* `key` array joined together using the `_joint` property.
|
|
47
42
|
*/
|
|
48
43
|
delete(key: number[]): boolean;
|
|
44
|
+
protected _setJoint(v: string): void;
|
|
49
45
|
}
|
|
@@ -36,18 +36,9 @@ var CoordinateMap = /** @class */ (function (_super) {
|
|
|
36
36
|
get: function () {
|
|
37
37
|
return this._joint;
|
|
38
38
|
},
|
|
39
|
-
set: function (v) {
|
|
40
|
-
this._joint = v;
|
|
41
|
-
},
|
|
42
39
|
enumerable: false,
|
|
43
40
|
configurable: true
|
|
44
41
|
});
|
|
45
|
-
/**
|
|
46
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
47
|
-
*/
|
|
48
|
-
CoordinateMap.prototype.getJoint = function () {
|
|
49
|
-
return this._joint;
|
|
50
|
-
};
|
|
51
42
|
/**
|
|
52
43
|
* The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
|
|
53
44
|
* key array with a specified delimiter.
|
|
@@ -88,6 +79,9 @@ var CoordinateMap = /** @class */ (function (_super) {
|
|
|
88
79
|
CoordinateMap.prototype.delete = function (key) {
|
|
89
80
|
return _super.prototype.delete.call(this, key.join(this._joint));
|
|
90
81
|
};
|
|
82
|
+
CoordinateMap.prototype._setJoint = function (v) {
|
|
83
|
+
this._joint = v;
|
|
84
|
+
};
|
|
91
85
|
return CoordinateMap;
|
|
92
86
|
}(Map));
|
|
93
87
|
exports.CoordinateMap = CoordinateMap;
|
|
@@ -9,11 +9,6 @@ export declare class CoordinateSet extends Set {
|
|
|
9
9
|
constructor(joint?: string);
|
|
10
10
|
protected _joint: string;
|
|
11
11
|
get joint(): string;
|
|
12
|
-
protected set joint(v: string);
|
|
13
|
-
/**
|
|
14
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
15
|
-
*/
|
|
16
|
-
getJoint(): string;
|
|
17
12
|
/**
|
|
18
13
|
* The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
|
|
19
14
|
* joining its elements with a specified separator.
|
|
@@ -38,4 +33,5 @@ export declare class CoordinateSet extends Set {
|
|
|
38
33
|
* `value` array joined together using the `_joint` property.
|
|
39
34
|
*/
|
|
40
35
|
delete(value: number[]): boolean;
|
|
36
|
+
protected _setJoint(v: string): void;
|
|
41
37
|
}
|
|
@@ -36,18 +36,9 @@ var CoordinateSet = /** @class */ (function (_super) {
|
|
|
36
36
|
get: function () {
|
|
37
37
|
return this._joint;
|
|
38
38
|
},
|
|
39
|
-
set: function (v) {
|
|
40
|
-
this._joint = v;
|
|
41
|
-
},
|
|
42
39
|
enumerable: false,
|
|
43
40
|
configurable: true
|
|
44
41
|
});
|
|
45
|
-
/**
|
|
46
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
47
|
-
*/
|
|
48
|
-
CoordinateSet.prototype.getJoint = function () {
|
|
49
|
-
return this._joint;
|
|
50
|
-
};
|
|
51
42
|
/**
|
|
52
43
|
* The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
|
|
53
44
|
* joining its elements with a specified separator.
|
|
@@ -78,6 +69,9 @@ var CoordinateSet = /** @class */ (function (_super) {
|
|
|
78
69
|
CoordinateSet.prototype.delete = function (value) {
|
|
79
70
|
return _super.prototype.delete.call(this, value.join(this._joint));
|
|
80
71
|
};
|
|
72
|
+
CoordinateSet.prototype._setJoint = function (v) {
|
|
73
|
+
this._joint = v;
|
|
74
|
+
};
|
|
81
75
|
return CoordinateSet;
|
|
82
76
|
}(Set));
|
|
83
77
|
exports.CoordinateSet = CoordinateSet;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export declare class HashTable {
|
|
2
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export declare class Pair {
|
|
2
|
+
}
|