priority-queue-typed 1.49.1 → 1.49.2
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 +11 -0
- package/dist/data-structures/base/iterable-base.js +21 -0
- package/dist/data-structures/hash/hash-map.d.ts +9 -9
- package/dist/data-structures/hash/hash-map.js +16 -15
- package/dist/data-structures/heap/heap.d.ts +6 -35
- package/dist/data-structures/heap/heap.js +10 -42
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +87 -93
- package/dist/data-structures/linked-list/doubly-linked-list.js +126 -129
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +16 -21
- package/dist/data-structures/linked-list/singly-linked-list.js +42 -42
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -2
- package/dist/data-structures/linked-list/skip-linked-list.js +2 -2
- package/dist/data-structures/queue/deque.d.ts +70 -75
- package/dist/data-structures/queue/deque.js +100 -110
- package/dist/data-structures/queue/queue.d.ts +13 -14
- package/dist/data-structures/queue/queue.js +15 -18
- package/dist/data-structures/stack/stack.d.ts +2 -3
- package/dist/data-structures/stack/stack.js +2 -5
- package/dist/data-structures/trie/trie.d.ts +1 -2
- package/dist/data-structures/trie/trie.js +2 -5
- package/package.json +1 -1
- package/src/data-structures/base/iterable-base.ts +24 -0
- package/src/data-structures/hash/hash-map.ts +27 -28
- package/src/data-structures/heap/heap.ts +19 -57
- package/src/data-structures/linked-list/doubly-linked-list.ts +138 -142
- package/src/data-structures/linked-list/singly-linked-list.ts +49 -49
- package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
- package/src/data-structures/queue/deque.ts +122 -135
- package/src/data-structures/queue/queue.ts +19 -23
- package/src/data-structures/stack/stack.ts +4 -8
- package/src/data-structures/trie/trie.ts +5 -9
|
@@ -26,22 +26,21 @@ export declare class DoublyLinkedListNode<E = any> {
|
|
|
26
26
|
*/
|
|
27
27
|
export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
28
28
|
/**
|
|
29
|
-
* The constructor initializes the linked list with an empty head, tail, and
|
|
29
|
+
* The constructor initializes the linked list with an empty head, tail, and size.
|
|
30
30
|
*/
|
|
31
31
|
constructor(elements?: Iterable<E>);
|
|
32
32
|
protected _head: DoublyLinkedListNode<E> | undefined;
|
|
33
33
|
get head(): DoublyLinkedListNode<E> | undefined;
|
|
34
34
|
protected _tail: DoublyLinkedListNode<E> | undefined;
|
|
35
35
|
get tail(): DoublyLinkedListNode<E> | undefined;
|
|
36
|
-
protected
|
|
37
|
-
get length(): number;
|
|
36
|
+
protected _size: number;
|
|
38
37
|
get size(): number;
|
|
39
38
|
/**
|
|
40
|
-
* Time Complexity: O(n), where n is the
|
|
39
|
+
* Time Complexity: O(n), where n is the size of the input array.
|
|
41
40
|
* Space Complexity: O(n)
|
|
42
41
|
*/
|
|
43
42
|
/**
|
|
44
|
-
* Time Complexity: O(n), where n is the
|
|
43
|
+
* Time Complexity: O(n), where n is the size of the input array.
|
|
45
44
|
* Space Complexity: O(n)
|
|
46
45
|
*
|
|
47
46
|
* The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
|
|
@@ -61,19 +60,7 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
61
60
|
* The push function adds a new node with the given value to the end of the doubly linked list.
|
|
62
61
|
* @param {E} value - The value to be added to the linked list.
|
|
63
62
|
*/
|
|
64
|
-
push(value: E):
|
|
65
|
-
/**
|
|
66
|
-
* Time Complexity: O(1)
|
|
67
|
-
* Space Complexity: O(1)
|
|
68
|
-
*/
|
|
69
|
-
/**
|
|
70
|
-
* Time Complexity: O(1)
|
|
71
|
-
* Space Complexity: O(1)
|
|
72
|
-
*
|
|
73
|
-
* The addLast function adds a new node with the given value to the end of the doubly linked list.
|
|
74
|
-
* @param {E} value - The value to be added to the linked list.
|
|
75
|
-
*/
|
|
76
|
-
addLast(value: E): void;
|
|
63
|
+
push(value: E): boolean;
|
|
77
64
|
/**
|
|
78
65
|
* Time Complexity: O(1)
|
|
79
66
|
* Space Complexity: O(1)
|
|
@@ -87,19 +74,6 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
87
74
|
* list is empty, it returns undefined.
|
|
88
75
|
*/
|
|
89
76
|
pop(): E | undefined;
|
|
90
|
-
/**
|
|
91
|
-
* Time Complexity: O(1)
|
|
92
|
-
* Space Complexity: O(1)
|
|
93
|
-
*/
|
|
94
|
-
/**
|
|
95
|
-
* Time Complexity: O(1)
|
|
96
|
-
* Space Complexity: O(1)
|
|
97
|
-
*
|
|
98
|
-
* The `pollLast()` function removes and returns the value of the last node in a doubly linked list.
|
|
99
|
-
* @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
|
|
100
|
-
* list is empty, it returns undefined.
|
|
101
|
-
*/
|
|
102
|
-
pollLast(): E | undefined;
|
|
103
77
|
/**
|
|
104
78
|
* Time Complexity: O(1)
|
|
105
79
|
* Space Complexity: O(1)
|
|
@@ -113,19 +87,6 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
113
87
|
* list.
|
|
114
88
|
*/
|
|
115
89
|
shift(): E | undefined;
|
|
116
|
-
/**
|
|
117
|
-
* Time Complexity: O(1)
|
|
118
|
-
* Space Complexity: O(1)
|
|
119
|
-
*/
|
|
120
|
-
/**
|
|
121
|
-
* Time Complexity: O(1)
|
|
122
|
-
* Space Complexity: O(1)
|
|
123
|
-
*
|
|
124
|
-
* The `pollFirst()` function removes and returns the value of the first node in a doubly linked list.
|
|
125
|
-
* @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
|
|
126
|
-
* list.
|
|
127
|
-
*/
|
|
128
|
-
pollFirst(): E | undefined;
|
|
129
90
|
/**
|
|
130
91
|
* Time Complexity: O(1)
|
|
131
92
|
* Space Complexity: O(1)
|
|
@@ -138,44 +99,7 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
138
99
|
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
|
|
139
100
|
* doubly linked list.
|
|
140
101
|
*/
|
|
141
|
-
unshift(value: E):
|
|
142
|
-
/**
|
|
143
|
-
* Time Complexity: O(1)
|
|
144
|
-
* Space Complexity: O(1)
|
|
145
|
-
*/
|
|
146
|
-
/**
|
|
147
|
-
* Time Complexity: O(1)
|
|
148
|
-
* Space Complexity: O(1)
|
|
149
|
-
*
|
|
150
|
-
* The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
|
|
151
|
-
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
|
|
152
|
-
* doubly linked list.
|
|
153
|
-
*/
|
|
154
|
-
addFirst(value: E): void;
|
|
155
|
-
/**
|
|
156
|
-
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
157
|
-
* Space Complexity: O(1)
|
|
158
|
-
*/
|
|
159
|
-
/**
|
|
160
|
-
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
161
|
-
* Space Complexity: O(1)
|
|
162
|
-
*
|
|
163
|
-
* The `getFirst` function returns the first node in a doubly linked list, or undefined if the list is empty.
|
|
164
|
-
* @returns The method `getFirst()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
|
|
165
|
-
*/
|
|
166
|
-
getFirst(): E | undefined;
|
|
167
|
-
/**
|
|
168
|
-
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
169
|
-
* Space Complexity: O(1)
|
|
170
|
-
*/
|
|
171
|
-
/**
|
|
172
|
-
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
173
|
-
* Space Complexity: O(1)
|
|
174
|
-
*
|
|
175
|
-
* The `getLast` function returns the last node in a doubly linked list, or undefined if the list is empty.
|
|
176
|
-
* @returns The method `getLast()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
|
|
177
|
-
*/
|
|
178
|
-
getLast(): E | undefined;
|
|
102
|
+
unshift(value: E): boolean;
|
|
179
103
|
/**
|
|
180
104
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
181
105
|
* Space Complexity: O(1)
|
|
@@ -238,7 +162,7 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
238
162
|
* @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
|
|
239
163
|
* if the index is out of bounds.
|
|
240
164
|
*/
|
|
241
|
-
|
|
165
|
+
addAt(index: number, value: E): boolean;
|
|
242
166
|
/**
|
|
243
167
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
244
168
|
* Space Complexity: O(1)
|
|
@@ -247,7 +171,7 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
247
171
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
248
172
|
* Space Complexity: O(1)
|
|
249
173
|
*
|
|
250
|
-
* The `
|
|
174
|
+
* The `addBefore` function inserts a new value before an existing value or node in a doubly linked list.
|
|
251
175
|
* @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
|
|
252
176
|
* before which the new value will be inserted. It can be either the value of the existing node or the existing node
|
|
253
177
|
* itself.
|
|
@@ -256,7 +180,7 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
256
180
|
* @returns The method returns a boolean value. It returns `true` if the insertion is successful, and `false` if the
|
|
257
181
|
* insertion fails.
|
|
258
182
|
*/
|
|
259
|
-
|
|
183
|
+
addBefore(existingValueOrNode: E | DoublyLinkedListNode<E>, newValue: E): boolean;
|
|
260
184
|
/**
|
|
261
185
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
262
186
|
* Space Complexity: O(1)
|
|
@@ -265,7 +189,7 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
265
189
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
266
190
|
* Space Complexity: O(1)
|
|
267
191
|
*
|
|
268
|
-
* The `
|
|
192
|
+
* The `addAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
|
|
269
193
|
* @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
|
|
270
194
|
* after which the new value will be inserted. It can be either the value of the existing node or the existing node
|
|
271
195
|
* itself.
|
|
@@ -273,7 +197,7 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
273
197
|
* @returns The method returns a boolean value. It returns true if the insertion is successful, and false if the
|
|
274
198
|
* existing value or node is not found in the doubly linked list.
|
|
275
199
|
*/
|
|
276
|
-
|
|
200
|
+
addAfter(existingValueOrNode: E | DoublyLinkedListNode<E>, newValue: E): boolean;
|
|
277
201
|
/**
|
|
278
202
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
279
203
|
* Space Complexity: O(1)
|
|
@@ -288,7 +212,7 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
288
212
|
* @returns The method `deleteAt` returns the value of the node that was deleted, or `undefined` if the index is out of
|
|
289
213
|
* bounds.
|
|
290
214
|
*/
|
|
291
|
-
deleteAt(index: number):
|
|
215
|
+
deleteAt(index: number): boolean;
|
|
292
216
|
/**
|
|
293
217
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
294
218
|
* Space Complexity: O(1)
|
|
@@ -305,12 +229,12 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
305
229
|
*/
|
|
306
230
|
delete(valOrNode: E | DoublyLinkedListNode<E> | undefined): boolean;
|
|
307
231
|
/**
|
|
308
|
-
* The function checks if a variable has a
|
|
232
|
+
* The function checks if a variable has a size greater than zero and returns a boolean value.
|
|
309
233
|
* @returns A boolean value is being returned.
|
|
310
234
|
*/
|
|
311
235
|
isEmpty(): boolean;
|
|
312
236
|
/**
|
|
313
|
-
* The `clear` function resets the linked list by setting the head, tail, and
|
|
237
|
+
* The `clear` function resets the linked list by setting the head, tail, and size to undefined and 0 respectively.
|
|
314
238
|
*/
|
|
315
239
|
clear(): void;
|
|
316
240
|
/**
|
|
@@ -369,7 +293,7 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
369
293
|
*
|
|
370
294
|
* The `reverse` function reverses the order of the elements in a doubly linked list.
|
|
371
295
|
*/
|
|
372
|
-
reverse():
|
|
296
|
+
reverse(): this;
|
|
373
297
|
/**
|
|
374
298
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
375
299
|
* Space Complexity: O(n)
|
|
@@ -438,11 +362,81 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
438
362
|
* object.
|
|
439
363
|
*/
|
|
440
364
|
map<T>(callback: ElementCallback<E, T>, thisArg?: any): DoublyLinkedList<T>;
|
|
365
|
+
/**
|
|
366
|
+
* Time Complexity: O(1)
|
|
367
|
+
* Space Complexity: O(1)
|
|
368
|
+
*/
|
|
369
|
+
/**
|
|
370
|
+
* Time Complexity: O(1)
|
|
371
|
+
* Space Complexity: O(1)
|
|
372
|
+
*
|
|
373
|
+
* The addLast function adds a new node with the given value to the end of the doubly linked list.
|
|
374
|
+
* @param {E} value - The value to be added to the linked list.
|
|
375
|
+
*/
|
|
376
|
+
addLast(value: E): boolean;
|
|
377
|
+
/**
|
|
378
|
+
* Time Complexity: O(1)
|
|
379
|
+
* Space Complexity: O(1)
|
|
380
|
+
*/
|
|
381
|
+
/**
|
|
382
|
+
* Time Complexity: O(1)
|
|
383
|
+
* Space Complexity: O(1)
|
|
384
|
+
*
|
|
385
|
+
* The `pollLast()` function removes and returns the value of the last node in a doubly linked list.
|
|
386
|
+
* @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
|
|
387
|
+
* list is empty, it returns undefined.
|
|
388
|
+
*/
|
|
389
|
+
pollLast(): E | undefined;
|
|
390
|
+
/**
|
|
391
|
+
* Time Complexity: O(1)
|
|
392
|
+
* Space Complexity: O(1)
|
|
393
|
+
*/
|
|
394
|
+
/**
|
|
395
|
+
* Time Complexity: O(1)
|
|
396
|
+
* Space Complexity: O(1)
|
|
397
|
+
*
|
|
398
|
+
* The `pollFirst()` function removes and returns the value of the first node in a doubly linked list.
|
|
399
|
+
* @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
|
|
400
|
+
* list.
|
|
401
|
+
*/
|
|
402
|
+
pollFirst(): E | undefined;
|
|
403
|
+
/**
|
|
404
|
+
* Time Complexity: O(1)
|
|
405
|
+
* Space Complexity: O(1)
|
|
406
|
+
*/
|
|
407
|
+
/**
|
|
408
|
+
* Time Complexity: O(1)
|
|
409
|
+
* Space Complexity: O(1)
|
|
410
|
+
*
|
|
411
|
+
* The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
|
|
412
|
+
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
|
|
413
|
+
* doubly linked list.
|
|
414
|
+
*/
|
|
415
|
+
addFirst(value: E): void;
|
|
441
416
|
/**
|
|
442
417
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
443
|
-
* Space Complexity: O(
|
|
418
|
+
* Space Complexity: O(1)
|
|
419
|
+
*/
|
|
420
|
+
/**
|
|
421
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
422
|
+
* Space Complexity: O(1)
|
|
423
|
+
*
|
|
424
|
+
* The `get first` function returns the first node in a doubly linked list, or undefined if the list is empty.
|
|
425
|
+
* @returns The method `get first()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
|
|
426
|
+
*/
|
|
427
|
+
get first(): E | undefined;
|
|
428
|
+
/**
|
|
429
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
430
|
+
* Space Complexity: O(1)
|
|
431
|
+
*/
|
|
432
|
+
/**
|
|
433
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
434
|
+
* Space Complexity: O(1)
|
|
435
|
+
*
|
|
436
|
+
* The `get last` function returns the last node in a doubly linked list, or undefined if the list is empty.
|
|
437
|
+
* @returns The method `get last()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
|
|
444
438
|
*/
|
|
445
|
-
|
|
439
|
+
get last(): E | undefined;
|
|
446
440
|
/**
|
|
447
441
|
* The function returns an iterator that iterates over the values of a linked list.
|
|
448
442
|
*/
|