min-heap-typed 1.50.4 → 1.50.6
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 +10 -8
- package/dist/data-structures/base/iterable-base.js +8 -12
- package/dist/data-structures/binary-tree/binary-tree.js +19 -19
- package/dist/data-structures/binary-tree/rb-tree.d.ts +158 -135
- package/dist/data-structures/binary-tree/rb-tree.js +415 -386
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +1 -0
- package/dist/data-structures/binary-tree/tree-multi-map.js +84 -76
- package/dist/data-structures/graph/abstract-graph.d.ts +1 -0
- package/dist/data-structures/graph/abstract-graph.js +3 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +14 -76
- package/dist/data-structures/linked-list/doubly-linked-list.js +16 -86
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +27 -69
- package/dist/data-structures/linked-list/singly-linked-list.js +35 -79
- package/dist/data-structures/queue/deque.d.ts +0 -53
- package/dist/data-structures/queue/deque.js +0 -61
- package/dist/data-structures/queue/queue.d.ts +0 -70
- package/dist/data-structures/queue/queue.js +0 -87
- package/package.json +2 -2
- package/src/data-structures/base/iterable-base.ts +14 -10
- package/src/data-structures/binary-tree/binary-tree.ts +19 -19
- package/src/data-structures/binary-tree/rb-tree.ts +437 -395
- package/src/data-structures/binary-tree/tree-multi-map.ts +85 -82
- package/src/data-structures/graph/abstract-graph.ts +4 -0
- package/src/data-structures/heap/heap.ts +1 -1
- package/src/data-structures/linked-list/doubly-linked-list.ts +16 -94
- package/src/data-structures/linked-list/singly-linked-list.ts +35 -87
- package/src/data-structures/queue/deque.ts +0 -67
- package/src/data-structures/queue/queue.ts +0 -98
|
@@ -178,72 +178,6 @@ export class Queue<E = any> extends IterableElementBase<E> {
|
|
|
178
178
|
return spliced.length === 1;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
/**
|
|
182
|
-
* Time Complexity: O(1)
|
|
183
|
-
* Space Complexity: O(1)
|
|
184
|
-
*/
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Time Complexity: O(1)
|
|
188
|
-
* Space Complexity: O(1)
|
|
189
|
-
*
|
|
190
|
-
* The `peek` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
|
|
191
|
-
* @returns The `peek()` method returns the first element of the data structure, represented by the `_elements` array at
|
|
192
|
-
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
|
|
193
|
-
*/
|
|
194
|
-
peek(): E | undefined {
|
|
195
|
-
return this.first;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Time Complexity: O(1)
|
|
200
|
-
* Space Complexity: O(1)
|
|
201
|
-
*/
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Time Complexity: O(1)
|
|
205
|
-
* Space Complexity: O(1)
|
|
206
|
-
*
|
|
207
|
-
* The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
|
|
208
|
-
* @returns The method `peekLast()` returns the last element of the `_elements` array if the array is not empty. If the
|
|
209
|
-
* array is empty, it returns `undefined`.
|
|
210
|
-
*/
|
|
211
|
-
peekLast(): E | undefined {
|
|
212
|
-
return this.last;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Time Complexity: O(1)
|
|
217
|
-
* Space Complexity: O(1)
|
|
218
|
-
*/
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Time Complexity: O(1)
|
|
222
|
-
* Space Complexity: O(1)
|
|
223
|
-
*
|
|
224
|
-
* The enqueue function adds a value to the end of a queue.
|
|
225
|
-
* @param {E} value - The value parameter represents the value that you want to add to the queue.
|
|
226
|
-
*/
|
|
227
|
-
enqueue(value: E): boolean {
|
|
228
|
-
return this.push(value);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Time Complexity: O(1)
|
|
233
|
-
* Space Complexity: O(1)
|
|
234
|
-
*/
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Time Complexity: O(1)
|
|
238
|
-
* Space Complexity: O(1)
|
|
239
|
-
*
|
|
240
|
-
* The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
|
|
241
|
-
* @returns The method is returning a value of type E or undefined.
|
|
242
|
-
*/
|
|
243
|
-
dequeue(): E | undefined {
|
|
244
|
-
return this.shift();
|
|
245
|
-
}
|
|
246
|
-
|
|
247
181
|
/**
|
|
248
182
|
* Time Complexity: O(1)
|
|
249
183
|
* Space Complexity: O(1)
|
|
@@ -411,38 +345,6 @@ export class Queue<E = any> extends IterableElementBase<E> {
|
|
|
411
345
|
* 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
|
|
412
346
|
*/
|
|
413
347
|
export class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
|
|
414
|
-
/**
|
|
415
|
-
* The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
|
|
416
|
-
* @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
|
|
417
|
-
*/
|
|
418
|
-
get first(): E | undefined {
|
|
419
|
-
return this.head?.value;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* The enqueue function adds a value to the end of an array.
|
|
424
|
-
* @param {E} value - The value parameter represents the value that you want to add to the queue.
|
|
425
|
-
*/
|
|
426
|
-
enqueue(value: E): boolean {
|
|
427
|
-
return this.push(value);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
|
|
432
|
-
* @returns The method is returning the element at the front of the queue, or undefined if the queue is empty.
|
|
433
|
-
*/
|
|
434
|
-
dequeue(): E | undefined {
|
|
435
|
-
return this.shift();
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
|
|
440
|
-
* @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
|
|
441
|
-
*/
|
|
442
|
-
peek(): E | undefined {
|
|
443
|
-
return this.first;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
348
|
/**
|
|
447
349
|
* Time Complexity: O(n)
|
|
448
350
|
* Space Complexity: O(n)
|