heap-typed 2.0.4 → 2.1.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/dist/data-structures/base/iterable-element-base.d.ts +186 -83
- package/dist/data-structures/base/iterable-element-base.js +149 -107
- package/dist/data-structures/base/iterable-entry-base.d.ts +95 -119
- package/dist/data-structures/base/iterable-entry-base.js +59 -116
- package/dist/data-structures/base/linear-base.d.ts +250 -192
- package/dist/data-structures/base/linear-base.js +137 -274
- package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +126 -158
- package/dist/data-structures/binary-tree/avl-tree-counter.js +171 -205
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +100 -69
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +135 -87
- package/dist/data-structures/binary-tree/avl-tree.d.ts +138 -149
- package/dist/data-structures/binary-tree/avl-tree.js +208 -195
- package/dist/data-structures/binary-tree/binary-tree.d.ts +476 -632
- package/dist/data-structures/binary-tree/binary-tree.js +612 -879
- package/dist/data-structures/binary-tree/bst.d.ts +258 -306
- package/dist/data-structures/binary-tree/bst.js +505 -481
- package/dist/data-structures/binary-tree/red-black-tree.d.ts +107 -179
- package/dist/data-structures/binary-tree/red-black-tree.js +114 -209
- package/dist/data-structures/binary-tree/tree-counter.d.ts +132 -154
- package/dist/data-structures/binary-tree/tree-counter.js +172 -203
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +72 -69
- package/dist/data-structures/binary-tree/tree-multi-map.js +105 -85
- package/dist/data-structures/graph/abstract-graph.d.ts +238 -233
- package/dist/data-structures/graph/abstract-graph.js +267 -237
- package/dist/data-structures/graph/directed-graph.d.ts +108 -224
- package/dist/data-structures/graph/directed-graph.js +146 -233
- package/dist/data-structures/graph/map-graph.d.ts +49 -55
- package/dist/data-structures/graph/map-graph.js +56 -59
- package/dist/data-structures/graph/undirected-graph.d.ts +103 -146
- package/dist/data-structures/graph/undirected-graph.js +129 -149
- package/dist/data-structures/hash/hash-map.d.ts +164 -338
- package/dist/data-structures/hash/hash-map.js +270 -457
- package/dist/data-structures/heap/heap.d.ts +214 -289
- package/dist/data-structures/heap/heap.js +340 -349
- package/dist/data-structures/heap/max-heap.d.ts +11 -47
- package/dist/data-structures/heap/max-heap.js +11 -66
- package/dist/data-structures/heap/min-heap.d.ts +12 -47
- package/dist/data-structures/heap/min-heap.js +11 -66
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +231 -347
- package/dist/data-structures/linked-list/doubly-linked-list.js +368 -494
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +261 -310
- package/dist/data-structures/linked-list/singly-linked-list.js +447 -466
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -107
- package/dist/data-structures/linked-list/skip-linked-list.js +0 -100
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -56
- package/dist/data-structures/priority-queue/max-priority-queue.js +11 -78
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -57
- package/dist/data-structures/priority-queue/min-priority-queue.js +10 -79
- package/dist/data-structures/priority-queue/priority-queue.d.ts +2 -61
- package/dist/data-structures/priority-queue/priority-queue.js +8 -83
- package/dist/data-structures/queue/deque.d.ts +227 -254
- package/dist/data-structures/queue/deque.js +309 -348
- package/dist/data-structures/queue/queue.d.ts +180 -201
- package/dist/data-structures/queue/queue.js +265 -248
- package/dist/data-structures/stack/stack.d.ts +124 -102
- package/dist/data-structures/stack/stack.js +181 -125
- package/dist/data-structures/trie/trie.d.ts +164 -165
- package/dist/data-structures/trie/trie.js +189 -172
- package/dist/interfaces/binary-tree.d.ts +56 -6
- package/dist/interfaces/graph.d.ts +16 -0
- package/dist/types/data-structures/base/base.d.ts +1 -1
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -0
- package/dist/types/utils/utils.d.ts +6 -6
- package/dist/utils/utils.d.ts +110 -49
- package/dist/utils/utils.js +148 -73
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +238 -115
- package/src/data-structures/base/iterable-entry-base.ts +96 -120
- package/src/data-structures/base/linear-base.ts +271 -277
- package/src/data-structures/binary-tree/avl-tree-counter.ts +198 -216
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +192 -101
- package/src/data-structures/binary-tree/avl-tree.ts +239 -206
- package/src/data-structures/binary-tree/binary-tree.ts +681 -905
- package/src/data-structures/binary-tree/bst.ts +568 -570
- package/src/data-structures/binary-tree/red-black-tree.ts +161 -222
- package/src/data-structures/binary-tree/tree-counter.ts +199 -218
- package/src/data-structures/binary-tree/tree-multi-map.ts +131 -97
- package/src/data-structures/graph/abstract-graph.ts +339 -264
- package/src/data-structures/graph/directed-graph.ts +146 -236
- package/src/data-structures/graph/map-graph.ts +63 -60
- package/src/data-structures/graph/undirected-graph.ts +129 -152
- package/src/data-structures/hash/hash-map.ts +274 -496
- package/src/data-structures/heap/heap.ts +389 -402
- package/src/data-structures/heap/max-heap.ts +12 -76
- package/src/data-structures/heap/min-heap.ts +13 -76
- package/src/data-structures/linked-list/doubly-linked-list.ts +426 -530
- package/src/data-structures/linked-list/singly-linked-list.ts +495 -517
- package/src/data-structures/linked-list/skip-linked-list.ts +1 -108
- package/src/data-structures/priority-queue/max-priority-queue.ts +12 -87
- package/src/data-structures/priority-queue/min-priority-queue.ts +11 -88
- package/src/data-structures/priority-queue/priority-queue.ts +3 -92
- package/src/data-structures/queue/deque.ts +381 -357
- package/src/data-structures/queue/queue.ts +310 -264
- package/src/data-structures/stack/stack.ts +217 -131
- package/src/data-structures/trie/trie.ts +240 -175
- package/src/interfaces/binary-tree.ts +240 -6
- package/src/interfaces/graph.ts +37 -0
- package/src/types/data-structures/base/base.ts +5 -5
- package/src/types/data-structures/graph/abstract-graph.ts +5 -0
- package/src/types/utils/utils.ts +9 -5
- package/src/utils/utils.ts +152 -86
|
@@ -5,23 +5,55 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type { DoublyLinkedListOptions, ElementCallback } from '../../types';
|
|
8
|
+
import type { DoublyLinkedListOptions, ElementCallback, LinearBaseOptions } from '../../types';
|
|
9
9
|
import { LinearLinkedBase, LinkedListNode } from '../base/linear-base';
|
|
10
|
+
/**
|
|
11
|
+
* Node of a doubly linked list; stores value and prev/next links.
|
|
12
|
+
* @remarks Time O(1), Space O(1)
|
|
13
|
+
* @template E
|
|
14
|
+
*/
|
|
10
15
|
export declare class DoublyLinkedListNode<E = any> extends LinkedListNode<E> {
|
|
11
16
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
17
|
+
* Create a node.
|
|
18
|
+
* @remarks Time O(1), Space O(1)
|
|
19
|
+
* @param value - Element value to store.
|
|
20
|
+
* @returns New node instance.
|
|
15
21
|
*/
|
|
16
22
|
constructor(value: E);
|
|
17
23
|
protected _next: DoublyLinkedListNode<E> | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Get the next node link.
|
|
26
|
+
* @remarks Time O(1), Space O(1)
|
|
27
|
+
* @returns Next node or undefined.
|
|
28
|
+
*/
|
|
18
29
|
get next(): DoublyLinkedListNode<E> | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Set the next node link.
|
|
32
|
+
* @remarks Time O(1), Space O(1)
|
|
33
|
+
* @param value - Next node or undefined.
|
|
34
|
+
* @returns void
|
|
35
|
+
*/
|
|
19
36
|
set next(value: DoublyLinkedListNode<E> | undefined);
|
|
20
37
|
protected _prev: DoublyLinkedListNode<E> | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Get the previous node link.
|
|
40
|
+
* @remarks Time O(1), Space O(1)
|
|
41
|
+
* @returns Previous node or undefined.
|
|
42
|
+
*/
|
|
21
43
|
get prev(): DoublyLinkedListNode<E> | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Set the previous node link.
|
|
46
|
+
* @remarks Time O(1), Space O(1)
|
|
47
|
+
* @param value - Previous node or undefined.
|
|
48
|
+
* @returns void
|
|
49
|
+
*/
|
|
22
50
|
set prev(value: DoublyLinkedListNode<E> | undefined);
|
|
23
51
|
}
|
|
24
52
|
/**
|
|
53
|
+
* Doubly linked list with O(1) push/pop/unshift/shift and linear scans.
|
|
54
|
+
* @remarks Time O(1), Space O(1)
|
|
55
|
+
* @template E
|
|
56
|
+
* @template R
|
|
25
57
|
* 1. Node Structure: Each node contains three parts: a data field, a pointer (or reference) to the previous node, and a pointer to the next node. This structure allows traversal of the linked list in both directions.
|
|
26
58
|
* 2. Bidirectional Traversal: Unlike singly linked lists, doubly linked lists can be easily traversed forwards or backwards. This makes insertions and deletions in the list more flexible and efficient.
|
|
27
59
|
* 3. No Centralized Index: Unlike arrays, elements in a linked list are not stored contiguously, so there is no centralized index. Accessing elements in a linked list typically requires traversing from the head or tail node.
|
|
@@ -196,6 +228,16 @@ export declare class DoublyLinkedListNode<E = any> extends LinkedListNode<E> {
|
|
|
196
228
|
* this.map = new Map<K, DoublyLinkedListNode<CacheEntry<K, V>>>();
|
|
197
229
|
* }
|
|
198
230
|
*
|
|
231
|
+
* // Get the current cache length
|
|
232
|
+
* get length(): number {
|
|
233
|
+
* return this.list.length;
|
|
234
|
+
* }
|
|
235
|
+
*
|
|
236
|
+
* // Check if it is empty
|
|
237
|
+
* get isEmpty(): boolean {
|
|
238
|
+
* return this.list.isEmpty();
|
|
239
|
+
* }
|
|
240
|
+
*
|
|
199
241
|
* // Get cached value
|
|
200
242
|
* get(key: K): V | undefined {
|
|
201
243
|
* const node = this.map.get(key);
|
|
@@ -241,12 +283,6 @@ export declare class DoublyLinkedListNode<E = any> extends LinkedListNode<E> {
|
|
|
241
283
|
* }
|
|
242
284
|
* }
|
|
243
285
|
*
|
|
244
|
-
* // Move the node to the head of the linked list
|
|
245
|
-
* private moveToFront(node: DoublyLinkedListNode<CacheEntry<K, V>>): void {
|
|
246
|
-
* this.list.delete(node);
|
|
247
|
-
* this.list.unshift(node.value);
|
|
248
|
-
* }
|
|
249
|
-
*
|
|
250
286
|
* // Delete specific key
|
|
251
287
|
* delete(key: K): boolean {
|
|
252
288
|
* const node = this.map.get(key);
|
|
@@ -266,14 +302,10 @@ export declare class DoublyLinkedListNode<E = any> extends LinkedListNode<E> {
|
|
|
266
302
|
* this.map.clear();
|
|
267
303
|
* }
|
|
268
304
|
*
|
|
269
|
-
* //
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
* // Check if it is empty
|
|
275
|
-
* get isEmpty(): boolean {
|
|
276
|
-
* return this.list.isEmpty();
|
|
305
|
+
* // Move the node to the head of the linked list
|
|
306
|
+
* private moveToFront(node: DoublyLinkedListNode<CacheEntry<K, V>>): void {
|
|
307
|
+
* this.list.delete(node);
|
|
308
|
+
* this.list.unshift(node.value);
|
|
277
309
|
* }
|
|
278
310
|
* }
|
|
279
311
|
*
|
|
@@ -455,431 +487,283 @@ export declare class DoublyLinkedListNode<E = any> extends LinkedListNode<E> {
|
|
|
455
487
|
* console.log(scheduler.listProcesses()); // []
|
|
456
488
|
*/
|
|
457
489
|
export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, DoublyLinkedListNode<E>> {
|
|
490
|
+
protected _equals: (a: E, b: E) => boolean;
|
|
458
491
|
/**
|
|
459
|
-
*
|
|
460
|
-
* @
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
* @param [options] - The `options` parameter in the constructor is of type
|
|
465
|
-
* `DoublyLinkedListOptions<E, R>`. It is an optional parameter that allows you to pass additional
|
|
466
|
-
* configuration options to customize the behavior of the DoublyLinkedList.
|
|
492
|
+
* Create a DoublyLinkedList and optionally bulk-insert elements.
|
|
493
|
+
* @remarks Time O(N), Space O(N)
|
|
494
|
+
* @param [elements] - Iterable of elements or nodes (or raw records if toElementFn is provided).
|
|
495
|
+
* @param [options] - Options such as maxLen and toElementFn.
|
|
496
|
+
* @returns New DoublyLinkedList instance.
|
|
467
497
|
*/
|
|
468
498
|
constructor(elements?: Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>, options?: DoublyLinkedListOptions<E, R>);
|
|
469
499
|
protected _head: DoublyLinkedListNode<E> | undefined;
|
|
500
|
+
/**
|
|
501
|
+
* Get the head node.
|
|
502
|
+
* @remarks Time O(1), Space O(1)
|
|
503
|
+
* @returns Head node or undefined.
|
|
504
|
+
*/
|
|
470
505
|
get head(): DoublyLinkedListNode<E> | undefined;
|
|
471
506
|
protected _tail: DoublyLinkedListNode<E> | undefined;
|
|
507
|
+
/**
|
|
508
|
+
* Get the tail node.
|
|
509
|
+
* @remarks Time O(1), Space O(1)
|
|
510
|
+
* @returns Tail node or undefined.
|
|
511
|
+
*/
|
|
472
512
|
get tail(): DoublyLinkedListNode<E> | undefined;
|
|
473
513
|
protected _length: number;
|
|
514
|
+
/**
|
|
515
|
+
* Get the number of elements.
|
|
516
|
+
* @remarks Time O(1), Space O(1)
|
|
517
|
+
* @returns Current length.
|
|
518
|
+
*/
|
|
474
519
|
get length(): number;
|
|
475
520
|
/**
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
* The `get first` function returns the first node in a doubly linked list, or undefined if the list is empty.
|
|
480
|
-
* @returns The method `get first()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
|
|
521
|
+
* Get the first element value.
|
|
522
|
+
* @remarks Time O(1), Space O(1)
|
|
523
|
+
* @returns First element or undefined.
|
|
481
524
|
*/
|
|
482
525
|
get first(): E | undefined;
|
|
483
526
|
/**
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
* The `get last` function returns the last node in a doubly linked list, or undefined if the list is empty.
|
|
488
|
-
* @returns The method `get last()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
|
|
527
|
+
* Get the last element value.
|
|
528
|
+
* @remarks Time O(1), Space O(1)
|
|
529
|
+
* @returns Last element or undefined.
|
|
489
530
|
*/
|
|
490
531
|
get last(): E | undefined;
|
|
491
532
|
/**
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
* @param
|
|
498
|
-
* @returns
|
|
499
|
-
*/
|
|
500
|
-
static fromArray<E>(data: E[]):
|
|
501
|
-
/**
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
* `DoublyLinkedListNode`.
|
|
507
|
-
* @param {E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)} elementNodeOrPredicate
|
|
508
|
-
* elementNodeOrPredicate - The `elementNodeOrPredicate` parameter in the `isNode` function can
|
|
509
|
-
* be one of the following types:
|
|
510
|
-
* @returns The `isNode` function is checking if the `elementNodeOrPredicate` parameter is an
|
|
511
|
-
* instance of `DoublyLinkedListNode<E>`. If it is, the function returns `true`, indicating that the
|
|
512
|
-
* parameter is a `DoublyLinkedListNode<E>`. If it is not an instance of `DoublyLinkedListNode<E>`,
|
|
513
|
-
* the function returns `false`.
|
|
533
|
+
* Create a new list from an array of elements.
|
|
534
|
+
* @remarks Time O(N), Space O(N)
|
|
535
|
+
* @template E
|
|
536
|
+
* @template R
|
|
537
|
+
* @param this - The constructor (subclass) to instantiate.
|
|
538
|
+
* @param data - Array of elements to insert.
|
|
539
|
+
* @returns A new list populated with the array's elements.
|
|
540
|
+
*/
|
|
541
|
+
static fromArray<E, R = any>(this: new (elements?: Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>, options?: DoublyLinkedListOptions<E, R>) => any, data: E[]): any;
|
|
542
|
+
/**
|
|
543
|
+
* Type guard: check whether the input is a DoublyLinkedListNode.
|
|
544
|
+
* @remarks Time O(1), Space O(1)
|
|
545
|
+
* @param elementNodeOrPredicate - Element, node, or predicate.
|
|
546
|
+
* @returns True if the value is a DoublyLinkedListNode.
|
|
514
547
|
*/
|
|
515
548
|
isNode(elementNodeOrPredicate: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)): elementNodeOrPredicate is DoublyLinkedListNode<E>;
|
|
516
549
|
/**
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
* @param {E | DoublyLinkedListNode<E>} elementOrNode - The `elementOrNode` parameter in the `push`
|
|
522
|
-
* method can accept either an element of type `E` or a `DoublyLinkedListNode<E>` object.
|
|
523
|
-
* @returns The `push` method is returning a boolean value, specifically `true`.
|
|
550
|
+
* Append an element/node to the tail.
|
|
551
|
+
* @remarks Time O(1), Space O(1)
|
|
552
|
+
* @param elementOrNode - Element or node to append.
|
|
553
|
+
* @returns True when appended.
|
|
524
554
|
*/
|
|
525
555
|
push(elementOrNode: E | DoublyLinkedListNode<E>): boolean;
|
|
526
556
|
/**
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
* The `pop()` function removes and returns the value of the last element in a linked list.
|
|
531
|
-
* @returns The method is returning the value of the removed node.
|
|
557
|
+
* Remove and return the tail element.
|
|
558
|
+
* @remarks Time O(1), Space O(1)
|
|
559
|
+
* @returns Removed element or undefined.
|
|
532
560
|
*/
|
|
533
561
|
pop(): E | undefined;
|
|
534
562
|
/**
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
* The `shift()` function removes and returns the value of the first element in a doubly linked list.
|
|
539
|
-
* @returns The value of the removed node.
|
|
563
|
+
* Remove and return the head element.
|
|
564
|
+
* @remarks Time O(1), Space O(1)
|
|
565
|
+
* @returns Removed element or undefined.
|
|
540
566
|
*/
|
|
541
567
|
shift(): E | undefined;
|
|
542
568
|
/**
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
* @param {E | DoublyLinkedListNode<E>} elementOrNode - The `elementOrNode` parameter in the
|
|
548
|
-
* `unshift` method can be either an element of type `E` or a `DoublyLinkedListNode` containing an
|
|
549
|
-
* element of type `E`.
|
|
550
|
-
* @returns The `unshift` method is returning a boolean value, specifically `true`.
|
|
569
|
+
* Prepend an element/node to the head.
|
|
570
|
+
* @remarks Time O(1), Space O(1)
|
|
571
|
+
* @param elementOrNode - Element or node to prepend.
|
|
572
|
+
* @returns True when prepended.
|
|
551
573
|
*/
|
|
552
574
|
unshift(elementOrNode: E | DoublyLinkedListNode<E>): boolean;
|
|
553
575
|
/**
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
* transformation function if provided.
|
|
559
|
-
* @param {Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>} elements - The `elements`
|
|
560
|
-
* parameter in the `pushMany` function can accept an iterable containing elements of type `E`, `R`,
|
|
561
|
-
* or `DoublyLinkedListNode<E>`. The function iterates over each element in the iterable and pushes
|
|
562
|
-
* it onto the linked list. If a transformation function `to
|
|
563
|
-
* @returns The `pushMany` function is returning an array of boolean values (`ans`) which indicate
|
|
564
|
-
* the success or failure of pushing each element into the data structure.
|
|
576
|
+
* Append a sequence of elements/nodes.
|
|
577
|
+
* @remarks Time O(N), Space O(1)
|
|
578
|
+
* @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).
|
|
579
|
+
* @returns Array of per-element success flags.
|
|
565
580
|
*/
|
|
566
581
|
pushMany(elements: Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>): boolean[];
|
|
567
582
|
/**
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
* beginning of a Doubly Linked List, returning an array of boolean values indicating the success of
|
|
573
|
-
* each insertion.
|
|
574
|
-
* @param {Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>} elements - The `elements`
|
|
575
|
-
* parameter in the `unshiftMany` function can accept an iterable containing elements of type `E`,
|
|
576
|
-
* `R`, or `DoublyLinkedListNode<E>`. The function iterates over each element in the iterable and
|
|
577
|
-
* performs an `unshift` operation on the doubly linked list
|
|
578
|
-
* @returns The `unshiftMany` function returns an array of boolean values indicating the success of
|
|
579
|
-
* each unshift operation performed on the elements passed as input.
|
|
583
|
+
* Prepend a sequence of elements/nodes.
|
|
584
|
+
* @remarks Time O(N), Space O(1)
|
|
585
|
+
* @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).
|
|
586
|
+
* @returns Array of per-element success flags.
|
|
580
587
|
*/
|
|
581
588
|
unshiftMany(elements: Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>): boolean[];
|
|
582
589
|
/**
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
* @param {number} index - The index parameter is a number that represents the position of the element we want to
|
|
588
|
-
* retrieve from the list.
|
|
589
|
-
* @returns The method is returning the value at the specified index in the linked list. If the index is out of bounds
|
|
590
|
-
* or the linked list is empty, it will return undefined.
|
|
590
|
+
* Get the element at a given index.
|
|
591
|
+
* @remarks Time O(N), Space O(1)
|
|
592
|
+
* @param index - Zero-based index.
|
|
593
|
+
* @returns Element or undefined.
|
|
591
594
|
*/
|
|
592
595
|
at(index: number): E | undefined;
|
|
593
596
|
/**
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
* range.
|
|
599
|
-
* @param {number} index - The `index` parameter is a number that represents the position of the node we want to
|
|
600
|
-
* retrieve from the doubly linked list. It indicates the zero-based index of the node we want to access.
|
|
601
|
-
* @returns The method `getNodeAt(index: number)` returns a `DoublyLinkedListNode<E>` object if the index is within the
|
|
602
|
-
* valid range of the linked list, otherwise it returns `undefined`.
|
|
597
|
+
* Get the node reference at a given index.
|
|
598
|
+
* @remarks Time O(N), Space O(1)
|
|
599
|
+
* @param index - Zero-based index.
|
|
600
|
+
* @returns Node or undefined.
|
|
603
601
|
*/
|
|
604
602
|
getNodeAt(index: number): DoublyLinkedListNode<E> | undefined;
|
|
605
603
|
/**
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
* or predicate.
|
|
611
|
-
* @param {| E
|
|
612
|
-
* | DoublyLinkedListNode<E>
|
|
613
|
-
* | ((node: DoublyLinkedListNode<E>) => boolean)
|
|
614
|
-
* | undefined} elementNodeOrPredicate - The `getNode` method you provided is used to find a
|
|
615
|
-
* node in a doubly linked list based on a given element, node, or predicate function. The
|
|
616
|
-
* `elementNodeOrPredicate` parameter can be one of the following:
|
|
617
|
-
* @returns The `getNode` method returns a `DoublyLinkedListNode<E>` or `undefined` based on the
|
|
618
|
-
* input `elementNodeOrPredicate`. If the input is `undefined`, the method returns `undefined`.
|
|
619
|
-
* Otherwise, it iterates through the linked list starting from the head node and applies the
|
|
620
|
-
* provided predicate function to each node. If a node satisfies the predicate, that node is
|
|
621
|
-
* returned. If
|
|
604
|
+
* Find a node by value, reference, or predicate.
|
|
605
|
+
* @remarks Time O(N), Space O(1)
|
|
606
|
+
* @param [elementNodeOrPredicate] - Element, node, or predicate to match.
|
|
607
|
+
* @returns Matching node or undefined.
|
|
622
608
|
*/
|
|
623
609
|
getNode(elementNodeOrPredicate: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean) | undefined): DoublyLinkedListNode<E> | undefined;
|
|
624
610
|
/**
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
* @
|
|
630
|
-
* which you want to add a new element or node in the doubly linked list. It indicates the location
|
|
631
|
-
* where the new element or node should be inserted.
|
|
632
|
-
* @param {E | DoublyLinkedListNode<E>} newElementOrNode - The `newElementOrNode` parameter in the
|
|
633
|
-
* `addAt` method can be either a value of type `E` or a `DoublyLinkedListNode<E>` object.
|
|
634
|
-
* @returns The `addAt` method returns a boolean value. It returns `true` if the element or node was
|
|
635
|
-
* successfully added at the specified index, and `false` if the index is out of bounds (less than 0
|
|
636
|
-
* or greater than the length of the list).
|
|
611
|
+
* Insert a new element/node at an index, shifting following nodes.
|
|
612
|
+
* @remarks Time O(N), Space O(1)
|
|
613
|
+
* @param index - Zero-based index.
|
|
614
|
+
* @param newElementOrNode - Element or node to insert.
|
|
615
|
+
* @returns True if inserted.
|
|
637
616
|
*/
|
|
638
617
|
addAt(index: number, newElementOrNode: E | DoublyLinkedListNode<E>): boolean;
|
|
639
618
|
/**
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
* @param {E | DoublyLinkedListNode<E>} existingElementOrNode - The `existingElementOrNode` parameter
|
|
646
|
-
* in the `addBefore` method can be either an element of type `E` or a `DoublyLinkedListNode<E>`.
|
|
647
|
-
* @param {E | DoublyLinkedListNode<E>} newElementOrNode - The `newElementOrNode` parameter
|
|
648
|
-
* represents the element or node that you want to add before the `existingElementOrNode` in a doubly
|
|
649
|
-
* linked list.
|
|
650
|
-
* @returns The `addBefore` method returns a boolean value - `true` if the new element or node was
|
|
651
|
-
* successfully added before the existing element or node, and `false` if the existing element or
|
|
652
|
-
* node was not found.
|
|
619
|
+
* Insert a new element/node before an existing one.
|
|
620
|
+
* @remarks Time O(N), Space O(1)
|
|
621
|
+
* @param existingElementOrNode - Existing element or node.
|
|
622
|
+
* @param newElementOrNode - Element or node to insert.
|
|
623
|
+
* @returns True if inserted.
|
|
653
624
|
*/
|
|
654
625
|
addBefore(existingElementOrNode: E | DoublyLinkedListNode<E>, newElementOrNode: E | DoublyLinkedListNode<E>): boolean;
|
|
655
626
|
/**
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
* @param {E | DoublyLinkedListNode<E>} existingElementOrNode - existingElementOrNode represents the
|
|
662
|
-
* element or node in the doubly linked list after which you want to add a new element or node.
|
|
663
|
-
* @param {E | DoublyLinkedListNode<E>} newElementOrNode - The `newElementOrNode` parameter in the
|
|
664
|
-
* `addAfter` method represents the element or node that you want to add after the existing element
|
|
665
|
-
* or node in a doubly linked list. This parameter can be either an element value or a
|
|
666
|
-
* `DoublyLinkedListNode` object that you want to insert
|
|
667
|
-
* @returns The `addAfter` method returns a boolean value - `true` if the new element or node was
|
|
668
|
-
* successfully added after the existing element or node, and `false` if the existing element or node
|
|
669
|
-
* was not found in the linked list.
|
|
627
|
+
* Insert a new element/node after an existing one.
|
|
628
|
+
* @remarks Time O(N), Space O(1)
|
|
629
|
+
* @param existingElementOrNode - Existing element or node.
|
|
630
|
+
* @param newElementOrNode - Element or node to insert.
|
|
631
|
+
* @returns True if inserted.
|
|
670
632
|
*/
|
|
671
633
|
addAfter(existingElementOrNode: E | DoublyLinkedListNode<E>, newElementOrNode: E | DoublyLinkedListNode<E>): boolean;
|
|
672
634
|
/**
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
* @param {number} index - The `index` parameter in the `setAt` method refers to the position in the
|
|
679
|
-
* data structure where you want to set a new value.
|
|
680
|
-
* @param {E} value - The `value` parameter in the `setAt` method represents the new value that you
|
|
681
|
-
* want to set at the specified index in the data structure.
|
|
682
|
-
* @returns The `setAt` method returns a boolean value - `true` if the value at the specified index
|
|
683
|
-
* is successfully updated, and `false` if the index is out of bounds.
|
|
635
|
+
* Set the element value at an index.
|
|
636
|
+
* @remarks Time O(N), Space O(1)
|
|
637
|
+
* @param index - Zero-based index.
|
|
638
|
+
* @param value - New value.
|
|
639
|
+
* @returns True if updated.
|
|
684
640
|
*/
|
|
685
641
|
setAt(index: number, value: E): boolean;
|
|
686
642
|
/**
|
|
687
|
-
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
* @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
|
|
692
|
-
* data structure. It is of type number.
|
|
693
|
-
* @returns The method `deleteAt` returns the value of the node that was deleted, or `undefined` if the index is out of
|
|
694
|
-
* bounds.
|
|
643
|
+
* Delete the element at an index.
|
|
644
|
+
* @remarks Time O(N), Space O(1)
|
|
645
|
+
* @param index - Zero-based index.
|
|
646
|
+
* @returns Removed element or undefined.
|
|
695
647
|
*/
|
|
696
648
|
deleteAt(index: number): E | undefined;
|
|
697
649
|
/**
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
* @param {E | DoublyLinkedListNode<E> | undefined} elementOrNode - The `elementOrNode` parameter in
|
|
703
|
-
* the `delete` method can accept an element of type `E`, a `DoublyLinkedListNode` of type `E`, or it
|
|
704
|
-
* can be `undefined`. This parameter is used to identify the node that needs to be deleted from the
|
|
705
|
-
* doubly linked list
|
|
706
|
-
* @returns The `delete` method returns a boolean value - `true` if the element or node was
|
|
707
|
-
* successfully deleted from the doubly linked list, and `false` if the element or node was not found
|
|
708
|
-
* in the list.
|
|
650
|
+
* Delete the first match by value/node.
|
|
651
|
+
* @remarks Time O(N), Space O(1)
|
|
652
|
+
* @param [elementOrNode] - Element or node to remove.
|
|
653
|
+
* @returns True if removed.
|
|
709
654
|
*/
|
|
710
655
|
delete(elementOrNode: E | DoublyLinkedListNode<E> | undefined): boolean;
|
|
711
656
|
/**
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
* The function checks if a variable has a length greater than zero and returns a boolean value.
|
|
716
|
-
* @returns A boolean value is being returned.
|
|
657
|
+
* Check whether the list is empty.
|
|
658
|
+
* @remarks Time O(1), Space O(1)
|
|
659
|
+
* @returns True if length is 0.
|
|
717
660
|
*/
|
|
718
661
|
isEmpty(): boolean;
|
|
719
662
|
/**
|
|
720
|
-
*
|
|
721
|
-
*
|
|
722
|
-
*
|
|
723
|
-
* The `clear` function resets the linked list by setting the head, tail, and length to undefined and 0 respectively.
|
|
663
|
+
* Remove all nodes and reset length.
|
|
664
|
+
* @remarks Time O(N), Space O(1)
|
|
665
|
+
* @returns void
|
|
724
666
|
*/
|
|
725
667
|
clear(): void;
|
|
726
668
|
/**
|
|
727
|
-
*
|
|
728
|
-
*
|
|
729
|
-
*
|
|
730
|
-
*
|
|
731
|
-
* node or predicate.
|
|
732
|
-
* @param {E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)} elementNodeOrPredicate
|
|
733
|
-
* elementNodeOrPredicate - The `get` method takes in a parameter called `elementNodeOrPredicate`,
|
|
734
|
-
* which can be one of the following types:
|
|
735
|
-
* @returns The `get` method returns the value of the first node in the doubly linked list that
|
|
736
|
-
* satisfies the provided predicate function. If no such node is found, it returns `undefined`.
|
|
669
|
+
* Find the first value matching a predicate scanning forward.
|
|
670
|
+
* @remarks Time O(N), Space O(1)
|
|
671
|
+
* @param elementNodeOrPredicate - Element, node, or predicate to match.
|
|
672
|
+
* @returns Matched value or undefined.
|
|
737
673
|
*/
|
|
738
674
|
search(elementNodeOrPredicate: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)): E | undefined;
|
|
739
675
|
/**
|
|
740
|
-
*
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
* the tail and moving backwards.
|
|
745
|
-
* @param {E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)} elementNodeOrPredicate
|
|
746
|
-
* elementNodeOrPredicate - The `elementNodeOrPredicate` parameter in the `getBackward`
|
|
747
|
-
* function can be one of the following types:
|
|
748
|
-
* @returns The `getBackward` method returns the value of the element node that matches the provided
|
|
749
|
-
* predicate when traversing the doubly linked list backwards. If no matching element is found, it
|
|
750
|
-
* returns `undefined`.
|
|
676
|
+
* Find the first value matching a predicate scanning backward.
|
|
677
|
+
* @remarks Time O(N), Space O(1)
|
|
678
|
+
* @param elementNodeOrPredicate - Element, node, or predicate to match.
|
|
679
|
+
* @returns Matched value or undefined.
|
|
751
680
|
*/
|
|
752
681
|
getBackward(elementNodeOrPredicate: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)): E | undefined;
|
|
753
682
|
/**
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
* The `reverse` function reverses the order of the elements in a doubly linked list.
|
|
683
|
+
* Reverse the list in place.
|
|
684
|
+
* @remarks Time O(N), Space O(1)
|
|
685
|
+
* @returns This list.
|
|
758
686
|
*/
|
|
759
687
|
reverse(): this;
|
|
760
688
|
/**
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
* as the original list.
|
|
766
|
-
* @returns The `clone()` method is returning a new instance of the `DoublyLinkedList` class, which
|
|
767
|
-
* is a copy of the original list.
|
|
689
|
+
* Set the equality comparator used to compare values.
|
|
690
|
+
* @remarks Time O(1), Space O(1)
|
|
691
|
+
* @param equals - Equality predicate (a, b) → boolean.
|
|
692
|
+
* @returns This list.
|
|
768
693
|
*/
|
|
769
|
-
|
|
694
|
+
setEquality(equals: (a: E, b: E) => boolean): this;
|
|
770
695
|
/**
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
* The `filter` function creates a new DoublyLinkedList by iterating over the elements of the current
|
|
775
|
-
* list and applying a callback function to each element, returning only the elements for which the
|
|
776
|
-
* callback function returns true.
|
|
777
|
-
* @param callback - The `callback` parameter is a function that will be called for each element in
|
|
778
|
-
* the DoublyLinkedList. It takes three arguments: the current element, the index of the current
|
|
779
|
-
* element, and the DoublyLinkedList itself. The callback function should return a boolean value
|
|
780
|
-
* indicating whether the current element should be included
|
|
781
|
-
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
782
|
-
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
|
|
783
|
-
* passed as the `this` value to the `callback` function. If `thisArg` is
|
|
784
|
-
* @returns The `filter` method is returning a new `DoublyLinkedList` object that contains the
|
|
785
|
-
* elements that pass the filter condition specified by the `callback` function.
|
|
786
|
-
*/
|
|
787
|
-
filter(callback: ElementCallback<E, R, boolean>, thisArg?: any): DoublyLinkedList<E, R>;
|
|
788
|
-
/**
|
|
789
|
-
* Time Complexity: O(n)
|
|
790
|
-
* Space Complexity: O(n)
|
|
791
|
-
*
|
|
792
|
-
* The `map` function takes a callback function and returns a new DoublyLinkedList with the results
|
|
793
|
-
* of applying the callback to each element in the original list.
|
|
794
|
-
* @param callback - The callback parameter is a function that will be called for each element in the
|
|
795
|
-
* original DoublyLinkedList. It takes three arguments: current (the current element being
|
|
796
|
-
* processed), index (the index of the current element), and this (the original DoublyLinkedList).
|
|
797
|
-
* The callback function should return a value of type
|
|
798
|
-
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
|
|
799
|
-
* convert the raw element (`RR`) to the desired element type (`T`). It takes the raw element as
|
|
800
|
-
* input and returns the converted element. If this parameter is not provided, the raw element will
|
|
801
|
-
* be used as is.
|
|
802
|
-
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
|
|
803
|
-
* specify the value of `this` within the callback function. It is used to set the context or scope
|
|
804
|
-
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
|
|
805
|
-
* value of
|
|
806
|
-
* @returns a new instance of the `DoublyLinkedList` class with elements of type `T` and `RR`.
|
|
807
|
-
*/
|
|
808
|
-
map<EM, RM>(callback: ElementCallback<E, R, EM>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): DoublyLinkedList<EM, RM>;
|
|
809
|
-
/**
|
|
810
|
-
* Time Complexity: O(n)
|
|
811
|
-
* Space Complexity: O(1)
|
|
812
|
-
*
|
|
813
|
-
* The function `countOccurrences` iterates through a doubly linked list and counts the occurrences
|
|
814
|
-
* of a specified element or nodes that satisfy a given predicate.
|
|
815
|
-
* @param {E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)} elementOrNode
|
|
816
|
-
* - The `elementOrNode` parameter in the `countOccurrences` method can accept three types of values:
|
|
817
|
-
* @returns The `countOccurrences` method returns the number of occurrences of the specified element,
|
|
818
|
-
* node, or predicate function in the doubly linked list.
|
|
819
|
-
*/
|
|
820
|
-
countOccurrences(elementOrNode: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)): number;
|
|
821
|
-
/**
|
|
822
|
-
* The function returns an iterator that iterates over the values of a linked list.
|
|
696
|
+
* Deep clone this list (values are copied by reference).
|
|
697
|
+
* @remarks Time O(N), Space O(N)
|
|
698
|
+
* @returns A new list with the same element sequence.
|
|
823
699
|
*/
|
|
824
|
-
|
|
700
|
+
clone(): this;
|
|
825
701
|
/**
|
|
826
|
-
*
|
|
827
|
-
*
|
|
702
|
+
* Filter values into a new list of the same class.
|
|
703
|
+
* @remarks Time O(N), Space O(N)
|
|
704
|
+
* @param callback - Predicate (value, index, list) → boolean to keep value.
|
|
705
|
+
* @param [thisArg] - Value for `this` inside the callback.
|
|
706
|
+
* @returns A new list with kept values.
|
|
828
707
|
*/
|
|
829
|
-
|
|
708
|
+
filter(callback: ElementCallback<E, R, boolean>, thisArg?: any): this;
|
|
830
709
|
/**
|
|
831
|
-
*
|
|
832
|
-
*
|
|
710
|
+
* Map values into a new list of the same class.
|
|
711
|
+
* @remarks Time O(N), Space O(N)
|
|
712
|
+
* @param callback - Mapping function (value, index, list) → newValue.
|
|
713
|
+
* @param [thisArg] - Value for `this` inside the callback.
|
|
714
|
+
* @returns A new list with mapped values.
|
|
833
715
|
*/
|
|
834
|
-
|
|
716
|
+
mapSame(callback: ElementCallback<E, R, E>, thisArg?: any): this;
|
|
835
717
|
/**
|
|
836
|
-
*
|
|
837
|
-
*
|
|
838
|
-
* @
|
|
839
|
-
*
|
|
840
|
-
*
|
|
841
|
-
* @
|
|
842
|
-
*
|
|
843
|
-
*
|
|
718
|
+
* Map values into a new list (possibly different element type).
|
|
719
|
+
* @remarks Time O(N), Space O(N)
|
|
720
|
+
* @template EM
|
|
721
|
+
* @template RM
|
|
722
|
+
* @param callback - Mapping function (value, index, list) → newElement.
|
|
723
|
+
* @param [options] - Options for the output list (e.g., maxLen, toElementFn).
|
|
724
|
+
* @param [thisArg] - Value for `this` inside the callback.
|
|
725
|
+
* @returns A new DoublyLinkedList with mapped values.
|
|
844
726
|
*/
|
|
845
|
-
|
|
727
|
+
map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: DoublyLinkedListOptions<EM, RM>, thisArg?: any): DoublyLinkedList<EM, RM>;
|
|
846
728
|
/**
|
|
847
|
-
*
|
|
848
|
-
* @
|
|
849
|
-
*
|
|
850
|
-
* @returns
|
|
851
|
-
* as is. Otherwise, a new `DoublyLinkedListNode` instance will be created with the `elementOrNode`
|
|
852
|
-
* value and returned.
|
|
729
|
+
* (Protected) Create or return a node for the given input (node or raw element).
|
|
730
|
+
* @remarks Time O(1), Space O(1)
|
|
731
|
+
* @param elementOrNode - Element value or node to normalize.
|
|
732
|
+
* @returns A DoublyLinkedListNode for the provided input.
|
|
853
733
|
*/
|
|
854
734
|
protected _ensureNode(elementOrNode: E | DoublyLinkedListNode<E>): DoublyLinkedListNode<E>;
|
|
855
735
|
/**
|
|
856
|
-
*
|
|
857
|
-
*
|
|
858
|
-
* @param
|
|
859
|
-
*
|
|
860
|
-
* types:
|
|
861
|
-
* @returns A function is being returned that takes a `DoublyLinkedListNode` as a parameter and
|
|
862
|
-
* returns a boolean value based on the conditions specified in the code.
|
|
736
|
+
* (Protected) Normalize input into a predicate over nodes.
|
|
737
|
+
* @remarks Time O(1), Space O(1)
|
|
738
|
+
* @param elementNodeOrPredicate - Element, node, or node predicate.
|
|
739
|
+
* @returns A predicate function taking a node and returning true/false.
|
|
863
740
|
*/
|
|
864
741
|
protected _ensurePredicate(elementNodeOrPredicate: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)): (node: DoublyLinkedListNode<E>) => boolean;
|
|
865
742
|
/**
|
|
866
|
-
*
|
|
867
|
-
*
|
|
868
|
-
* @param
|
|
869
|
-
*
|
|
870
|
-
* configuration options when creating a new instance of the `DoublyLinkedList` class.
|
|
871
|
-
* @returns An instance of the `DoublyLinkedList` class with an empty array and the provided options
|
|
872
|
-
* is being returned, cast as the current class type.
|
|
743
|
+
* (Protected) Get the previous node of a given node.
|
|
744
|
+
* @remarks Time O(1), Space O(1)
|
|
745
|
+
* @param node - A node in the list.
|
|
746
|
+
* @returns Previous node or undefined.
|
|
873
747
|
*/
|
|
874
|
-
protected
|
|
748
|
+
protected _getPrevNode(node: DoublyLinkedListNode<E>): DoublyLinkedListNode<E> | undefined;
|
|
875
749
|
/**
|
|
876
|
-
*
|
|
877
|
-
* @
|
|
878
|
-
*
|
|
879
|
-
*
|
|
880
|
-
* @returns The `_getPrevNode` method is returning the previous node of the input `node` in a doubly
|
|
881
|
-
* linked list. If the input node has a previous node, it will return that node. Otherwise, it will
|
|
882
|
-
* return `undefined`.
|
|
750
|
+
* (Protected) Create an empty instance of the same concrete class.
|
|
751
|
+
* @remarks Time O(1), Space O(1)
|
|
752
|
+
* @param [options] - Options forwarded to the constructor.
|
|
753
|
+
* @returns An empty like-kind list instance.
|
|
883
754
|
*/
|
|
884
|
-
protected
|
|
755
|
+
protected _createInstance(options?: LinearBaseOptions<E, R>): this;
|
|
756
|
+
/**
|
|
757
|
+
* (Protected) Create a like-kind instance and seed it from an iterable.
|
|
758
|
+
* @remarks Time O(N), Space O(N)
|
|
759
|
+
* @template EM
|
|
760
|
+
* @template RM
|
|
761
|
+
* @param [elements] - Iterable used to seed the new list.
|
|
762
|
+
* @param [options] - Options forwarded to the constructor.
|
|
763
|
+
* @returns A like-kind DoublyLinkedList instance.
|
|
764
|
+
*/
|
|
765
|
+
protected _createLike<EM = E, RM = R>(elements?: Iterable<EM> | Iterable<RM> | Iterable<DoublyLinkedListNode<EM>>, options?: DoublyLinkedListOptions<EM, RM>): DoublyLinkedList<EM, RM>;
|
|
766
|
+
protected _getIterator(): IterableIterator<E>;
|
|
767
|
+
protected _getReverseIterator(): IterableIterator<E>;
|
|
768
|
+
protected _getNodeIterator(): IterableIterator<DoublyLinkedListNode<E>>;
|
|
885
769
|
}
|