min-heap-typed 1.50.1 → 1.50.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-structures/base/iterable-base.d.ts +120 -9
- package/dist/data-structures/base/iterable-base.js +143 -7
- package/dist/data-structures/binary-tree/avl-tree.d.ts +72 -47
- package/dist/data-structures/binary-tree/avl-tree.js +101 -72
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +22 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +244 -199
- package/dist/data-structures/binary-tree/binary-tree.js +484 -376
- package/dist/data-structures/binary-tree/bst.d.ts +92 -79
- package/dist/data-structures/binary-tree/bst.js +68 -76
- package/dist/data-structures/binary-tree/rb-tree.d.ts +127 -57
- package/dist/data-structures/binary-tree/rb-tree.js +152 -99
- package/dist/data-structures/binary-tree/segment-tree.d.ts +99 -6
- package/dist/data-structures/binary-tree/segment-tree.js +127 -10
- package/dist/data-structures/binary-tree/tree-multimap.d.ts +72 -58
- package/dist/data-structures/binary-tree/tree-multimap.js +102 -85
- package/dist/data-structures/graph/abstract-graph.d.ts +1 -78
- package/dist/data-structures/graph/abstract-graph.js +3 -189
- package/dist/data-structures/graph/directed-graph.d.ts +73 -0
- package/dist/data-structures/graph/directed-graph.js +131 -0
- package/dist/data-structures/graph/map-graph.d.ts +8 -0
- package/dist/data-structures/graph/map-graph.js +14 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +76 -7
- package/dist/data-structures/graph/undirected-graph.js +151 -18
- package/dist/data-structures/hash/hash-map.d.ts +254 -28
- package/dist/data-structures/hash/hash-map.js +347 -78
- package/dist/data-structures/heap/heap.d.ts +95 -25
- package/dist/data-structures/heap/heap.js +95 -26
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
- package/dist/data-structures/linked-list/doubly-linked-list.js +141 -77
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +154 -106
- package/dist/data-structures/linked-list/singly-linked-list.js +164 -115
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +63 -36
- package/dist/data-structures/linked-list/skip-linked-list.js +63 -36
- package/dist/data-structures/matrix/matrix.d.ts +35 -4
- package/dist/data-structures/matrix/matrix.js +50 -11
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
- package/dist/data-structures/priority-queue/max-priority-queue.js +10 -0
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
- package/dist/data-structures/priority-queue/min-priority-queue.js +11 -0
- package/dist/data-structures/priority-queue/priority-queue.d.ts +8 -0
- package/dist/data-structures/priority-queue/priority-queue.js +8 -0
- package/dist/data-structures/queue/deque.d.ts +139 -35
- package/dist/data-structures/queue/deque.js +200 -62
- package/dist/data-structures/queue/queue.d.ts +103 -49
- package/dist/data-structures/queue/queue.js +111 -49
- package/dist/data-structures/stack/stack.d.ts +51 -21
- package/dist/data-structures/stack/stack.js +58 -22
- package/dist/data-structures/tree/tree.d.ts +57 -3
- package/dist/data-structures/tree/tree.js +77 -11
- package/dist/data-structures/trie/trie.d.ts +135 -34
- package/dist/data-structures/trie/trie.js +153 -33
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/types/data-structures/hash/hash-map.d.ts +4 -3
- package/dist/types/utils/utils.d.ts +1 -0
- package/package.json +2 -2
- package/src/data-structures/base/iterable-base.ts +184 -19
- package/src/data-structures/binary-tree/avl-tree.ts +134 -100
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
- package/src/data-structures/binary-tree/binary-tree.ts +674 -671
- package/src/data-structures/binary-tree/bst.ts +127 -136
- package/src/data-structures/binary-tree/rb-tree.ts +199 -166
- package/src/data-structures/binary-tree/segment-tree.ts +145 -11
- package/src/data-structures/binary-tree/tree-multimap.ts +138 -115
- package/src/data-structures/graph/abstract-graph.ts +4 -211
- package/src/data-structures/graph/directed-graph.ts +152 -0
- package/src/data-structures/graph/map-graph.ts +15 -0
- package/src/data-structures/graph/undirected-graph.ts +171 -19
- package/src/data-structures/hash/hash-map.ts +389 -96
- package/src/data-structures/heap/heap.ts +97 -26
- package/src/data-structures/linked-list/doubly-linked-list.ts +156 -83
- package/src/data-structures/linked-list/singly-linked-list.ts +174 -120
- package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
- package/src/data-structures/matrix/matrix.ts +52 -12
- package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
- package/src/data-structures/priority-queue/priority-queue.ts +8 -0
- package/src/data-structures/queue/deque.ts +225 -70
- package/src/data-structures/queue/queue.ts +118 -49
- package/src/data-structures/stack/stack.ts +63 -23
- package/src/data-structures/tree/tree.ts +89 -15
- package/src/data-structures/trie/trie.ts +173 -38
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/hash/hash-map.ts +4 -3
- package/src/types/utils/utils.ts +2 -0
|
@@ -20,6 +20,14 @@ export class SkipListNode<K, V> {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export class SkipList<K, V> {
|
|
23
|
+
/**
|
|
24
|
+
* The constructor function initializes a SkipLinkedList object with optional options and elements.
|
|
25
|
+
* @param elements - The `elements` parameter is an iterable containing key-value pairs `[K, V]`. It
|
|
26
|
+
* is used to initialize the SkipLinkedList with the given key-value pairs. If no elements are
|
|
27
|
+
* provided, the SkipLinkedList will be empty.
|
|
28
|
+
* @param {SkipLinkedListOptions} [options] - The `options` parameter is an optional object that can
|
|
29
|
+
* contain two properties:
|
|
30
|
+
*/
|
|
23
31
|
constructor(elements: Iterable<[K, V]> = [], options?: SkipLinkedListOptions) {
|
|
24
32
|
if (options) {
|
|
25
33
|
const { maxLevel, probability } = options;
|
|
@@ -34,36 +42,52 @@ export class SkipList<K, V> {
|
|
|
34
42
|
|
|
35
43
|
protected _head: SkipListNode<K, V> = new SkipListNode<K, V>(undefined as any, undefined as any, this.maxLevel);
|
|
36
44
|
|
|
45
|
+
/**
|
|
46
|
+
* The function returns the head node of a SkipList.
|
|
47
|
+
* @returns The method is returning a SkipListNode object with generic key type K and value type V.
|
|
48
|
+
*/
|
|
37
49
|
get head(): SkipListNode<K, V> {
|
|
38
50
|
return this._head;
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
protected _level: number = 0;
|
|
42
54
|
|
|
55
|
+
/**
|
|
56
|
+
* The function returns the value of the protected variable _level.
|
|
57
|
+
* @returns The level property of the object.
|
|
58
|
+
*/
|
|
43
59
|
get level(): number {
|
|
44
60
|
return this._level;
|
|
45
61
|
}
|
|
46
62
|
|
|
47
63
|
protected _maxLevel: number = 16;
|
|
48
64
|
|
|
65
|
+
/**
|
|
66
|
+
* The function returns the maximum level.
|
|
67
|
+
* @returns The value of the variable `_maxLevel` is being returned.
|
|
68
|
+
*/
|
|
49
69
|
get maxLevel(): number {
|
|
50
70
|
return this._maxLevel;
|
|
51
71
|
}
|
|
52
72
|
|
|
53
73
|
protected _probability: number = 0.5;
|
|
54
74
|
|
|
75
|
+
/**
|
|
76
|
+
* The function returns the probability value.
|
|
77
|
+
* @returns The probability value stored in the protected variable `_probability` is being returned.
|
|
78
|
+
*/
|
|
55
79
|
get probability(): number {
|
|
56
80
|
return this._probability;
|
|
57
81
|
}
|
|
58
82
|
|
|
59
83
|
/**
|
|
60
|
-
* Time Complexity: O(log n)
|
|
61
|
-
* Space Complexity: O(1)
|
|
84
|
+
* Time Complexity: O(log n)
|
|
85
|
+
* Space Complexity: O(1)
|
|
62
86
|
*/
|
|
63
87
|
|
|
64
88
|
/**
|
|
65
|
-
* Time Complexity: O(1)
|
|
66
|
-
* Space Complexity: O(1)
|
|
89
|
+
* Time Complexity: O(1)
|
|
90
|
+
* Space Complexity: O(1)
|
|
67
91
|
*
|
|
68
92
|
* Get the value of the first element (the smallest element) in the Skip List.
|
|
69
93
|
* @returns The value of the first element, or undefined if the Skip List is empty.
|
|
@@ -74,13 +98,13 @@ export class SkipList<K, V> {
|
|
|
74
98
|
}
|
|
75
99
|
|
|
76
100
|
/**
|
|
77
|
-
* Time Complexity: O(log n)
|
|
78
|
-
* Space Complexity: O(1)
|
|
101
|
+
* Time Complexity: O(log n)
|
|
102
|
+
* Space Complexity: O(1)
|
|
79
103
|
*/
|
|
80
104
|
|
|
81
105
|
/**
|
|
82
|
-
* Time Complexity: O(log n)
|
|
83
|
-
* Space Complexity: O(1)
|
|
106
|
+
* Time Complexity: O(log n)
|
|
107
|
+
* Space Complexity: O(1)
|
|
84
108
|
*
|
|
85
109
|
* Get the value of the last element (the largest element) in the Skip List.
|
|
86
110
|
* @returns The value of the last element, or undefined if the Skip List is empty.
|
|
@@ -96,13 +120,13 @@ export class SkipList<K, V> {
|
|
|
96
120
|
}
|
|
97
121
|
|
|
98
122
|
/**
|
|
99
|
-
* Time Complexity: O(log n)
|
|
100
|
-
* Space Complexity: O(1)
|
|
123
|
+
* Time Complexity: O(log n)
|
|
124
|
+
* Space Complexity: O(1)
|
|
101
125
|
*/
|
|
102
126
|
|
|
103
127
|
/**
|
|
104
|
-
* Time Complexity: O(log n)
|
|
105
|
-
* Space Complexity: O(1)
|
|
128
|
+
* Time Complexity: O(log n)
|
|
129
|
+
* Space Complexity: O(1)
|
|
106
130
|
*
|
|
107
131
|
* The add function adds a new node with a given key and value to a Skip List data structure.
|
|
108
132
|
* @param {K} key - The key parameter represents the key of the node that needs to be added to the skip list.
|
|
@@ -132,13 +156,13 @@ export class SkipList<K, V> {
|
|
|
132
156
|
}
|
|
133
157
|
|
|
134
158
|
/**
|
|
135
|
-
* Time Complexity: O(log n)
|
|
136
|
-
* Space Complexity: O(1)
|
|
159
|
+
* Time Complexity: O(log n)
|
|
160
|
+
* Space Complexity: O(1)
|
|
137
161
|
*/
|
|
138
162
|
|
|
139
163
|
/**
|
|
140
|
-
* Time Complexity: O(log n)
|
|
141
|
-
* Space Complexity: O(1)
|
|
164
|
+
* Time Complexity: O(log n)
|
|
165
|
+
* Space Complexity: O(1)
|
|
142
166
|
*
|
|
143
167
|
* The function `get` retrieves the value associated with a given key from a skip list data structure.
|
|
144
168
|
* @param {K} key - The `key` parameter is the key of the element that we want to retrieve from the data structure.
|
|
@@ -163,27 +187,28 @@ export class SkipList<K, V> {
|
|
|
163
187
|
}
|
|
164
188
|
|
|
165
189
|
/**
|
|
166
|
-
* Time Complexity: O(
|
|
167
|
-
* Space Complexity: O(1)
|
|
190
|
+
* Time Complexity: O(log n)
|
|
191
|
+
* Space Complexity: O(1)
|
|
168
192
|
*/
|
|
169
193
|
|
|
170
194
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
195
|
+
* The function checks if a key exists in a data structure.
|
|
196
|
+
* @param {K} key - The parameter "key" is of type K, which represents the type of the key being
|
|
197
|
+
* checked.
|
|
198
|
+
* @returns a boolean value.
|
|
173
199
|
*/
|
|
174
|
-
|
|
175
200
|
has(key: K): boolean {
|
|
176
201
|
return this.get(key) !== undefined;
|
|
177
202
|
}
|
|
178
203
|
|
|
179
204
|
/**
|
|
180
|
-
* Time Complexity: O(log n)
|
|
181
|
-
* Space Complexity: O(1)
|
|
205
|
+
* Time Complexity: O(log n)
|
|
206
|
+
* Space Complexity: O(1)
|
|
182
207
|
*/
|
|
183
208
|
|
|
184
209
|
/**
|
|
185
|
-
* Time Complexity: O(log n)
|
|
186
|
-
* Space Complexity: O(1)
|
|
210
|
+
* Time Complexity: O(log n)
|
|
211
|
+
* Space Complexity: O(1)
|
|
187
212
|
*
|
|
188
213
|
* The `delete` function removes a node with a specific key from a Skip List data structure.
|
|
189
214
|
* @param {K} key - The key parameter represents the key of the node that needs to be removed from the skip list.
|
|
@@ -220,13 +245,13 @@ export class SkipList<K, V> {
|
|
|
220
245
|
}
|
|
221
246
|
|
|
222
247
|
/**
|
|
223
|
-
* Time Complexity: O(log n)
|
|
224
|
-
* Space Complexity: O(1)
|
|
248
|
+
* Time Complexity: O(log n)
|
|
249
|
+
* Space Complexity: O(1)
|
|
225
250
|
*/
|
|
226
251
|
|
|
227
252
|
/**
|
|
228
|
-
* Time Complexity: O(log n)
|
|
229
|
-
* Space Complexity: O(1)
|
|
253
|
+
* Time Complexity: O(log n)
|
|
254
|
+
* Space Complexity: O(1)
|
|
230
255
|
*
|
|
231
256
|
* Get the value of the first element in the Skip List that is greater than the given key.
|
|
232
257
|
* @param key - the given key.
|
|
@@ -244,13 +269,13 @@ export class SkipList<K, V> {
|
|
|
244
269
|
}
|
|
245
270
|
|
|
246
271
|
/**
|
|
247
|
-
* Time Complexity: O(log n)
|
|
248
|
-
* Space Complexity: O(1)
|
|
272
|
+
* Time Complexity: O(log n)
|
|
273
|
+
* Space Complexity: O(1)
|
|
249
274
|
*/
|
|
250
275
|
|
|
251
276
|
/**
|
|
252
|
-
* Time Complexity: O(log n)
|
|
253
|
-
* Space Complexity: O(1)
|
|
277
|
+
* Time Complexity: O(log n)
|
|
278
|
+
* Space Complexity: O(1)
|
|
254
279
|
*
|
|
255
280
|
* Get the value of the last element in the Skip List that is less than the given key.
|
|
256
281
|
* @param key - the given key.
|
|
@@ -273,13 +298,14 @@ export class SkipList<K, V> {
|
|
|
273
298
|
}
|
|
274
299
|
|
|
275
300
|
/**
|
|
276
|
-
* Time Complexity: O(maxLevel)
|
|
277
|
-
* Space Complexity: O(1)
|
|
301
|
+
* Time Complexity: O(maxLevel)
|
|
302
|
+
* Space Complexity: O(1)
|
|
303
|
+
* where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
|
|
278
304
|
*/
|
|
279
305
|
|
|
280
306
|
/**
|
|
281
|
-
* Time Complexity: O(maxLevel)
|
|
282
|
-
* Space Complexity: O(1)
|
|
307
|
+
* Time Complexity: O(maxLevel)
|
|
308
|
+
* Space Complexity: O(1)
|
|
283
309
|
*
|
|
284
310
|
* The function "_randomLevel" generates a random level based on a given probability and maximum level.
|
|
285
311
|
* @returns the level, which is a number.
|
|
@@ -42,30 +42,54 @@ export class Matrix {
|
|
|
42
42
|
|
|
43
43
|
protected _rows: number = 0;
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* The function returns the number of rows.
|
|
47
|
+
* @returns The number of rows.
|
|
48
|
+
*/
|
|
45
49
|
get rows(): number {
|
|
46
50
|
return this._rows;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
protected _cols: number = 0;
|
|
50
54
|
|
|
55
|
+
/**
|
|
56
|
+
* The function returns the value of the protected variable _cols.
|
|
57
|
+
* @returns The number of columns.
|
|
58
|
+
*/
|
|
51
59
|
get cols(): number {
|
|
52
60
|
return this._cols;
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
protected _data: number[][];
|
|
56
64
|
|
|
65
|
+
/**
|
|
66
|
+
* The function returns a two-dimensional array of numbers.
|
|
67
|
+
* @returns The data property, which is a two-dimensional array of numbers.
|
|
68
|
+
*/
|
|
57
69
|
get data(): number[][] {
|
|
58
70
|
return this._data;
|
|
59
71
|
}
|
|
60
72
|
|
|
73
|
+
/**
|
|
74
|
+
* The above function returns the value of the _addFn property.
|
|
75
|
+
* @returns The value of the property `_addFn` is being returned.
|
|
76
|
+
*/
|
|
61
77
|
get addFn() {
|
|
62
78
|
return this._addFn;
|
|
63
79
|
}
|
|
64
80
|
|
|
81
|
+
/**
|
|
82
|
+
* The function returns the value of the _subtractFn property.
|
|
83
|
+
* @returns The `_subtractFn` property is being returned.
|
|
84
|
+
*/
|
|
65
85
|
get subtractFn() {
|
|
66
86
|
return this._subtractFn;
|
|
67
87
|
}
|
|
68
88
|
|
|
89
|
+
/**
|
|
90
|
+
* The function returns the value of the _multiplyFn property.
|
|
91
|
+
* @returns The `_multiplyFn` property is being returned.
|
|
92
|
+
*/
|
|
69
93
|
get multiplyFn() {
|
|
70
94
|
return this._multiplyFn;
|
|
71
95
|
}
|
|
@@ -373,6 +397,34 @@ export class Matrix {
|
|
|
373
397
|
});
|
|
374
398
|
}
|
|
375
399
|
|
|
400
|
+
/**
|
|
401
|
+
* The function checks if a given row and column index is valid within a specified range.
|
|
402
|
+
* @param {number} row - The `row` parameter represents the row index of a two-dimensional array or
|
|
403
|
+
* matrix. It is a number that indicates the specific row in the matrix.
|
|
404
|
+
* @param {number} col - The "col" parameter represents the column index in a two-dimensional array
|
|
405
|
+
* or grid. It is used to check if the given column index is valid within the bounds of the grid.
|
|
406
|
+
* @returns A boolean value is being returned.
|
|
407
|
+
*/
|
|
408
|
+
isValidIndex(row: number, col: number): boolean {
|
|
409
|
+
return row >= 0 && row < this.rows && col >= 0 && col < this.cols;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* The `clone` function returns a new instance of the Matrix class with the same data and properties
|
|
414
|
+
* as the original instance.
|
|
415
|
+
* @returns The `clone()` method is returning a new instance of the `Matrix` class with the same data
|
|
416
|
+
* and properties as the current instance.
|
|
417
|
+
*/
|
|
418
|
+
clone(): Matrix {
|
|
419
|
+
return new Matrix(this.data, {
|
|
420
|
+
rows: this.rows,
|
|
421
|
+
cols: this.cols,
|
|
422
|
+
addFn: this.addFn,
|
|
423
|
+
subtractFn: this.subtractFn,
|
|
424
|
+
multiplyFn: this.multiplyFn
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
|
|
376
428
|
protected _addFn(a: number | undefined, b: number): number | undefined {
|
|
377
429
|
if (a === undefined) return b;
|
|
378
430
|
return a + b;
|
|
@@ -386,18 +438,6 @@ export class Matrix {
|
|
|
386
438
|
return a * b;
|
|
387
439
|
}
|
|
388
440
|
|
|
389
|
-
/**
|
|
390
|
-
* The function checks if a given row and column index is valid within a specified range.
|
|
391
|
-
* @param {number} row - The `row` parameter represents the row index of a two-dimensional array or
|
|
392
|
-
* matrix. It is a number that indicates the specific row in the matrix.
|
|
393
|
-
* @param {number} col - The "col" parameter represents the column index in a two-dimensional array
|
|
394
|
-
* or grid. It is used to check if the given column index is valid within the bounds of the grid.
|
|
395
|
-
* @returns A boolean value is being returned.
|
|
396
|
-
*/
|
|
397
|
-
protected isValidIndex(row: number, col: number): boolean {
|
|
398
|
-
return row >= 0 && row < this.rows && col >= 0 && col < this.cols;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
441
|
/**
|
|
402
442
|
* The function `_swapRows` swaps the positions of two rows in an array.
|
|
403
443
|
* @param {number} row1 - The `row1` parameter is the index of the first row that you want to swap.
|
|
@@ -9,6 +9,16 @@ import type { PriorityQueueOptions } from '../../types';
|
|
|
9
9
|
import { PriorityQueue } from './priority-queue';
|
|
10
10
|
|
|
11
11
|
export class MaxPriorityQueue<E = any> extends PriorityQueue<E> {
|
|
12
|
+
/**
|
|
13
|
+
* The constructor initializes a PriorityQueue with optional elements and options, including a
|
|
14
|
+
* comparator function.
|
|
15
|
+
* @param elements - The `elements` parameter is an iterable object that contains the initial
|
|
16
|
+
* elements to be added to the priority queue. It is optional and defaults to an empty array if not
|
|
17
|
+
* provided.
|
|
18
|
+
* @param options - The `options` parameter is an object that contains additional configuration
|
|
19
|
+
* options for the priority queue. In this case, it has a property called `comparator` which is a
|
|
20
|
+
* function used to compare elements in the priority queue.
|
|
21
|
+
*/
|
|
12
22
|
constructor(
|
|
13
23
|
elements: Iterable<E> = [],
|
|
14
24
|
options: PriorityQueueOptions<E> = {
|
|
@@ -9,6 +9,17 @@ import type { PriorityQueueOptions } from '../../types';
|
|
|
9
9
|
import { PriorityQueue } from './priority-queue';
|
|
10
10
|
|
|
11
11
|
export class MinPriorityQueue<E = any> extends PriorityQueue<E> {
|
|
12
|
+
/**
|
|
13
|
+
* The constructor initializes a PriorityQueue with optional elements and options, including a
|
|
14
|
+
* comparator function.
|
|
15
|
+
* @param elements - The `elements` parameter is an iterable object that contains the initial
|
|
16
|
+
* elements to be added to the priority queue. It is optional and defaults to an empty array if not
|
|
17
|
+
* provided.
|
|
18
|
+
* @param options - The `options` parameter is an object that contains additional configuration
|
|
19
|
+
* options for the priority queue. In this case, it has a property called `comparator` which is a
|
|
20
|
+
* function used to compare elements in the priority queue. The `comparator` function takes two
|
|
21
|
+
* parameters `a` and `b`,
|
|
22
|
+
*/
|
|
12
23
|
constructor(
|
|
13
24
|
elements: Iterable<E> = [],
|
|
14
25
|
options: PriorityQueueOptions<E> = {
|
|
@@ -17,6 +17,14 @@ import { Heap } from '../heap';
|
|
|
17
17
|
* 6. Kth Largest Element in a Data Stream: Used to maintain a min-heap of size K for quickly finding the Kth largest element in stream data
|
|
18
18
|
*/
|
|
19
19
|
export class PriorityQueue<E = any> extends Heap<E> {
|
|
20
|
+
/**
|
|
21
|
+
* The constructor initializes a priority queue with optional elements and options.
|
|
22
|
+
* @param elements - The `elements` parameter is an iterable object that contains the initial
|
|
23
|
+
* elements to be added to the priority queue. It is an optional parameter and if not provided, the
|
|
24
|
+
* priority queue will be initialized as empty.
|
|
25
|
+
* @param [options] - The `options` parameter is an optional object that can be used to customize the
|
|
26
|
+
* behavior of the priority queue. It can contain the following properties:
|
|
27
|
+
*/
|
|
20
28
|
constructor(elements: Iterable<E> = [], options?: PriorityQueueOptions<E>) {
|
|
21
29
|
super(elements, options);
|
|
22
30
|
}
|