data-structure-typed 1.15.1 → 1.16.1
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 +398 -27
- package/dist/data-structures/binary-tree/binary-tree.d.ts +30 -30
- package/dist/data-structures/binary-tree/binary-tree.js +55 -55
- package/dist/data-structures/binary-tree/segment-tree.d.ts +17 -17
- package/dist/data-structures/binary-tree/segment-tree.js +30 -30
- package/dist/data-structures/graph/abstract-graph.d.ts +6 -6
- package/dist/data-structures/graph/abstract-graph.js +6 -6
- package/dist/data-structures/graph/directed-graph.d.ts +4 -4
- package/dist/data-structures/graph/directed-graph.js +6 -6
- package/dist/data-structures/graph/undirected-graph.d.ts +3 -3
- package/dist/data-structures/hash/coordinate-map.d.ts +2 -2
- package/dist/data-structures/hash/coordinate-set.d.ts +2 -2
- package/dist/data-structures/heap/heap.d.ts +40 -25
- package/dist/data-structures/heap/heap.js +72 -27
- package/dist/data-structures/heap/max-heap.d.ts +3 -3
- package/dist/data-structures/heap/min-heap.d.ts +3 -3
- package/dist/data-structures/index.d.ts +1 -0
- package/dist/data-structures/index.js +1 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +9 -9
- package/dist/data-structures/linked-list/doubly-linked-list.js +12 -12
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +7 -7
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +4 -5
- package/dist/data-structures/priority-queue/max-priority-queue.js +30 -6
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +4 -5
- package/dist/data-structures/priority-queue/min-priority-queue.js +31 -6
- package/dist/data-structures/priority-queue/priority-queue.d.ts +20 -9
- package/dist/data-structures/priority-queue/priority-queue.js +34 -28
- package/dist/data-structures/queue/deque.d.ts +1 -1
- package/dist/data-structures/tree/index.d.ts +1 -0
- package/dist/data-structures/tree/index.js +17 -0
- package/dist/data-structures/tree/tree.d.ts +9 -0
- package/dist/data-structures/tree/tree.js +52 -0
- package/dist/data-structures/types/heap.d.ts +0 -4
- package/dist/utils/types/utils.d.ts +1 -3
- package/dist/utils/types/utils.js +0 -14
- package/dist/utils/utils.js +0 -197
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +92 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1367 -0
- package/docs/classes/AVLTree.html +2192 -0
- package/docs/classes/AVLTreeNode.html +574 -0
- package/docs/classes/AaTree.html +150 -0
- package/docs/classes/AbstractEdge.html +269 -0
- package/docs/classes/AbstractGraph.html +927 -0
- package/docs/classes/AbstractVertex.html +215 -0
- package/docs/classes/ArrayDeque.html +417 -0
- package/docs/classes/BST.html +2038 -0
- package/docs/classes/BSTNode.html +570 -0
- package/docs/classes/BTree.html +150 -0
- package/docs/classes/BinaryIndexedTree.html +289 -0
- package/docs/classes/BinaryTree.html +1827 -0
- package/docs/classes/BinaryTreeNode.html +533 -0
- package/docs/classes/Character.html +198 -0
- package/docs/classes/CoordinateMap.html +469 -0
- package/docs/classes/CoordinateSet.html +430 -0
- package/docs/classes/Deque.html +767 -0
- package/docs/classes/DirectedEdge.html +354 -0
- package/docs/classes/DirectedGraph.html +1243 -0
- package/docs/classes/DirectedVertex.html +226 -0
- package/docs/classes/DoublyLinkedList.html +733 -0
- package/docs/classes/DoublyLinkedListNode.html +258 -0
- package/docs/classes/Heap.html +482 -0
- package/docs/classes/HeapItem.html +233 -0
- package/docs/classes/Matrix2D.html +480 -0
- package/docs/classes/MatrixNTI2D.html +218 -0
- package/docs/classes/MaxHeap.html +500 -0
- package/docs/classes/MaxPriorityQueue.html +809 -0
- package/docs/classes/MinHeap.html +501 -0
- package/docs/classes/MinPriorityQueue.html +811 -0
- package/docs/classes/Navigator.html +291 -0
- package/docs/classes/ObjectDeque.html +423 -0
- package/docs/classes/PriorityQueue.html +733 -0
- package/docs/classes/Queue.html +370 -0
- package/docs/classes/RBTree.html +150 -0
- package/docs/classes/SegmentTree.html +345 -0
- package/docs/classes/SegmentTreeNode.html +418 -0
- package/docs/classes/SinglyLinkedList.html +1105 -0
- package/docs/classes/SinglyLinkedListNode.html +375 -0
- package/docs/classes/SplayTree.html +150 -0
- package/docs/classes/Stack.html +346 -0
- package/docs/classes/TreeMultiSet.html +2036 -0
- package/docs/classes/TreeNode.html +236 -0
- package/docs/classes/Trie.html +350 -0
- package/docs/classes/TrieNode.html +258 -0
- package/docs/classes/TwoThreeTree.html +150 -0
- package/docs/classes/UndirectedEdge.html +313 -0
- package/docs/classes/UndirectedGraph.html +1080 -0
- package/docs/classes/UndirectedVertex.html +226 -0
- package/docs/classes/Vector2D.html +783 -0
- package/docs/enums/CP.html +159 -0
- package/docs/enums/FamilyPosition.html +159 -0
- package/docs/enums/LoopType.html +160 -0
- package/docs/index.html +494 -0
- package/docs/interfaces/AVLTreeDeleted.html +161 -0
- package/docs/interfaces/BinaryTreeNodeObj.html +168 -0
- package/docs/interfaces/HeapOptions.html +167 -0
- package/docs/interfaces/IDirectedGraph.html +243 -0
- package/docs/interfaces/IGraph.html +427 -0
- package/docs/interfaces/NavigatorParams.html +197 -0
- package/docs/interfaces/PriorityQueueOptions.html +168 -0
- package/docs/modules.html +218 -0
- package/docs/types/BSTComparator.html +140 -0
- package/docs/types/BSTDeletedResult.html +137 -0
- package/docs/types/BinaryTreeDeleted.html +137 -0
- package/docs/types/BinaryTreeNodeId.html +125 -0
- package/docs/types/BinaryTreeNodePropertyName.html +125 -0
- package/docs/types/DFSOrderPattern.html +125 -0
- package/docs/types/DijkstraResult.html +145 -0
- package/docs/types/Direction.html +125 -0
- package/docs/types/DoublyLinkedListGetBy.html +125 -0
- package/docs/types/NodeOrPropertyName.html +125 -0
- package/docs/types/PriorityQueueComparator.html +145 -0
- package/docs/types/PriorityQueueDFSOrderPattern.html +125 -0
- package/docs/types/ResultByProperty.html +130 -0
- package/docs/types/ResultsByProperty.html +130 -0
- package/docs/types/SegmentTreeNodeVal.html +125 -0
- package/docs/types/SpecifyOptional.html +132 -0
- package/docs/types/Thunk.html +133 -0
- package/docs/types/ToThunkFn.html +133 -0
- package/docs/types/TopologicalStatus.html +125 -0
- package/docs/types/TreeMultiSetDeletedResult.html +137 -0
- package/docs/types/TrlAsyncFn.html +138 -0
- package/docs/types/TrlFn.html +138 -0
- package/docs/types/Turning.html +125 -0
- package/docs/types/VertexId.html +125 -0
- package/{tests/unit/data-structures/binary-tree → notes}/bst.test.ts +11 -15
- package/notes/note.md +23 -0
- package/package.json +2 -4
- package/.idea/data-structure-typed.iml +0 -14
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/src/assets/complexities-diff.jpg +0 -0
- package/src/assets/data-structure-complexities.jpg +0 -0
- package/src/assets/logo.png +0 -0
- package/src/data-structures/binary-tree/aa-tree.ts +0 -3
- package/src/data-structures/binary-tree/avl-tree.ts +0 -293
- package/src/data-structures/binary-tree/b-tree.ts +0 -3
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -69
- package/src/data-structures/binary-tree/binary-tree.ts +0 -1485
- package/src/data-structures/binary-tree/bst.ts +0 -497
- package/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
- package/src/data-structures/binary-tree/index.ts +0 -11
- package/src/data-structures/binary-tree/rb-tree.ts +0 -3
- package/src/data-structures/binary-tree/segment-tree.ts +0 -248
- package/src/data-structures/binary-tree/splay-tree.ts +0 -3
- package/src/data-structures/binary-tree/tree-multiset.ts +0 -53
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -3
- package/src/data-structures/diagrams/README.md +0 -5
- package/src/data-structures/graph/abstract-graph.ts +0 -956
- package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
- package/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
- package/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
- package/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
- package/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
- package/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
- package/src/data-structures/graph/diagrams/mst.jpg +0 -0
- package/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
- package/src/data-structures/graph/diagrams/tarjan.webp +0 -0
- package/src/data-structures/graph/directed-graph.ts +0 -424
- package/src/data-structures/graph/index.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +0 -254
- package/src/data-structures/hash/coordinate-map.ts +0 -71
- package/src/data-structures/hash/coordinate-set.ts +0 -60
- package/src/data-structures/hash/hash-table.ts +0 -1
- package/src/data-structures/hash/index.ts +0 -6
- package/src/data-structures/hash/pair.ts +0 -1
- package/src/data-structures/hash/tree-map.ts +0 -1
- package/src/data-structures/hash/tree-set.ts +0 -1
- package/src/data-structures/heap/heap.ts +0 -156
- package/src/data-structures/heap/index.ts +0 -3
- package/src/data-structures/heap/max-heap.ts +0 -31
- package/src/data-structures/heap/min-heap.ts +0 -34
- package/src/data-structures/index.ts +0 -13
- package/src/data-structures/linked-list/doubly-linked-list.ts +0 -351
- package/src/data-structures/linked-list/index.ts +0 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +0 -748
- package/src/data-structures/linked-list/skip-linked-list.ts +0 -1
- package/src/data-structures/matrix/index.ts +0 -4
- package/src/data-structures/matrix/matrix.ts +0 -27
- package/src/data-structures/matrix/matrix2d.ts +0 -208
- package/src/data-structures/matrix/navigator.ts +0 -122
- package/src/data-structures/matrix/vector2d.ts +0 -316
- package/src/data-structures/priority-queue/index.ts +0 -3
- package/src/data-structures/priority-queue/max-priority-queue.ts +0 -24
- package/src/data-structures/priority-queue/min-priority-queue.ts +0 -24
- package/src/data-structures/priority-queue/priority-queue.ts +0 -346
- package/src/data-structures/queue/deque.ts +0 -241
- package/src/data-structures/queue/index.ts +0 -2
- package/src/data-structures/queue/queue.ts +0 -120
- package/src/data-structures/stack/index.ts +0 -1
- package/src/data-structures/stack/stack.ts +0 -98
- package/src/data-structures/trie/index.ts +0 -1
- package/src/data-structures/trie/trie.ts +0 -225
- package/src/data-structures/types/abstract-graph.ts +0 -51
- package/src/data-structures/types/avl-tree.ts +0 -6
- package/src/data-structures/types/binary-tree.ts +0 -15
- package/src/data-structures/types/bst.ts +0 -5
- package/src/data-structures/types/directed-graph.ts +0 -18
- package/src/data-structures/types/doubly-linked-list.ts +0 -1
- package/src/data-structures/types/heap.ts +0 -8
- package/src/data-structures/types/index.ts +0 -13
- package/src/data-structures/types/navigator.ts +0 -13
- package/src/data-structures/types/priority-queue.ts +0 -9
- package/src/data-structures/types/segment-tree.ts +0 -1
- package/src/data-structures/types/singly-linked-list.ts +0 -1
- package/src/data-structures/types/tree-multiset.ts +0 -3
- package/src/index.ts +0 -1
- package/src/utils/index.ts +0 -2
- package/src/utils/types/index.ts +0 -1
- package/src/utils/types/utils.ts +0 -176
- package/src/utils/utils.ts +0 -290
- package/tests/unit/data-structures/graph/abstract-graph.ts +0 -0
- package/tests/unit/data-structures/graph/directed-graph.test.ts +0 -495
- package/tests/unit/data-structures/graph/index.ts +0 -3
- package/tests/unit/data-structures/graph/undirected-graph.ts +0 -0
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Heap = void 0;
|
|
3
|
+
exports.Heap = exports.HeapItem = void 0;
|
|
4
|
+
var HeapItem = /** @class */ (function () {
|
|
5
|
+
function HeapItem(priority, val) {
|
|
6
|
+
if (priority === void 0) { priority = NaN; }
|
|
7
|
+
if (val === void 0) { val = null; }
|
|
8
|
+
this._val = val;
|
|
9
|
+
this._priority = priority;
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(HeapItem.prototype, "priority", {
|
|
12
|
+
get: function () {
|
|
13
|
+
return this._priority;
|
|
14
|
+
},
|
|
15
|
+
set: function (value) {
|
|
16
|
+
this._priority = value;
|
|
17
|
+
},
|
|
18
|
+
enumerable: false,
|
|
19
|
+
configurable: true
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(HeapItem.prototype, "val", {
|
|
22
|
+
get: function () {
|
|
23
|
+
return this._val;
|
|
24
|
+
},
|
|
25
|
+
set: function (value) {
|
|
26
|
+
this._val = value;
|
|
27
|
+
},
|
|
28
|
+
enumerable: false,
|
|
29
|
+
configurable: true
|
|
30
|
+
});
|
|
31
|
+
return HeapItem;
|
|
32
|
+
}());
|
|
33
|
+
exports.HeapItem = HeapItem;
|
|
4
34
|
var Heap = /** @class */ (function () {
|
|
5
35
|
/**
|
|
6
36
|
* The function is a constructor for a class that initializes a priority callback function based on the
|
|
@@ -29,12 +59,6 @@ var Heap = /** @class */ (function () {
|
|
|
29
59
|
enumerable: false,
|
|
30
60
|
configurable: true
|
|
31
61
|
});
|
|
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
|
-
Heap.prototype.getPq = function () {
|
|
36
|
-
return this._pq;
|
|
37
|
-
};
|
|
38
62
|
Object.defineProperty(Heap.prototype, "priorityCb", {
|
|
39
63
|
get: function () {
|
|
40
64
|
return this._priorityCb;
|
|
@@ -45,12 +69,6 @@ var Heap = /** @class */ (function () {
|
|
|
45
69
|
enumerable: false,
|
|
46
70
|
configurable: true
|
|
47
71
|
});
|
|
48
|
-
/**
|
|
49
|
-
* 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.
|
|
50
|
-
*/
|
|
51
|
-
Heap.prototype.getPriorityCb = function () {
|
|
52
|
-
return this._priorityCb;
|
|
53
|
-
};
|
|
54
72
|
Object.defineProperty(Heap.prototype, "size", {
|
|
55
73
|
/**
|
|
56
74
|
* The function returns the size of a priority queue.
|
|
@@ -62,6 +80,18 @@ var Heap = /** @class */ (function () {
|
|
|
62
80
|
enumerable: false,
|
|
63
81
|
configurable: true
|
|
64
82
|
});
|
|
83
|
+
/**
|
|
84
|
+
* 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.
|
|
85
|
+
*/
|
|
86
|
+
Heap.prototype.getPq = function () {
|
|
87
|
+
return this._pq;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* 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.
|
|
91
|
+
*/
|
|
92
|
+
Heap.prototype.getPriorityCb = function () {
|
|
93
|
+
return this._priorityCb;
|
|
94
|
+
};
|
|
65
95
|
/**
|
|
66
96
|
* 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.
|
|
67
97
|
*/
|
|
@@ -77,31 +107,31 @@ var Heap = /** @class */ (function () {
|
|
|
77
107
|
};
|
|
78
108
|
/**
|
|
79
109
|
* The `peek` function returns the top item in the priority queue without removing it.
|
|
80
|
-
* @returns The `peek()` method is returning either a `HeapItem<T>` object or `null`.Returns an
|
|
110
|
+
* @returns The `peek()` method is returning either a `HeapItem<T>` object or `null`.Returns an val with the highest priority in the queue
|
|
81
111
|
*/
|
|
82
112
|
Heap.prototype.peek = function () {
|
|
83
113
|
return this._pq.peek();
|
|
84
114
|
};
|
|
85
115
|
/**
|
|
86
116
|
* The `peekLast` function returns the last item in the heap.
|
|
87
|
-
* @returns The method `peekLast()` returns either a `HeapItem<T>` object or `null`.Returns an
|
|
117
|
+
* @returns The method `peekLast()` returns either a `HeapItem<T>` object or `null`.Returns an val with the lowest priority in the queue
|
|
88
118
|
*/
|
|
89
119
|
Heap.prototype.peekLast = function () {
|
|
90
120
|
return this._pq.leaf();
|
|
91
121
|
};
|
|
92
122
|
/**
|
|
93
|
-
* The `add` function adds an
|
|
94
|
-
* @param {T}
|
|
123
|
+
* The `add` function adds an val to a priority queue with an optional priority value.
|
|
124
|
+
* @param {T} val - The `val` parameter represents the value that you want to add to the heap. It can be of any
|
|
95
125
|
* type.
|
|
96
126
|
* @param {number} [priority] - The `priority` parameter is an optional number that represents the priority of the
|
|
97
|
-
*
|
|
98
|
-
* the value of `
|
|
127
|
+
* val being added to the heap. If the `val` parameter is a number, then the `priority` parameter is set to
|
|
128
|
+
* the value of `val`. If the `val` parameter is not a number, then the
|
|
99
129
|
* @returns The `add` method returns the instance of the `Heap` class.
|
|
100
130
|
* @throws {Error} if priority is not a valid number
|
|
101
131
|
*/
|
|
102
|
-
Heap.prototype.add = function (
|
|
103
|
-
if (typeof
|
|
104
|
-
priority =
|
|
132
|
+
Heap.prototype.add = function (val, priority) {
|
|
133
|
+
if (typeof val === 'number') {
|
|
134
|
+
priority = val;
|
|
105
135
|
}
|
|
106
136
|
else {
|
|
107
137
|
if (priority === undefined) {
|
|
@@ -111,16 +141,16 @@ var Heap = /** @class */ (function () {
|
|
|
111
141
|
if (priority && Number.isNaN(+priority)) {
|
|
112
142
|
throw new Error('.add expects a numeric priority');
|
|
113
143
|
}
|
|
114
|
-
if (Number.isNaN(+priority) && Number.isNaN(this._priorityCb(
|
|
144
|
+
if (Number.isNaN(+priority) && Number.isNaN(this._priorityCb(val))) {
|
|
115
145
|
throw new Error('.add expects a numeric priority '
|
|
116
146
|
+ 'or a constructor callback that returns a number');
|
|
117
147
|
}
|
|
118
|
-
var _priority = !Number.isNaN(+priority) ? priority : this._priorityCb(
|
|
119
|
-
this._pq.add(
|
|
148
|
+
var _priority = !Number.isNaN(+priority) ? priority : this._priorityCb(val);
|
|
149
|
+
this._pq.add(new HeapItem(_priority, val));
|
|
120
150
|
return this;
|
|
121
151
|
};
|
|
122
152
|
/**
|
|
123
|
-
* The `poll` function returns the top item from a priority queue or null if the queue is empty.Removes and returns an
|
|
153
|
+
* The `poll` function returns the top item from a priority queue or null if the queue is empty.Removes and returns an val with the highest priority in the queue
|
|
124
154
|
* @returns either a HeapItem<T> object or null.
|
|
125
155
|
*/
|
|
126
156
|
Heap.prototype.poll = function () {
|
|
@@ -130,9 +160,24 @@ var Heap = /** @class */ (function () {
|
|
|
130
160
|
}
|
|
131
161
|
return top;
|
|
132
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* The function checks if a given node or value exists in the priority queue.
|
|
165
|
+
* @param {T | HeapItem<T>} node - The parameter `node` can be of type `T` or `HeapItem<T>`.
|
|
166
|
+
* @returns a boolean value.
|
|
167
|
+
*/
|
|
168
|
+
Heap.prototype.has = function (node) {
|
|
169
|
+
if (node instanceof (HeapItem)) {
|
|
170
|
+
return this.getPq().getNodes().includes(node);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
return this.getPq().getNodes().findIndex(function (item) {
|
|
174
|
+
return item.val === node;
|
|
175
|
+
}) !== -1;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
133
178
|
/**
|
|
134
179
|
* The `toArray` function returns an array of `HeapItem<T>` objects.
|
|
135
|
-
* @returns An array of HeapItem<T> objects.Returns a sorted list of
|
|
180
|
+
* @returns An array of HeapItem<T> objects.Returns a sorted list of vals
|
|
136
181
|
*/
|
|
137
182
|
Heap.prototype.toArray = function () {
|
|
138
183
|
return this._pq.toArray();
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import { Heap } from './heap';
|
|
8
|
+
import { Heap, HeapItem } from './heap';
|
|
9
9
|
import { PriorityQueue } from '../priority-queue';
|
|
10
|
-
import type {
|
|
10
|
+
import type { HeapOptions } from '../types';
|
|
11
11
|
/**
|
|
12
12
|
* @class MaxHeap
|
|
13
13
|
* @extends Heap
|
|
14
14
|
*/
|
|
15
|
-
export declare class MaxHeap<T> extends Heap<T> {
|
|
15
|
+
export declare class MaxHeap<T = number> extends Heap<T> {
|
|
16
16
|
protected _pq: PriorityQueue<HeapItem<T>>;
|
|
17
17
|
/**
|
|
18
18
|
* The constructor initializes a PriorityQueue with a custom comparator function.
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import { Heap } from './heap';
|
|
8
|
+
import { Heap, HeapItem } from './heap';
|
|
9
9
|
import { PriorityQueue } from '../priority-queue';
|
|
10
|
-
import type {
|
|
10
|
+
import type { HeapOptions } from '../types';
|
|
11
11
|
/**
|
|
12
12
|
* @class MinHeap
|
|
13
13
|
* @extends Heap
|
|
14
14
|
*/
|
|
15
|
-
export declare class MinHeap<T> extends Heap<T> {
|
|
15
|
+
export declare class MinHeap<T = number> extends Heap<T> {
|
|
16
16
|
protected _pq: PriorityQueue<HeapItem<T>>;
|
|
17
17
|
/**
|
|
18
18
|
* The constructor initializes a PriorityQueue with a comparator function that compares the priority of two HeapItem
|
|
@@ -20,6 +20,7 @@ __exportStar(require("./stack"), exports);
|
|
|
20
20
|
__exportStar(require("./queue"), exports);
|
|
21
21
|
__exportStar(require("./graph"), exports);
|
|
22
22
|
__exportStar(require("./binary-tree"), exports);
|
|
23
|
+
__exportStar(require("./tree"), exports);
|
|
23
24
|
__exportStar(require("./heap"), exports);
|
|
24
25
|
__exportStar(require("./priority-queue"), exports);
|
|
25
26
|
__exportStar(require("./matrix"), exports);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare class DoublyLinkedListNode<T> {
|
|
2
|
+
constructor(nodeValue: T);
|
|
2
3
|
protected _val: T;
|
|
3
4
|
get val(): T;
|
|
4
5
|
set val(v: T);
|
|
@@ -8,31 +9,30 @@ export declare class DoublyLinkedListNode<T> {
|
|
|
8
9
|
protected _prev: DoublyLinkedListNode<T> | null;
|
|
9
10
|
get prev(): DoublyLinkedListNode<T> | null;
|
|
10
11
|
set prev(v: DoublyLinkedListNode<T> | null);
|
|
11
|
-
constructor(nodeValue: T);
|
|
12
12
|
}
|
|
13
13
|
export declare class DoublyLinkedList<T> {
|
|
14
|
+
constructor();
|
|
14
15
|
protected _first: DoublyLinkedListNode<T> | null;
|
|
15
16
|
get first(): DoublyLinkedListNode<T> | null;
|
|
17
|
+
protected set first(v: DoublyLinkedListNode<T> | null);
|
|
18
|
+
protected _last: DoublyLinkedListNode<T> | null;
|
|
19
|
+
get last(): DoublyLinkedListNode<T> | null;
|
|
20
|
+
protected set last(v: DoublyLinkedListNode<T> | null);
|
|
21
|
+
protected _size: number;
|
|
22
|
+
get size(): number;
|
|
23
|
+
protected set size(v: number);
|
|
16
24
|
/**
|
|
17
25
|
* 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.
|
|
18
26
|
*/
|
|
19
27
|
getFirst(): DoublyLinkedListNode<T> | null;
|
|
20
|
-
protected set first(v: DoublyLinkedListNode<T> | null);
|
|
21
|
-
protected _last: DoublyLinkedListNode<T> | null;
|
|
22
|
-
get last(): DoublyLinkedListNode<T> | null;
|
|
23
28
|
/**
|
|
24
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.
|
|
25
30
|
*/
|
|
26
31
|
getLast(): DoublyLinkedListNode<T> | null;
|
|
27
|
-
protected set last(v: DoublyLinkedListNode<T> | null);
|
|
28
|
-
protected _size: number;
|
|
29
|
-
get size(): number;
|
|
30
32
|
/**
|
|
31
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.
|
|
32
34
|
*/
|
|
33
35
|
getSize(): number;
|
|
34
|
-
protected set size(v: number);
|
|
35
|
-
constructor();
|
|
36
36
|
/**
|
|
37
37
|
* The function adds a new node with a given value to the beginning of a doubly linked list.
|
|
38
38
|
* @param {T} val - The `val` parameter represents the value of the element that you want to add to the beginning of
|
|
@@ -56,12 +56,6 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
56
56
|
enumerable: false,
|
|
57
57
|
configurable: true
|
|
58
58
|
});
|
|
59
|
-
/**
|
|
60
|
-
* 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.
|
|
61
|
-
*/
|
|
62
|
-
DoublyLinkedList.prototype.getFirst = function () {
|
|
63
|
-
return this._first;
|
|
64
|
-
};
|
|
65
59
|
Object.defineProperty(DoublyLinkedList.prototype, "last", {
|
|
66
60
|
get: function () {
|
|
67
61
|
return this._last;
|
|
@@ -72,12 +66,6 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
72
66
|
enumerable: false,
|
|
73
67
|
configurable: true
|
|
74
68
|
});
|
|
75
|
-
/**
|
|
76
|
-
* 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.
|
|
77
|
-
*/
|
|
78
|
-
DoublyLinkedList.prototype.getLast = function () {
|
|
79
|
-
return this._last;
|
|
80
|
-
};
|
|
81
69
|
Object.defineProperty(DoublyLinkedList.prototype, "size", {
|
|
82
70
|
get: function () {
|
|
83
71
|
return this._size;
|
|
@@ -88,6 +76,18 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
88
76
|
enumerable: false,
|
|
89
77
|
configurable: true
|
|
90
78
|
});
|
|
79
|
+
/**
|
|
80
|
+
* 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.
|
|
81
|
+
*/
|
|
82
|
+
DoublyLinkedList.prototype.getFirst = function () {
|
|
83
|
+
return this._first;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* 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.
|
|
87
|
+
*/
|
|
88
|
+
DoublyLinkedList.prototype.getLast = function () {
|
|
89
|
+
return this._last;
|
|
90
|
+
};
|
|
91
91
|
/**
|
|
92
92
|
* 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.
|
|
93
93
|
*/
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
export declare class SinglyLinkedListNode<NodeVal = any> {
|
|
9
|
+
constructor(val: NodeVal, prev?: SinglyLinkedListNode<NodeVal> | null, next?: SinglyLinkedListNode<NodeVal> | null, list?: SinglyLinkedList<NodeVal> | null);
|
|
9
10
|
protected _val: NodeVal;
|
|
10
11
|
get val(): NodeVal;
|
|
11
12
|
set val(value: NodeVal);
|
|
@@ -18,7 +19,6 @@ export declare class SinglyLinkedListNode<NodeVal = any> {
|
|
|
18
19
|
protected _list: SinglyLinkedList<NodeVal> | null;
|
|
19
20
|
get list(): SinglyLinkedList<NodeVal> | null;
|
|
20
21
|
set list(value: SinglyLinkedList<NodeVal> | null);
|
|
21
|
-
constructor(val: NodeVal, prev?: SinglyLinkedListNode<NodeVal> | null, next?: SinglyLinkedListNode<NodeVal> | null, list?: SinglyLinkedList<NodeVal> | null);
|
|
22
22
|
get index(): number | undefined;
|
|
23
23
|
/**
|
|
24
24
|
* The `insertBefore` function inserts a new node with the given value before the current node in a singly linked list.
|
|
@@ -40,6 +40,12 @@ export declare class SinglyLinkedListNode<NodeVal = any> {
|
|
|
40
40
|
remove(): SinglyLinkedListNode<NodeVal>;
|
|
41
41
|
}
|
|
42
42
|
export declare class SinglyLinkedList<NodeVal = any> {
|
|
43
|
+
/**
|
|
44
|
+
* The constructor initializes a linked list with the given arguments as nodes.
|
|
45
|
+
* @param {NodeVal[]} args - args is a rest parameter that allows the constructor to accept an arbitrary number of
|
|
46
|
+
* arguments of type NodeVal.
|
|
47
|
+
*/
|
|
48
|
+
constructor(...args: NodeVal[]);
|
|
43
49
|
protected _head: SinglyLinkedListNode<NodeVal> | null;
|
|
44
50
|
get head(): SinglyLinkedListNode<NodeVal> | null;
|
|
45
51
|
set head(value: SinglyLinkedListNode<NodeVal> | null);
|
|
@@ -49,12 +55,6 @@ export declare class SinglyLinkedList<NodeVal = any> {
|
|
|
49
55
|
protected _size: number;
|
|
50
56
|
get size(): number;
|
|
51
57
|
set size(value: number);
|
|
52
|
-
/**
|
|
53
|
-
* The constructor initializes a linked list with the given arguments as nodes.
|
|
54
|
-
* @param {NodeVal[]} args - args is a rest parameter that allows the constructor to accept an arbitrary number of
|
|
55
|
-
* arguments of type NodeVal.
|
|
56
|
-
*/
|
|
57
|
-
constructor(...args: NodeVal[]);
|
|
58
58
|
/**
|
|
59
59
|
* The `from` function in TypeScript creates a new SinglyLinkedList instance from an iterable object.
|
|
60
60
|
* @param iterable - The `iterable` parameter is an object that can be iterated over, such as an array or a string. It
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
import { PriorityQueue } from './priority-queue';
|
|
9
9
|
import type { PriorityQueueOptions } from '../types';
|
|
10
10
|
export declare class MaxPriorityQueue<T = number> extends PriorityQueue<T> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
constructor(options?: PriorityQueueOptions<T>);
|
|
11
|
+
constructor(options?: Omit<PriorityQueueOptions<number>, 'comparator'>);
|
|
12
|
+
constructor(options: PriorityQueueOptions<T>);
|
|
13
|
+
static heapify<T extends number>(options?: Omit<PriorityQueueOptions<T>, 'comparator'>): MaxPriorityQueue<T>;
|
|
14
|
+
static heapify<T>(options: PriorityQueueOptions<T>): MaxPriorityQueue<T>;
|
|
16
15
|
}
|
|
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
17
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
29
|
exports.MaxPriorityQueue = void 0;
|
|
19
30
|
/**
|
|
@@ -27,17 +38,30 @@ var priority_queue_1 = require("./priority-queue");
|
|
|
27
38
|
var MaxPriorityQueue = /** @class */ (function (_super) {
|
|
28
39
|
__extends(MaxPriorityQueue, _super);
|
|
29
40
|
/**
|
|
30
|
-
* The constructor initializes a
|
|
31
|
-
* @param [options] -
|
|
41
|
+
* The constructor initializes a priority queue with an optional comparator function.
|
|
42
|
+
* @param [options] - The `options` parameter is an optional object that can contain various properties to configure
|
|
43
|
+
* the priority queue.
|
|
32
44
|
*/
|
|
33
45
|
function MaxPriorityQueue(options) {
|
|
34
|
-
return _super.call(this, {
|
|
35
|
-
nodes: options === null || options === void 0 ? void 0 : options.nodes, comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : function (a, b) {
|
|
46
|
+
return _super.call(this, __assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : function (a, b) {
|
|
36
47
|
var aKey = a, bKey = b;
|
|
37
48
|
return bKey - aKey;
|
|
38
|
-
}
|
|
39
|
-
}) || this;
|
|
49
|
+
} })) || this;
|
|
40
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* The function `heapify` creates a max priority queue from the given options and returns it.
|
|
53
|
+
* @param options - The `options` parameter is an object that contains configuration options for creating a priority
|
|
54
|
+
* queue. It can have the following properties:
|
|
55
|
+
* @returns a MaxPriorityQueue object.
|
|
56
|
+
*/
|
|
57
|
+
MaxPriorityQueue.heapify = function (options) {
|
|
58
|
+
var maxPQ = new MaxPriorityQueue(__assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : function (a, b) {
|
|
59
|
+
var aKey = a, bKey = b;
|
|
60
|
+
return bKey - aKey;
|
|
61
|
+
} }));
|
|
62
|
+
maxPQ._fix();
|
|
63
|
+
return maxPQ;
|
|
64
|
+
};
|
|
41
65
|
return MaxPriorityQueue;
|
|
42
66
|
}(priority_queue_1.PriorityQueue));
|
|
43
67
|
exports.MaxPriorityQueue = MaxPriorityQueue;
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
import { PriorityQueue } from './priority-queue';
|
|
9
9
|
import type { PriorityQueueOptions } from '../types';
|
|
10
10
|
export declare class MinPriorityQueue<T = number> extends PriorityQueue<T> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
constructor(options?: PriorityQueueOptions<T>);
|
|
11
|
+
constructor(options?: Omit<PriorityQueueOptions<number>, 'comparator'>);
|
|
12
|
+
constructor(options: PriorityQueueOptions<T>);
|
|
13
|
+
static heapify<T extends number>(options?: Omit<PriorityQueueOptions<T>, 'comparator'>): MinPriorityQueue<T>;
|
|
14
|
+
static heapify<T>(options: PriorityQueueOptions<T>): MinPriorityQueue<T>;
|
|
16
15
|
}
|
|
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
17
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
29
|
exports.MinPriorityQueue = void 0;
|
|
19
30
|
/**
|
|
@@ -27,17 +38,31 @@ var priority_queue_1 = require("./priority-queue");
|
|
|
27
38
|
var MinPriorityQueue = /** @class */ (function (_super) {
|
|
28
39
|
__extends(MinPriorityQueue, _super);
|
|
29
40
|
/**
|
|
30
|
-
* The constructor initializes a
|
|
31
|
-
* @param [options] -
|
|
41
|
+
* The constructor initializes a priority queue with an optional comparator function.
|
|
42
|
+
* @param [options] - The `options` parameter is an optional object that can contain various configuration options for
|
|
43
|
+
* the `PriorityQueue` constructor.
|
|
32
44
|
*/
|
|
33
45
|
function MinPriorityQueue(options) {
|
|
34
|
-
return _super.call(this, {
|
|
35
|
-
nodes: options === null || options === void 0 ? void 0 : options.nodes, comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : function (a, b) {
|
|
46
|
+
return _super.call(this, __assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : function (a, b) {
|
|
36
47
|
var aKey = a, bKey = b;
|
|
37
48
|
return aKey - bKey;
|
|
38
|
-
}
|
|
39
|
-
}) || this;
|
|
49
|
+
} })) || this;
|
|
40
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* The function `heapify` creates a new MinPriorityQueue instance and sets the comparator function based on the options
|
|
53
|
+
* provided, and then fixes the heap structure of the queue.
|
|
54
|
+
* @param options - The `options` parameter is an object that contains configuration options for creating a priority
|
|
55
|
+
* queue. It can have the following properties:
|
|
56
|
+
* @returns a MinPriorityQueue object.
|
|
57
|
+
*/
|
|
58
|
+
MinPriorityQueue.heapify = function (options) {
|
|
59
|
+
var minPQ = new MinPriorityQueue(__assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : function (a, b) {
|
|
60
|
+
var aKey = a, bKey = b;
|
|
61
|
+
return aKey - bKey;
|
|
62
|
+
} }));
|
|
63
|
+
minPQ._fix();
|
|
64
|
+
return minPQ;
|
|
65
|
+
};
|
|
41
66
|
return MinPriorityQueue;
|
|
42
67
|
}(priority_queue_1.PriorityQueue));
|
|
43
68
|
exports.MinPriorityQueue = MinPriorityQueue;
|
|
@@ -7,19 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { PriorityQueueComparator, PriorityQueueDFSOrderPattern, PriorityQueueOptions } from '../types';
|
|
9
9
|
export declare class PriorityQueue<T = number> {
|
|
10
|
-
protected _nodes: T[];
|
|
11
|
-
get nodes(): T[];
|
|
12
|
-
/**
|
|
13
|
-
* 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.
|
|
14
|
-
*/
|
|
15
|
-
getNodes(): T[];
|
|
16
|
-
protected set nodes(value: T[]);
|
|
17
10
|
/**
|
|
18
11
|
* The constructor initializes a priority queue with the given options, including an array of nodes and a comparator
|
|
19
12
|
* function.
|
|
20
13
|
* @param options - The `options` parameter is an object that contains the following properties:
|
|
21
14
|
*/
|
|
22
15
|
constructor(options: PriorityQueueOptions<T>);
|
|
16
|
+
protected _nodes: T[];
|
|
17
|
+
get nodes(): T[];
|
|
18
|
+
protected set nodes(value: T[]);
|
|
23
19
|
get size(): number;
|
|
24
20
|
/**
|
|
25
21
|
* The `heapify` function creates a new PriorityQueue instance and fixes the heap property.
|
|
@@ -37,12 +33,23 @@ export declare class PriorityQueue<T = number> {
|
|
|
37
33
|
* @returns the result of calling the `isValid()` method on a new instance of the `PriorityQueue` class.
|
|
38
34
|
*/
|
|
39
35
|
static isPriorityQueueified<T>(options: Omit<PriorityQueueOptions<T>, 'isFix'>): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 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.
|
|
38
|
+
*/
|
|
39
|
+
getNodes(): T[];
|
|
40
40
|
/**
|
|
41
41
|
* The "add" function adds a node to the heap and ensures that the heap property is maintained.
|
|
42
42
|
* @param {T} node - The parameter "node" is of type T, which means it can be any data type. It represents the node
|
|
43
43
|
* that needs to be added to the heap.
|
|
44
44
|
*/
|
|
45
45
|
add(node: T): void;
|
|
46
|
+
/**
|
|
47
|
+
* The "has" function checks if a given node is present in the list of nodes.
|
|
48
|
+
* @param {T} node - The parameter `node` is of type `T`, which means it can be any type. It represents the node that
|
|
49
|
+
* we want to check if it exists in the `nodes` array.
|
|
50
|
+
* @returns a boolean value indicating whether the given node is included in the array of nodes.
|
|
51
|
+
*/
|
|
52
|
+
has(node: T): boolean;
|
|
46
53
|
/**
|
|
47
54
|
* The `peek` function returns the first element of the `nodes` array if it exists, otherwise it returns `null`.
|
|
48
55
|
* @returns The `peek()` function is returning the first element (`T`) of the `nodes` array if the `size` is not zero.
|
|
@@ -89,8 +96,12 @@ export declare class PriorityQueue<T = number> {
|
|
|
89
96
|
*/
|
|
90
97
|
isValid(): boolean;
|
|
91
98
|
/**
|
|
92
|
-
*
|
|
93
|
-
|
|
99
|
+
* Plan to support sorting of duplicate elements.
|
|
100
|
+
*/
|
|
101
|
+
/**
|
|
102
|
+
* The function sorts the elements in a data structure and returns them in an array.
|
|
103
|
+
* Plan to support sorting of duplicate elements.
|
|
104
|
+
* @returns The `sort()` method is returning an array of type `T[]`.
|
|
94
105
|
*/
|
|
95
106
|
sort(): T[];
|
|
96
107
|
/**
|