min-heap-typed 1.42.8 → 1.43.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/binary-tree/avl-tree.d.ts +88 -23
- package/dist/data-structures/binary-tree/avl-tree.js +88 -23
- package/dist/data-structures/binary-tree/binary-tree.d.ts +180 -74
- package/dist/data-structures/binary-tree/binary-tree.js +415 -236
- package/dist/data-structures/binary-tree/bst.d.ts +121 -66
- package/dist/data-structures/binary-tree/bst.js +121 -67
- package/dist/data-structures/binary-tree/rb-tree.d.ts +72 -5
- package/dist/data-structures/binary-tree/rb-tree.js +95 -18
- package/dist/data-structures/binary-tree/tree-multimap.d.ts +82 -43
- package/dist/data-structures/binary-tree/tree-multimap.js +82 -43
- package/dist/data-structures/graph/abstract-graph.d.ts +139 -36
- package/dist/data-structures/graph/abstract-graph.js +147 -36
- package/dist/data-structures/graph/directed-graph.d.ts +126 -0
- package/dist/data-structures/graph/directed-graph.js +126 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +63 -0
- package/dist/data-structures/graph/undirected-graph.js +63 -0
- package/dist/data-structures/heap/heap.d.ts +175 -12
- package/dist/data-structures/heap/heap.js +175 -12
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +203 -0
- package/dist/data-structures/linked-list/doubly-linked-list.js +203 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +182 -0
- package/dist/data-structures/linked-list/singly-linked-list.js +182 -0
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +64 -0
- package/dist/data-structures/linked-list/skip-linked-list.js +64 -0
- package/dist/data-structures/queue/deque.d.ts +113 -3
- package/dist/data-structures/queue/deque.js +113 -3
- package/dist/data-structures/queue/queue.d.ts +87 -0
- package/dist/data-structures/queue/queue.js +87 -0
- package/dist/data-structures/stack/stack.d.ts +42 -0
- package/dist/data-structures/stack/stack.js +42 -0
- package/dist/data-structures/trie/trie.d.ts +76 -0
- package/dist/data-structures/trie/trie.js +76 -1
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +97 -23
- package/src/data-structures/binary-tree/binary-tree.ts +465 -256
- package/src/data-structures/binary-tree/bst.ts +130 -68
- package/src/data-structures/binary-tree/rb-tree.ts +106 -19
- package/src/data-structures/binary-tree/tree-multimap.ts +88 -44
- package/src/data-structures/graph/abstract-graph.ts +133 -7
- package/src/data-structures/graph/directed-graph.ts +145 -1
- package/src/data-structures/graph/undirected-graph.ts +72 -0
- package/src/data-structures/heap/heap.ts +201 -12
- package/src/data-structures/linked-list/doubly-linked-list.ts +232 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +208 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +74 -0
- package/src/data-structures/queue/deque.ts +127 -3
- package/src/data-structures/queue/queue.ts +99 -0
- package/src/data-structures/stack/stack.ts +48 -0
- package/src/data-structures/trie/trie.ts +87 -4
|
@@ -29,6 +29,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
29
29
|
get length(): number;
|
|
30
30
|
get size(): number;
|
|
31
31
|
/**
|
|
32
|
+
* Time Complexity: O(n), where n is the length of the input array.
|
|
33
|
+
* Space Complexity: O(n)
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Time Complexity: O(n), where n is the length of the input array.
|
|
37
|
+
* Space Complexity: O(n)
|
|
38
|
+
*
|
|
32
39
|
* The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
|
|
33
40
|
* given array.
|
|
34
41
|
* @param {E[]} data - The `data` parameter is an array of elements of type `E`.
|
|
@@ -36,62 +43,139 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
36
43
|
*/
|
|
37
44
|
static fromArray<E>(data: E[]): DoublyLinkedList<E>;
|
|
38
45
|
/**
|
|
46
|
+
* Time Complexity: O(1)
|
|
47
|
+
* Space Complexity: O(1)
|
|
48
|
+
*/
|
|
49
|
+
/**
|
|
50
|
+
* Time Complexity: O(1)
|
|
51
|
+
* Space Complexity: O(1)
|
|
52
|
+
*
|
|
39
53
|
* The push function adds a new node with the given value to the end of the doubly linked list.
|
|
40
54
|
* @param {E} value - The value to be added to the linked list.
|
|
41
55
|
*/
|
|
42
56
|
push(value: E): void;
|
|
43
57
|
/**
|
|
58
|
+
* Time Complexity: O(1)
|
|
59
|
+
* Space Complexity: O(1)
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* Time Complexity: O(1)
|
|
63
|
+
* Space Complexity: O(1)
|
|
64
|
+
*
|
|
44
65
|
* The addLast function adds a new node with the given value to the end of the doubly linked list.
|
|
45
66
|
* @param {E} value - The value to be added to the linked list.
|
|
46
67
|
*/
|
|
47
68
|
addLast(value: E): void;
|
|
48
69
|
/**
|
|
70
|
+
* Time Complexity: O(1)
|
|
71
|
+
* Space Complexity: O(1)
|
|
72
|
+
*/
|
|
73
|
+
/**
|
|
74
|
+
* Time Complexity: O(1)
|
|
75
|
+
* Space Complexity: O(1)
|
|
76
|
+
*
|
|
49
77
|
* The `pop()` function removes and returns the value of the last node in a doubly linked list.
|
|
50
78
|
* @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
|
|
51
79
|
* list is empty, it returns null.
|
|
52
80
|
*/
|
|
53
81
|
pop(): E | undefined;
|
|
54
82
|
/**
|
|
83
|
+
* Time Complexity: O(1)
|
|
84
|
+
* Space Complexity: O(1)
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* Time Complexity: O(1)
|
|
88
|
+
* Space Complexity: O(1)
|
|
89
|
+
*
|
|
55
90
|
* The `popLast()` function removes and returns the value of the last node in a doubly linked list.
|
|
56
91
|
* @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
|
|
57
92
|
* list is empty, it returns null.
|
|
58
93
|
*/
|
|
59
94
|
popLast(): E | undefined;
|
|
60
95
|
/**
|
|
96
|
+
* Time Complexity: O(1)
|
|
97
|
+
* Space Complexity: O(1)
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* Time Complexity: O(1)
|
|
101
|
+
* Space Complexity: O(1)
|
|
102
|
+
*
|
|
61
103
|
* The `shift()` function removes and returns the value of the first node in a doubly linked list.
|
|
62
104
|
* @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
|
|
63
105
|
* list.
|
|
64
106
|
*/
|
|
65
107
|
shift(): E | undefined;
|
|
66
108
|
/**
|
|
109
|
+
* Time Complexity: O(1)
|
|
110
|
+
* Space Complexity: O(1)
|
|
111
|
+
*/
|
|
112
|
+
/**
|
|
113
|
+
* Time Complexity: O(1)
|
|
114
|
+
* Space Complexity: O(1)
|
|
115
|
+
*
|
|
67
116
|
* The `popFirst()` function removes and returns the value of the first node in a doubly linked list.
|
|
68
117
|
* @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
|
|
69
118
|
* list.
|
|
70
119
|
*/
|
|
71
120
|
popFirst(): E | undefined;
|
|
72
121
|
/**
|
|
122
|
+
* Time Complexity: O(1)
|
|
123
|
+
* Space Complexity: O(1)
|
|
124
|
+
*/
|
|
125
|
+
/**
|
|
126
|
+
* Time Complexity: O(1)
|
|
127
|
+
* Space Complexity: O(1)
|
|
128
|
+
*
|
|
73
129
|
* The unshift function adds a new node with the given value to the beginning of a doubly linked list.
|
|
74
130
|
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
|
|
75
131
|
* doubly linked list.
|
|
76
132
|
*/
|
|
77
133
|
unshift(value: E): void;
|
|
78
134
|
/**
|
|
135
|
+
* Time Complexity: O(1)
|
|
136
|
+
* Space Complexity: O(1)
|
|
137
|
+
*/
|
|
138
|
+
/**
|
|
139
|
+
* Time Complexity: O(1)
|
|
140
|
+
* Space Complexity: O(1)
|
|
141
|
+
*
|
|
79
142
|
* The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
|
|
80
143
|
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
|
|
81
144
|
* doubly linked list.
|
|
82
145
|
*/
|
|
83
146
|
addFirst(value: E): void;
|
|
84
147
|
/**
|
|
148
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
149
|
+
* Space Complexity: O(1)
|
|
150
|
+
*/
|
|
151
|
+
/**
|
|
152
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
153
|
+
* Space Complexity: O(1)
|
|
154
|
+
*
|
|
85
155
|
* The `getFirst` function returns the first node in a doubly linked list, or null if the list is empty.
|
|
86
156
|
* @returns The method `getFirst()` returns the first node of the doubly linked list, or `null` if the list is empty.
|
|
87
157
|
*/
|
|
88
158
|
getFirst(): E | undefined;
|
|
89
159
|
/**
|
|
160
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
161
|
+
* Space Complexity: O(1)
|
|
162
|
+
*/
|
|
163
|
+
/**
|
|
164
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
165
|
+
* Space Complexity: O(1)
|
|
166
|
+
*
|
|
90
167
|
* The `getLast` function returns the last node in a doubly linked list, or null if the list is empty.
|
|
91
168
|
* @returns The method `getLast()` returns the last node of the doubly linked list, or `null` if the list is empty.
|
|
92
169
|
*/
|
|
93
170
|
getLast(): E | undefined;
|
|
94
171
|
/**
|
|
172
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
173
|
+
* Space Complexity: O(1)
|
|
174
|
+
*/
|
|
175
|
+
/**
|
|
176
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
177
|
+
* Space Complexity: O(1)
|
|
178
|
+
*
|
|
95
179
|
* The `getAt` function returns the value at a specified index in a linked list, or null if the index is out of bounds.
|
|
96
180
|
* @param {number} index - The index parameter is a number that represents the position of the element we want to
|
|
97
181
|
* retrieve from the list.
|
|
@@ -100,6 +184,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
100
184
|
*/
|
|
101
185
|
getAt(index: number): E | undefined;
|
|
102
186
|
/**
|
|
187
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
188
|
+
* Space Complexity: O(1)
|
|
189
|
+
*/
|
|
190
|
+
/**
|
|
191
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
192
|
+
* Space Complexity: O(1)
|
|
193
|
+
*
|
|
103
194
|
* The function `getNodeAt` returns the node at a given index in a doubly linked list, or null if the index is out of
|
|
104
195
|
* range.
|
|
105
196
|
* @param {number} index - The `index` parameter is a number that represents the position of the node we want to
|
|
@@ -109,6 +200,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
109
200
|
*/
|
|
110
201
|
getNodeAt(index: number): DoublyLinkedListNode<E> | null;
|
|
111
202
|
/**
|
|
203
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
204
|
+
* Space Complexity: O(1)
|
|
205
|
+
*/
|
|
206
|
+
/**
|
|
207
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
208
|
+
* Space Complexity: O(1)
|
|
209
|
+
*
|
|
112
210
|
* The function `findNodeByValue` searches for a node with a specific value in a doubly linked list and returns the
|
|
113
211
|
* node if found, otherwise it returns null.
|
|
114
212
|
* @param {E} value - The `value` parameter is the value that we want to search for in the doubly linked list.
|
|
@@ -117,6 +215,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
117
215
|
*/
|
|
118
216
|
getNode(value: E | null): DoublyLinkedListNode<E> | null;
|
|
119
217
|
/**
|
|
218
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
219
|
+
* Space Complexity: O(1)
|
|
220
|
+
*/
|
|
221
|
+
/**
|
|
222
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
223
|
+
* Space Complexity: O(1)
|
|
224
|
+
*
|
|
120
225
|
* The `insert` function inserts a value at a specified index in a doubly linked list.
|
|
121
226
|
* @param {number} index - The index parameter represents the position at which the new value should be inserted in the
|
|
122
227
|
* DoublyLinkedList. It is of type number.
|
|
@@ -127,6 +232,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
127
232
|
*/
|
|
128
233
|
insertAt(index: number, value: E): boolean;
|
|
129
234
|
/**
|
|
235
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
236
|
+
* Space Complexity: O(1)
|
|
237
|
+
*/
|
|
238
|
+
/**
|
|
239
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
240
|
+
* Space Complexity: O(1)
|
|
241
|
+
*
|
|
130
242
|
* The `insertBefore` function inserts a new value before an existing value or node in a doubly linked list.
|
|
131
243
|
* @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
|
|
132
244
|
* before which the new value will be inserted. It can be either the value of the existing node or the existing node
|
|
@@ -138,6 +250,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
138
250
|
*/
|
|
139
251
|
insertBefore(existingValueOrNode: E | DoublyLinkedListNode<E>, newValue: E): boolean;
|
|
140
252
|
/**
|
|
253
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
254
|
+
* Space Complexity: O(1)
|
|
255
|
+
*/
|
|
256
|
+
/**
|
|
257
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
258
|
+
* Space Complexity: O(1)
|
|
259
|
+
*
|
|
141
260
|
* The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
|
|
142
261
|
* @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
|
|
143
262
|
* data structure. It is of type number.
|
|
@@ -146,6 +265,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
146
265
|
*/
|
|
147
266
|
deleteAt(index: number): E | undefined;
|
|
148
267
|
/**
|
|
268
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
269
|
+
* Space Complexity: O(1)
|
|
270
|
+
*/
|
|
271
|
+
/**
|
|
272
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
273
|
+
* Space Complexity: O(1)
|
|
274
|
+
*
|
|
149
275
|
* The `delete` function removes a node from a doubly linked list based on either the node itself or its value.
|
|
150
276
|
* @param {E | DoublyLinkedListNode<E>} valOrNode - The `valOrNode` parameter can accept either a value of type `E` or
|
|
151
277
|
* a `DoublyLinkedListNode<E>` object.
|
|
@@ -154,6 +280,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
154
280
|
*/
|
|
155
281
|
delete(valOrNode: E | DoublyLinkedListNode<E> | null): boolean;
|
|
156
282
|
/**
|
|
283
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
284
|
+
* Space Complexity: O(n)
|
|
285
|
+
*/
|
|
286
|
+
/**
|
|
287
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
288
|
+
* Space Complexity: O(n)
|
|
289
|
+
*
|
|
157
290
|
* The `toArray` function converts a linked list into an array.
|
|
158
291
|
* @returns The `toArray()` method is returning an array of type `E[]`.
|
|
159
292
|
*/
|
|
@@ -168,6 +301,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
168
301
|
*/
|
|
169
302
|
clear(): void;
|
|
170
303
|
/**
|
|
304
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
305
|
+
* Space Complexity: O(1)
|
|
306
|
+
*/
|
|
307
|
+
/**
|
|
308
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
309
|
+
* Space Complexity: O(1)
|
|
310
|
+
*
|
|
171
311
|
* The `find` function iterates through a linked list and returns the first element that satisfies a given condition.
|
|
172
312
|
* @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
|
|
173
313
|
* function is used to determine whether a particular value in the linked list satisfies a certain condition.
|
|
@@ -176,6 +316,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
176
316
|
*/
|
|
177
317
|
find(callback: (value: E) => boolean): E | null;
|
|
178
318
|
/**
|
|
319
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
320
|
+
* Space Complexity: O(1)
|
|
321
|
+
*/
|
|
322
|
+
/**
|
|
323
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
324
|
+
* Space Complexity: O(1)
|
|
325
|
+
*
|
|
179
326
|
* The function returns the index of the first occurrence of a given value in a linked list.
|
|
180
327
|
* @param {E} value - The parameter `value` is of type `E`, which means it can be any data type. It represents the value
|
|
181
328
|
* that we are searching for in the linked list.
|
|
@@ -184,6 +331,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
184
331
|
*/
|
|
185
332
|
indexOf(value: E): number;
|
|
186
333
|
/**
|
|
334
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
335
|
+
* Space Complexity: O(1)
|
|
336
|
+
*/
|
|
337
|
+
/**
|
|
338
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
339
|
+
* Space Complexity: O(1)
|
|
340
|
+
*
|
|
187
341
|
* The `findBackward` function iterates through a linked list from the last node to the first node and returns the last
|
|
188
342
|
* value that satisfies the given callback function, or null if no value satisfies the callback.
|
|
189
343
|
* @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
|
|
@@ -193,15 +347,36 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
193
347
|
*/
|
|
194
348
|
findBackward(callback: (value: E) => boolean): E | null;
|
|
195
349
|
/**
|
|
350
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
351
|
+
* Space Complexity: O(n)
|
|
352
|
+
*/
|
|
353
|
+
/**
|
|
354
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
355
|
+
* Space Complexity: O(n)
|
|
356
|
+
*
|
|
196
357
|
* The `toArrayBackward` function converts a doubly linked list into an array in reverse order.
|
|
197
358
|
* @returns The `toArrayBackward()` function returns an array of type `E[]`.
|
|
198
359
|
*/
|
|
199
360
|
toArrayBackward(): E[];
|
|
200
361
|
/**
|
|
362
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
363
|
+
* Space Complexity: O(1)
|
|
364
|
+
*/
|
|
365
|
+
/**
|
|
366
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
367
|
+
* Space Complexity: O(1)
|
|
368
|
+
*
|
|
201
369
|
* The `reverse` function reverses the order of the elements in a doubly linked list.
|
|
202
370
|
*/
|
|
203
371
|
reverse(): void;
|
|
204
372
|
/**
|
|
373
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
374
|
+
* Space Complexity: O(1)
|
|
375
|
+
*/
|
|
376
|
+
/**
|
|
377
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
378
|
+
* Space Complexity: O(1)
|
|
379
|
+
*
|
|
205
380
|
* The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
|
|
206
381
|
* @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
|
|
207
382
|
* represents the value of the current node in the linked list, and the index argument represents the index of the
|
|
@@ -209,6 +384,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
209
384
|
*/
|
|
210
385
|
forEach(callback: (value: E, index: number) => void): void;
|
|
211
386
|
/**
|
|
387
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
388
|
+
* Space Complexity: O(n)
|
|
389
|
+
*/
|
|
390
|
+
/**
|
|
391
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
392
|
+
* Space Complexity: O(n)
|
|
393
|
+
*
|
|
212
394
|
* The `map` function takes a callback function and applies it to each element in the DoublyLinkedList, returning a new
|
|
213
395
|
* DoublyLinkedList with the transformed values.
|
|
214
396
|
* @param callback - The callback parameter is a function that takes a value of type E (the type of values stored in
|
|
@@ -218,6 +400,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
218
400
|
*/
|
|
219
401
|
map<U>(callback: (value: E) => U): DoublyLinkedList<U>;
|
|
220
402
|
/**
|
|
403
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
404
|
+
* Space Complexity: O(n)
|
|
405
|
+
*/
|
|
406
|
+
/**
|
|
407
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
408
|
+
* Space Complexity: O(n)
|
|
409
|
+
*
|
|
221
410
|
* The `filter` function iterates through a DoublyLinkedList and returns a new DoublyLinkedList containing only the
|
|
222
411
|
* elements that satisfy the given callback function.
|
|
223
412
|
* @param callback - The `callback` parameter is a function that takes a value of type `E` and returns a boolean value.
|
|
@@ -226,6 +415,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
226
415
|
*/
|
|
227
416
|
filter(callback: (value: E) => boolean): DoublyLinkedList<E>;
|
|
228
417
|
/**
|
|
418
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
419
|
+
* Space Complexity: O(n)
|
|
420
|
+
*/
|
|
421
|
+
/**
|
|
422
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
423
|
+
* Space Complexity: O(n)
|
|
424
|
+
*
|
|
229
425
|
* The `reduce` function iterates over a linked list and applies a callback function to each element, accumulating a
|
|
230
426
|
* single value.
|
|
231
427
|
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
|
|
@@ -237,6 +433,13 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
237
433
|
*/
|
|
238
434
|
reduce<U>(callback: (accumulator: U, value: E) => U, initialValue: U): U;
|
|
239
435
|
/**
|
|
436
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
437
|
+
* Space Complexity: O(1)
|
|
438
|
+
*/
|
|
439
|
+
/**
|
|
440
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
441
|
+
* Space Complexity: O(1)
|
|
442
|
+
*
|
|
240
443
|
* The `insertAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
|
|
241
444
|
* @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
|
|
242
445
|
* after which the new value will be inserted. It can be either the value of the existing node or the existing node
|