red-black-tree-typed 1.53.7 → 1.54.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/LICENSE +2 -2
- package/README.md +52 -0
- package/dist/common/index.js +5 -0
- package/dist/data-structures/base/iterable-entry-base.js +4 -4
- package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
- package/dist/data-structures/binary-tree/avl-tree-counter.js +407 -0
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -170
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +133 -328
- package/dist/data-structures/binary-tree/avl-tree.d.ts +103 -69
- package/dist/data-structures/binary-tree/avl-tree.js +130 -70
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +3 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +268 -202
- package/dist/data-structures/binary-tree/binary-tree.js +311 -263
- package/dist/data-structures/binary-tree/bst.d.ts +193 -139
- package/dist/data-structures/binary-tree/bst.js +248 -164
- package/dist/data-structures/binary-tree/index.d.ts +3 -1
- package/dist/data-structures/binary-tree/index.js +3 -1
- package/dist/data-structures/binary-tree/red-black-tree.d.ts +286 -0
- package/dist/data-structures/binary-tree/{rb-tree.js → red-black-tree.js} +176 -107
- package/dist/data-structures/binary-tree/tree-counter.d.ts +212 -0
- package/dist/data-structures/binary-tree/tree-counter.js +444 -0
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +78 -170
- package/dist/data-structures/binary-tree/tree-multi-map.js +145 -367
- package/dist/data-structures/graph/abstract-graph.js +2 -2
- package/dist/data-structures/graph/directed-graph.d.ts +3 -0
- package/dist/data-structures/graph/directed-graph.js +3 -0
- package/dist/data-structures/graph/map-graph.d.ts +3 -0
- package/dist/data-structures/graph/map-graph.js +3 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +3 -0
- package/dist/data-structures/graph/undirected-graph.js +3 -0
- package/dist/data-structures/hash/hash-map.d.ts +31 -1
- package/dist/data-structures/hash/hash-map.js +35 -5
- package/dist/data-structures/heap/heap.d.ts +20 -3
- package/dist/data-structures/heap/heap.js +31 -11
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +46 -11
- package/dist/data-structures/linked-list/doubly-linked-list.js +68 -21
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +47 -11
- package/dist/data-structures/linked-list/singly-linked-list.js +73 -26
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +3 -0
- package/dist/data-structures/linked-list/skip-linked-list.js +3 -0
- package/dist/data-structures/matrix/matrix.d.ts +3 -0
- package/dist/data-structures/matrix/matrix.js +3 -0
- package/dist/data-structures/matrix/navigator.d.ts +3 -0
- package/dist/data-structures/matrix/navigator.js +3 -0
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
- package/dist/data-structures/priority-queue/max-priority-queue.js +3 -0
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
- package/dist/data-structures/priority-queue/min-priority-queue.js +3 -0
- package/dist/data-structures/queue/deque.d.ts +37 -8
- package/dist/data-structures/queue/deque.js +73 -29
- package/dist/data-structures/queue/queue.d.ts +41 -1
- package/dist/data-structures/queue/queue.js +51 -9
- package/dist/data-structures/stack/stack.d.ts +27 -10
- package/dist/data-structures/stack/stack.js +39 -20
- package/dist/data-structures/trie/trie.d.ts +8 -7
- package/dist/data-structures/trie/trie.js +8 -7
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/interfaces/binary-tree.d.ts +8 -8
- package/dist/types/data-structures/base/base.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -4
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -3
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
- package/dist/types/data-structures/binary-tree/bst.d.ts +4 -4
- package/dist/types/data-structures/binary-tree/index.d.ts +3 -1
- package/dist/types/data-structures/binary-tree/index.js +3 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.js +2 -0
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
- package/dist/types/data-structures/binary-tree/tree-counter.js +2 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -5
- package/package.json +3 -3
- package/src/common/index.ts +7 -1
- package/src/data-structures/base/iterable-entry-base.ts +4 -4
- package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +151 -370
- package/src/data-structures/binary-tree/avl-tree.ts +162 -105
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
- package/src/data-structures/binary-tree/binary-tree.ts +488 -416
- package/src/data-structures/binary-tree/bst.ts +326 -251
- package/src/data-structures/binary-tree/index.ts +3 -1
- package/src/data-structures/binary-tree/{rb-tree.ts → red-black-tree.ts} +219 -145
- package/src/data-structures/binary-tree/tree-counter.ts +504 -0
- package/src/data-structures/binary-tree/tree-multi-map.ts +159 -401
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +3 -0
- package/src/data-structures/graph/map-graph.ts +3 -0
- package/src/data-structures/graph/undirected-graph.ts +3 -0
- package/src/data-structures/hash/hash-map.ts +37 -7
- package/src/data-structures/heap/heap.ts +33 -10
- package/src/data-structures/linked-list/doubly-linked-list.ts +75 -21
- package/src/data-structures/linked-list/singly-linked-list.ts +80 -27
- package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
- package/src/data-structures/matrix/matrix.ts +3 -0
- package/src/data-structures/matrix/navigator.ts +3 -0
- package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
- package/src/data-structures/queue/deque.ts +72 -28
- package/src/data-structures/queue/queue.ts +50 -7
- package/src/data-structures/stack/stack.ts +39 -20
- package/src/data-structures/trie/trie.ts +8 -7
- package/src/index.ts +4 -4
- package/src/interfaces/binary-tree.ts +10 -21
- package/src/types/data-structures/base/base.ts +1 -1
- package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -6
- package/src/types/data-structures/binary-tree/avl-tree.ts +0 -5
- package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
- package/src/types/data-structures/binary-tree/bst.ts +6 -6
- package/src/types/data-structures/binary-tree/index.ts +3 -1
- package/src/types/data-structures/binary-tree/red-black-tree.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +2 -7
- package/dist/data-structures/binary-tree/rb-tree.d.ts +0 -209
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +0 -6
- package/src/types/data-structures/binary-tree/rb-tree.ts +0 -10
- /package/dist/types/data-structures/binary-tree/{rb-tree.js → avl-tree-counter.js} +0 -0
|
@@ -33,6 +33,9 @@ class UndirectedEdge extends abstract_graph_1.AbstractEdge {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
exports.UndirectedEdge = UndirectedEdge;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
36
39
|
class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
37
40
|
/**
|
|
38
41
|
* The constructor initializes a new Map object to store edgeMap.
|
|
@@ -62,6 +62,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
62
62
|
*/
|
|
63
63
|
get hashFn(): (key: K) => string;
|
|
64
64
|
/**
|
|
65
|
+
* Time Complexity: O(1)
|
|
66
|
+
* Space Complexity: O(1)
|
|
67
|
+
*
|
|
65
68
|
* The function checks if a given element is an array with exactly two elements.
|
|
66
69
|
* @param {any} rawElement - The `rawElement` parameter is of type `any`, which means it can be any
|
|
67
70
|
* data type.
|
|
@@ -69,16 +72,25 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
69
72
|
*/
|
|
70
73
|
isEntry(rawElement: any): rawElement is [K, V];
|
|
71
74
|
/**
|
|
75
|
+
* Time Complexity: O(1)
|
|
76
|
+
* Space Complexity: O(1)
|
|
77
|
+
*
|
|
72
78
|
* The function checks if the size of an object is equal to zero and returns a boolean value.
|
|
73
79
|
* @returns A boolean value indicating whether the size of the object is 0 or not.
|
|
74
80
|
*/
|
|
75
81
|
isEmpty(): boolean;
|
|
76
82
|
/**
|
|
83
|
+
* Time Complexity: O(1)
|
|
84
|
+
* Space Complexity: O(1)
|
|
85
|
+
*
|
|
77
86
|
* The clear() function resets the state of an object by clearing its internal store, object map, and
|
|
78
87
|
* size.
|
|
79
88
|
*/
|
|
80
89
|
clear(): void;
|
|
81
90
|
/**
|
|
91
|
+
* Time Complexity: O(1)
|
|
92
|
+
* Space Complexity: O(1)
|
|
93
|
+
*
|
|
82
94
|
* The `set` function adds a key-value pair to a map-like data structure, incrementing the size if
|
|
83
95
|
* the key is not already present.
|
|
84
96
|
* @param {K} key - The key parameter is the key used to identify the value in the data structure. It
|
|
@@ -89,6 +101,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
89
101
|
*/
|
|
90
102
|
set(key: K, value: V): boolean;
|
|
91
103
|
/**
|
|
104
|
+
* Time Complexity: O(k)
|
|
105
|
+
* Space Complexity: O(k)
|
|
106
|
+
*
|
|
92
107
|
* The function `setMany` takes an iterable collection of objects, maps each object to a key-value
|
|
93
108
|
* pair using a mapping function, and sets each key-value pair in the current object.
|
|
94
109
|
* @param entryOrRawElements - The `entryOrRawElements` parameter is an iterable collection of elements of a type
|
|
@@ -97,6 +112,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
97
112
|
*/
|
|
98
113
|
setMany(entryOrRawElements: Iterable<R | [K, V]>): boolean[];
|
|
99
114
|
/**
|
|
115
|
+
* Time Complexity: O(1)
|
|
116
|
+
* Space Complexity: O(1)
|
|
117
|
+
*
|
|
100
118
|
* The `get` function retrieves a value from a map based on a given key, either from an object map or
|
|
101
119
|
* a string map.
|
|
102
120
|
* @param {K} key - The `key` parameter is the key used to retrieve a value from the map. It can be
|
|
@@ -106,6 +124,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
106
124
|
*/
|
|
107
125
|
get(key: K): V | undefined;
|
|
108
126
|
/**
|
|
127
|
+
* Time Complexity: O(1)
|
|
128
|
+
* Space Complexity: O(1)
|
|
129
|
+
*
|
|
109
130
|
* The `has` function checks if a given key exists in the `_objMap` or `_store` based on whether it
|
|
110
131
|
* is an object key or not.
|
|
111
132
|
* @param {K} key - The parameter "key" is of type K, which means it can be any type.
|
|
@@ -113,6 +134,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
113
134
|
*/
|
|
114
135
|
has(key: K): boolean;
|
|
115
136
|
/**
|
|
137
|
+
* Time Complexity: O(1)
|
|
138
|
+
* Space Complexity: O(1)
|
|
139
|
+
*
|
|
116
140
|
* The `delete` function removes an element from a map-like data structure based on the provided key.
|
|
117
141
|
* @param {K} key - The `key` parameter is the key of the element that you want to delete from the
|
|
118
142
|
* data structure.
|
|
@@ -292,6 +316,9 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
|
|
|
292
316
|
*/
|
|
293
317
|
set(key: K, value?: V): boolean;
|
|
294
318
|
/**
|
|
319
|
+
* Time Complexity: O(k)
|
|
320
|
+
* Space Complexity: O(k)
|
|
321
|
+
*
|
|
295
322
|
* The function `setMany` takes an iterable collection, converts each element into a key-value pair
|
|
296
323
|
* using a provided function, and sets each key-value pair in the current object, returning an array
|
|
297
324
|
* of booleans indicating the success of each set operation.
|
|
@@ -301,6 +328,9 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
|
|
|
301
328
|
*/
|
|
302
329
|
setMany(entryOrRawElements: Iterable<R | [K, V]>): boolean[];
|
|
303
330
|
/**
|
|
331
|
+
* Time Complexity: O(1)
|
|
332
|
+
* Space Complexity: O(1)
|
|
333
|
+
*
|
|
304
334
|
* The function checks if a given key exists in a map, using different logic depending on whether the
|
|
305
335
|
* key is a weak key or not.
|
|
306
336
|
* @param {K} key - The `key` parameter is the key that is being checked for existence in the map.
|
|
@@ -420,7 +450,7 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
|
|
|
420
450
|
* @returns a new `LinkedHashMap` object with the values mapped according to the provided callback
|
|
421
451
|
* function.
|
|
422
452
|
*/
|
|
423
|
-
map<
|
|
453
|
+
map<MK, MV>(callback: EntryCallback<K, V, [MK, MV]>, thisArg?: any): LinkedHashMap<MK, MV>;
|
|
424
454
|
/**
|
|
425
455
|
* Time Complexity: O(n)
|
|
426
456
|
* Space Complexity: O(1)
|
|
@@ -75,6 +75,9 @@ class HashMap extends base_1.IterableEntryBase {
|
|
|
75
75
|
return this._hashFn;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
+
* Time Complexity: O(1)
|
|
79
|
+
* Space Complexity: O(1)
|
|
80
|
+
*
|
|
78
81
|
* The function checks if a given element is an array with exactly two elements.
|
|
79
82
|
* @param {any} rawElement - The `rawElement` parameter is of type `any`, which means it can be any
|
|
80
83
|
* data type.
|
|
@@ -84,6 +87,9 @@ class HashMap extends base_1.IterableEntryBase {
|
|
|
84
87
|
return Array.isArray(rawElement) && rawElement.length === 2;
|
|
85
88
|
}
|
|
86
89
|
/**
|
|
90
|
+
* Time Complexity: O(1)
|
|
91
|
+
* Space Complexity: O(1)
|
|
92
|
+
*
|
|
87
93
|
* The function checks if the size of an object is equal to zero and returns a boolean value.
|
|
88
94
|
* @returns A boolean value indicating whether the size of the object is 0 or not.
|
|
89
95
|
*/
|
|
@@ -91,6 +97,9 @@ class HashMap extends base_1.IterableEntryBase {
|
|
|
91
97
|
return this._size === 0;
|
|
92
98
|
}
|
|
93
99
|
/**
|
|
100
|
+
* Time Complexity: O(1)
|
|
101
|
+
* Space Complexity: O(1)
|
|
102
|
+
*
|
|
94
103
|
* The clear() function resets the state of an object by clearing its internal store, object map, and
|
|
95
104
|
* size.
|
|
96
105
|
*/
|
|
@@ -100,6 +109,9 @@ class HashMap extends base_1.IterableEntryBase {
|
|
|
100
109
|
this._size = 0;
|
|
101
110
|
}
|
|
102
111
|
/**
|
|
112
|
+
* Time Complexity: O(1)
|
|
113
|
+
* Space Complexity: O(1)
|
|
114
|
+
*
|
|
103
115
|
* The `set` function adds a key-value pair to a map-like data structure, incrementing the size if
|
|
104
116
|
* the key is not already present.
|
|
105
117
|
* @param {K} key - The key parameter is the key used to identify the value in the data structure. It
|
|
@@ -125,6 +137,9 @@ class HashMap extends base_1.IterableEntryBase {
|
|
|
125
137
|
return true;
|
|
126
138
|
}
|
|
127
139
|
/**
|
|
140
|
+
* Time Complexity: O(k)
|
|
141
|
+
* Space Complexity: O(k)
|
|
142
|
+
*
|
|
128
143
|
* The function `setMany` takes an iterable collection of objects, maps each object to a key-value
|
|
129
144
|
* pair using a mapping function, and sets each key-value pair in the current object.
|
|
130
145
|
* @param entryOrRawElements - The `entryOrRawElements` parameter is an iterable collection of elements of a type
|
|
@@ -150,6 +165,9 @@ class HashMap extends base_1.IterableEntryBase {
|
|
|
150
165
|
return results;
|
|
151
166
|
}
|
|
152
167
|
/**
|
|
168
|
+
* Time Complexity: O(1)
|
|
169
|
+
* Space Complexity: O(1)
|
|
170
|
+
*
|
|
153
171
|
* The `get` function retrieves a value from a map based on a given key, either from an object map or
|
|
154
172
|
* a string map.
|
|
155
173
|
* @param {K} key - The `key` parameter is the key used to retrieve a value from the map. It can be
|
|
@@ -168,6 +186,9 @@ class HashMap extends base_1.IterableEntryBase {
|
|
|
168
186
|
}
|
|
169
187
|
}
|
|
170
188
|
/**
|
|
189
|
+
* Time Complexity: O(1)
|
|
190
|
+
* Space Complexity: O(1)
|
|
191
|
+
*
|
|
171
192
|
* The `has` function checks if a given key exists in the `_objMap` or `_store` based on whether it
|
|
172
193
|
* is an object key or not.
|
|
173
194
|
* @param {K} key - The parameter "key" is of type K, which means it can be any type.
|
|
@@ -183,6 +204,9 @@ class HashMap extends base_1.IterableEntryBase {
|
|
|
183
204
|
}
|
|
184
205
|
}
|
|
185
206
|
/**
|
|
207
|
+
* Time Complexity: O(1)
|
|
208
|
+
* Space Complexity: O(1)
|
|
209
|
+
*
|
|
186
210
|
* The `delete` function removes an element from a map-like data structure based on the provided key.
|
|
187
211
|
* @param {K} key - The `key` parameter is the key of the element that you want to delete from the
|
|
188
212
|
* data structure.
|
|
@@ -237,7 +261,7 @@ class HashMap extends base_1.IterableEntryBase {
|
|
|
237
261
|
const resultMap = new HashMap();
|
|
238
262
|
let index = 0;
|
|
239
263
|
for (const [key, value] of this) {
|
|
240
|
-
resultMap.set(key, callbackfn.call(thisArg,
|
|
264
|
+
resultMap.set(key, callbackfn.call(thisArg, key, value, index++, this));
|
|
241
265
|
}
|
|
242
266
|
return resultMap;
|
|
243
267
|
}
|
|
@@ -261,7 +285,7 @@ class HashMap extends base_1.IterableEntryBase {
|
|
|
261
285
|
const filteredMap = new HashMap();
|
|
262
286
|
let index = 0;
|
|
263
287
|
for (const [key, value] of this) {
|
|
264
|
-
if (predicate.call(thisArg,
|
|
288
|
+
if (predicate.call(thisArg, key, value, index++, this)) {
|
|
265
289
|
filteredMap.set(key, value);
|
|
266
290
|
}
|
|
267
291
|
}
|
|
@@ -523,6 +547,9 @@ class LinkedHashMap extends base_1.IterableEntryBase {
|
|
|
523
547
|
return true;
|
|
524
548
|
}
|
|
525
549
|
/**
|
|
550
|
+
* Time Complexity: O(k)
|
|
551
|
+
* Space Complexity: O(k)
|
|
552
|
+
*
|
|
526
553
|
* The function `setMany` takes an iterable collection, converts each element into a key-value pair
|
|
527
554
|
* using a provided function, and sets each key-value pair in the current object, returning an array
|
|
528
555
|
* of booleans indicating the success of each set operation.
|
|
@@ -549,6 +576,9 @@ class LinkedHashMap extends base_1.IterableEntryBase {
|
|
|
549
576
|
return results;
|
|
550
577
|
}
|
|
551
578
|
/**
|
|
579
|
+
* Time Complexity: O(1)
|
|
580
|
+
* Space Complexity: O(1)
|
|
581
|
+
*
|
|
552
582
|
* The function checks if a given key exists in a map, using different logic depending on whether the
|
|
553
583
|
* key is a weak key or not.
|
|
554
584
|
* @param {K} key - The `key` parameter is the key that is being checked for existence in the map.
|
|
@@ -728,7 +758,7 @@ class LinkedHashMap extends base_1.IterableEntryBase {
|
|
|
728
758
|
const filteredMap = new LinkedHashMap();
|
|
729
759
|
let index = 0;
|
|
730
760
|
for (const [key, value] of this) {
|
|
731
|
-
if (predicate.call(thisArg,
|
|
761
|
+
if (predicate.call(thisArg, key, value, index, this)) {
|
|
732
762
|
filteredMap.set(key, value);
|
|
733
763
|
}
|
|
734
764
|
index++;
|
|
@@ -756,8 +786,8 @@ class LinkedHashMap extends base_1.IterableEntryBase {
|
|
|
756
786
|
const mappedMap = new LinkedHashMap();
|
|
757
787
|
let index = 0;
|
|
758
788
|
for (const [key, value] of this) {
|
|
759
|
-
const newValue = callback.call(thisArg,
|
|
760
|
-
mappedMap.set(
|
|
789
|
+
const [newKey, newValue] = callback.call(thisArg, key, value, index, this);
|
|
790
|
+
mappedMap.set(newKey, newValue);
|
|
761
791
|
index++;
|
|
762
792
|
}
|
|
763
793
|
return mappedMap;
|
|
@@ -224,10 +224,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R, He
|
|
|
224
224
|
* Time Complexity: O(log n)
|
|
225
225
|
* Space Complexity: O(1)
|
|
226
226
|
*
|
|
227
|
-
*
|
|
228
|
-
* @param element - The element to
|
|
227
|
+
* The add function pushes an element into an array and then triggers a bubble-up operation.
|
|
228
|
+
* @param {E} element - The `element` parameter represents the element that you want to add to the
|
|
229
|
+
* data structure.
|
|
230
|
+
* @returns The `add` method is returning a boolean value, which is the result of calling the
|
|
231
|
+
* `_bubbleUp` method with the index `this.elements.length - 1` as an argument.
|
|
229
232
|
*/
|
|
230
233
|
add(element: E): boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Time Complexity: O(k log n)
|
|
236
|
+
* Space Complexity: O(1)
|
|
237
|
+
*
|
|
238
|
+
* The `addMany` function iterates over elements and adds them to a collection, returning an array of
|
|
239
|
+
* boolean values indicating success or failure.
|
|
240
|
+
* @param {Iterable<E> | Iterable<R>} elements - The `elements` parameter in the `addMany` method is
|
|
241
|
+
* an iterable containing elements of type `E` or `R`. The method iterates over each element in the
|
|
242
|
+
* iterable and adds them to the data structure. If a transformation function `_toElementFn` is
|
|
243
|
+
* provided, it transforms the element
|
|
244
|
+
* @returns The `addMany` method returns an array of boolean values indicating whether each element
|
|
245
|
+
* in the input iterable was successfully added to the data structure.
|
|
246
|
+
*/
|
|
247
|
+
addMany(elements: Iterable<E> | Iterable<R>): boolean[];
|
|
231
248
|
/**
|
|
232
249
|
* Time Complexity: O(log n)
|
|
233
250
|
* Space Complexity: O(1)
|
|
@@ -340,7 +357,7 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R, He
|
|
|
340
357
|
*/
|
|
341
358
|
filter(callback: ElementCallback<E, R, boolean, Heap<E, R>>, thisArg?: any): Heap<E, R>;
|
|
342
359
|
/**
|
|
343
|
-
* Time Complexity: O(n
|
|
360
|
+
* Time Complexity: O(n)
|
|
344
361
|
* Space Complexity: O(n)
|
|
345
362
|
*
|
|
346
363
|
* The `map` function creates a new heap by applying a callback function to each element of the
|
|
@@ -218,14 +218,7 @@ class Heap extends base_1.IterableElementBase {
|
|
|
218
218
|
if (comparator)
|
|
219
219
|
this._comparator = comparator;
|
|
220
220
|
}
|
|
221
|
-
|
|
222
|
-
for (const el of elements) {
|
|
223
|
-
if (this.toElementFn)
|
|
224
|
-
this.add(this.toElementFn(el));
|
|
225
|
-
else
|
|
226
|
-
this.add(el);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
221
|
+
this.addMany(elements);
|
|
229
222
|
}
|
|
230
223
|
/**
|
|
231
224
|
* The function returns an array of elements.
|
|
@@ -261,13 +254,40 @@ class Heap extends base_1.IterableElementBase {
|
|
|
261
254
|
* Time Complexity: O(log n)
|
|
262
255
|
* Space Complexity: O(1)
|
|
263
256
|
*
|
|
264
|
-
*
|
|
265
|
-
* @param element - The element to
|
|
257
|
+
* The add function pushes an element into an array and then triggers a bubble-up operation.
|
|
258
|
+
* @param {E} element - The `element` parameter represents the element that you want to add to the
|
|
259
|
+
* data structure.
|
|
260
|
+
* @returns The `add` method is returning a boolean value, which is the result of calling the
|
|
261
|
+
* `_bubbleUp` method with the index `this.elements.length - 1` as an argument.
|
|
266
262
|
*/
|
|
267
263
|
add(element) {
|
|
268
264
|
this._elements.push(element);
|
|
269
265
|
return this._bubbleUp(this.elements.length - 1);
|
|
270
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Time Complexity: O(k log n)
|
|
269
|
+
* Space Complexity: O(1)
|
|
270
|
+
*
|
|
271
|
+
* The `addMany` function iterates over elements and adds them to a collection, returning an array of
|
|
272
|
+
* boolean values indicating success or failure.
|
|
273
|
+
* @param {Iterable<E> | Iterable<R>} elements - The `elements` parameter in the `addMany` method is
|
|
274
|
+
* an iterable containing elements of type `E` or `R`. The method iterates over each element in the
|
|
275
|
+
* iterable and adds them to the data structure. If a transformation function `_toElementFn` is
|
|
276
|
+
* provided, it transforms the element
|
|
277
|
+
* @returns The `addMany` method returns an array of boolean values indicating whether each element
|
|
278
|
+
* in the input iterable was successfully added to the data structure.
|
|
279
|
+
*/
|
|
280
|
+
addMany(elements) {
|
|
281
|
+
const ans = [];
|
|
282
|
+
for (const el of elements) {
|
|
283
|
+
if (this._toElementFn) {
|
|
284
|
+
ans.push(this.add(this._toElementFn(el)));
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
ans.push(this.add(el));
|
|
288
|
+
}
|
|
289
|
+
return ans;
|
|
290
|
+
}
|
|
271
291
|
/**
|
|
272
292
|
* Time Complexity: O(log n)
|
|
273
293
|
* Space Complexity: O(1)
|
|
@@ -470,7 +490,7 @@ class Heap extends base_1.IterableElementBase {
|
|
|
470
490
|
return filteredList;
|
|
471
491
|
}
|
|
472
492
|
/**
|
|
473
|
-
* Time Complexity: O(n
|
|
493
|
+
* Time Complexity: O(n)
|
|
474
494
|
* Space Complexity: O(n)
|
|
475
495
|
*
|
|
476
496
|
* The `map` function creates a new heap by applying a callback function to each element of the
|
|
@@ -497,7 +497,7 @@ export declare class DoublyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
497
497
|
* `DoublyLinkedListOptions<E, R>`. It is an optional parameter that allows you to pass additional
|
|
498
498
|
* configuration options to customize the behavior of the DoublyLinkedList.
|
|
499
499
|
*/
|
|
500
|
-
constructor(elements?: Iterable<E> | Iterable<R
|
|
500
|
+
constructor(elements?: Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>, options?: DoublyLinkedListOptions<E, R>);
|
|
501
501
|
protected _head: DoublyLinkedListNode<E> | undefined;
|
|
502
502
|
/**
|
|
503
503
|
* The `head` function returns the first node of a doubly linked list.
|
|
@@ -533,6 +533,16 @@ export declare class DoublyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
533
533
|
* @returns The method `get last()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
|
|
534
534
|
*/
|
|
535
535
|
get last(): E | undefined;
|
|
536
|
+
/**
|
|
537
|
+
* Time Complexity: O(n)
|
|
538
|
+
* Space Complexity: O(n)
|
|
539
|
+
*
|
|
540
|
+
* The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
|
|
541
|
+
* given array.
|
|
542
|
+
* @param {E[]} data - The `data` parameter is an array of elements of type `E`.
|
|
543
|
+
* @returns The `fromArray` function returns a DoublyLinkedList object.
|
|
544
|
+
*/
|
|
545
|
+
static fromArray<E>(data: E[]): DoublyLinkedList<E, any>;
|
|
536
546
|
/**
|
|
537
547
|
* Time Complexity: O(1)
|
|
538
548
|
* Space Complexity: O(1)
|
|
@@ -585,6 +595,35 @@ export declare class DoublyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
585
595
|
* @returns The `unshift` method is returning a boolean value, specifically `true`.
|
|
586
596
|
*/
|
|
587
597
|
unshift(elementOrNode: E | DoublyLinkedListNode<E>): boolean;
|
|
598
|
+
/**
|
|
599
|
+
* Time Complexity: O(k)
|
|
600
|
+
* Space Complexity: O(k)
|
|
601
|
+
*
|
|
602
|
+
* The function `pushMany` iterates over elements and pushes them into a data structure, applying a
|
|
603
|
+
* transformation function if provided.
|
|
604
|
+
* @param {Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>} elements - The `elements`
|
|
605
|
+
* parameter in the `pushMany` function can accept an iterable containing elements of type `E`, `R`,
|
|
606
|
+
* or `DoublyLinkedListNode<E>`. The function iterates over each element in the iterable and pushes
|
|
607
|
+
* it onto the linked list. If a transformation function `to
|
|
608
|
+
* @returns The `pushMany` function is returning an array of boolean values (`ans`) which indicate
|
|
609
|
+
* the success or failure of pushing each element into the data structure.
|
|
610
|
+
*/
|
|
611
|
+
pushMany(elements: Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>): boolean[];
|
|
612
|
+
/**
|
|
613
|
+
* Time Complexity: O(k)
|
|
614
|
+
* Space Complexity: O(k)
|
|
615
|
+
*
|
|
616
|
+
* The function `unshiftMany` iterates through a collection of elements and adds them to the
|
|
617
|
+
* beginning of a Doubly Linked List, returning an array of boolean values indicating the success of
|
|
618
|
+
* each insertion.
|
|
619
|
+
* @param {Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>} elements - The `elements`
|
|
620
|
+
* parameter in the `unshiftMany` function can accept an iterable containing elements of type `E`,
|
|
621
|
+
* `R`, or `DoublyLinkedListNode<E>`. The function iterates over each element in the iterable and
|
|
622
|
+
* performs an `unshift` operation on the doubly linked list
|
|
623
|
+
* @returns The `unshiftMany` function returns an array of boolean values indicating the success of
|
|
624
|
+
* each unshift operation performed on the elements passed as input.
|
|
625
|
+
*/
|
|
626
|
+
unshiftMany(elements: Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>): boolean[];
|
|
588
627
|
/**
|
|
589
628
|
* Time Complexity: O(n)
|
|
590
629
|
* Space Complexity: O(1)
|
|
@@ -830,18 +869,14 @@ export declare class DoublyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
830
869
|
* Time Complexity: O(n)
|
|
831
870
|
* Space Complexity: O(1)
|
|
832
871
|
*
|
|
872
|
+
* The function `countOccurrences` iterates through a doubly linked list and counts the occurrences
|
|
873
|
+
* of a specified element or nodes that satisfy a given predicate.
|
|
874
|
+
* @param {E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)} elementOrNode
|
|
875
|
+
* - The `elementOrNode` parameter in the `countOccurrences` method can accept three types of values:
|
|
876
|
+
* @returns The `countOccurrences` method returns the number of occurrences of the specified element,
|
|
877
|
+
* node, or predicate function in the doubly linked list.
|
|
833
878
|
*/
|
|
834
879
|
countOccurrences(elementOrNode: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)): number;
|
|
835
|
-
/**
|
|
836
|
-
* Time Complexity: O(n)
|
|
837
|
-
* Space Complexity: O(n)
|
|
838
|
-
*
|
|
839
|
-
* The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
|
|
840
|
-
* given array.
|
|
841
|
-
* @param {E[]} data - The `data` parameter is an array of elements of type `E`.
|
|
842
|
-
* @returns The `fromArray` function returns a DoublyLinkedList object.
|
|
843
|
-
*/
|
|
844
|
-
static fromArray<E>(data: E[]): DoublyLinkedList<E, any>;
|
|
845
880
|
/**
|
|
846
881
|
* The function returns an iterator that iterates over the values of a linked list.
|
|
847
882
|
*/
|
|
@@ -511,15 +511,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
|
|
|
511
511
|
this._head = undefined;
|
|
512
512
|
this._tail = undefined;
|
|
513
513
|
this._size = 0;
|
|
514
|
-
|
|
515
|
-
for (const el of elements) {
|
|
516
|
-
if (this.toElementFn) {
|
|
517
|
-
this.push(this.toElementFn(el));
|
|
518
|
-
}
|
|
519
|
-
else
|
|
520
|
-
this.push(el);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
514
|
+
this.pushMany(elements);
|
|
523
515
|
}
|
|
524
516
|
/**
|
|
525
517
|
* The `head` function returns the first node of a doubly linked list.
|
|
@@ -565,6 +557,18 @@ class DoublyLinkedList extends base_1.IterableElementBase {
|
|
|
565
557
|
var _a;
|
|
566
558
|
return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.value;
|
|
567
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* Time Complexity: O(n)
|
|
562
|
+
* Space Complexity: O(n)
|
|
563
|
+
*
|
|
564
|
+
* The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
|
|
565
|
+
* given array.
|
|
566
|
+
* @param {E[]} data - The `data` parameter is an array of elements of type `E`.
|
|
567
|
+
* @returns The `fromArray` function returns a DoublyLinkedList object.
|
|
568
|
+
*/
|
|
569
|
+
static fromArray(data) {
|
|
570
|
+
return new DoublyLinkedList(data);
|
|
571
|
+
}
|
|
568
572
|
/**
|
|
569
573
|
* Time Complexity: O(1)
|
|
570
574
|
* Space Complexity: O(1)
|
|
@@ -673,6 +677,55 @@ class DoublyLinkedList extends base_1.IterableElementBase {
|
|
|
673
677
|
this._size++;
|
|
674
678
|
return true;
|
|
675
679
|
}
|
|
680
|
+
/**
|
|
681
|
+
* Time Complexity: O(k)
|
|
682
|
+
* Space Complexity: O(k)
|
|
683
|
+
*
|
|
684
|
+
* The function `pushMany` iterates over elements and pushes them into a data structure, applying a
|
|
685
|
+
* transformation function if provided.
|
|
686
|
+
* @param {Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>} elements - The `elements`
|
|
687
|
+
* parameter in the `pushMany` function can accept an iterable containing elements of type `E`, `R`,
|
|
688
|
+
* or `DoublyLinkedListNode<E>`. The function iterates over each element in the iterable and pushes
|
|
689
|
+
* it onto the linked list. If a transformation function `to
|
|
690
|
+
* @returns The `pushMany` function is returning an array of boolean values (`ans`) which indicate
|
|
691
|
+
* the success or failure of pushing each element into the data structure.
|
|
692
|
+
*/
|
|
693
|
+
pushMany(elements) {
|
|
694
|
+
const ans = [];
|
|
695
|
+
for (const el of elements) {
|
|
696
|
+
if (this.toElementFn) {
|
|
697
|
+
ans.push(this.push(this.toElementFn(el)));
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
ans.push(this.push(el));
|
|
701
|
+
}
|
|
702
|
+
return ans;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Time Complexity: O(k)
|
|
706
|
+
* Space Complexity: O(k)
|
|
707
|
+
*
|
|
708
|
+
* The function `unshiftMany` iterates through a collection of elements and adds them to the
|
|
709
|
+
* beginning of a Doubly Linked List, returning an array of boolean values indicating the success of
|
|
710
|
+
* each insertion.
|
|
711
|
+
* @param {Iterable<E> | Iterable<R> | Iterable<DoublyLinkedListNode<E>>} elements - The `elements`
|
|
712
|
+
* parameter in the `unshiftMany` function can accept an iterable containing elements of type `E`,
|
|
713
|
+
* `R`, or `DoublyLinkedListNode<E>`. The function iterates over each element in the iterable and
|
|
714
|
+
* performs an `unshift` operation on the doubly linked list
|
|
715
|
+
* @returns The `unshiftMany` function returns an array of boolean values indicating the success of
|
|
716
|
+
* each unshift operation performed on the elements passed as input.
|
|
717
|
+
*/
|
|
718
|
+
unshiftMany(elements) {
|
|
719
|
+
const ans = [];
|
|
720
|
+
for (const el of elements) {
|
|
721
|
+
if (this.toElementFn) {
|
|
722
|
+
ans.push(this.unshift(this.toElementFn(el)));
|
|
723
|
+
continue;
|
|
724
|
+
}
|
|
725
|
+
ans.push(this.unshift(el));
|
|
726
|
+
}
|
|
727
|
+
return ans;
|
|
728
|
+
}
|
|
676
729
|
/**
|
|
677
730
|
* Time Complexity: O(n)
|
|
678
731
|
* Space Complexity: O(1)
|
|
@@ -1124,6 +1177,12 @@ class DoublyLinkedList extends base_1.IterableElementBase {
|
|
|
1124
1177
|
* Time Complexity: O(n)
|
|
1125
1178
|
* Space Complexity: O(1)
|
|
1126
1179
|
*
|
|
1180
|
+
* The function `countOccurrences` iterates through a doubly linked list and counts the occurrences
|
|
1181
|
+
* of a specified element or nodes that satisfy a given predicate.
|
|
1182
|
+
* @param {E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)} elementOrNode
|
|
1183
|
+
* - The `elementOrNode` parameter in the `countOccurrences` method can accept three types of values:
|
|
1184
|
+
* @returns The `countOccurrences` method returns the number of occurrences of the specified element,
|
|
1185
|
+
* node, or predicate function in the doubly linked list.
|
|
1127
1186
|
*/
|
|
1128
1187
|
countOccurrences(elementOrNode) {
|
|
1129
1188
|
const predicate = this._ensurePredicate(elementOrNode);
|
|
@@ -1137,18 +1196,6 @@ class DoublyLinkedList extends base_1.IterableElementBase {
|
|
|
1137
1196
|
}
|
|
1138
1197
|
return count;
|
|
1139
1198
|
}
|
|
1140
|
-
/**
|
|
1141
|
-
* Time Complexity: O(n)
|
|
1142
|
-
* Space Complexity: O(n)
|
|
1143
|
-
*
|
|
1144
|
-
* The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
|
|
1145
|
-
* given array.
|
|
1146
|
-
* @param {E[]} data - The `data` parameter is an array of elements of type `E`.
|
|
1147
|
-
* @returns The `fromArray` function returns a DoublyLinkedList object.
|
|
1148
|
-
*/
|
|
1149
|
-
static fromArray(data) {
|
|
1150
|
-
return new DoublyLinkedList(data);
|
|
1151
|
-
}
|
|
1152
1199
|
/**
|
|
1153
1200
|
* The function returns an iterator that iterates over the values of a linked list.
|
|
1154
1201
|
*/
|
|
@@ -40,8 +40,11 @@ export declare class SinglyLinkedListNode<E = any> {
|
|
|
40
40
|
*/
|
|
41
41
|
set next(value: SinglyLinkedListNode<E> | undefined);
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
43
46
|
export declare class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R, SinglyLinkedList<E, R>> {
|
|
44
|
-
constructor(elements?: Iterable<E> | Iterable<R
|
|
47
|
+
constructor(elements?: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>, options?: SinglyLinkedListOptions<E, R>);
|
|
45
48
|
protected _head: SinglyLinkedListNode<E> | undefined;
|
|
46
49
|
/**
|
|
47
50
|
* The `head` function returns the first node of a singly linked list.
|
|
@@ -72,6 +75,16 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
72
75
|
* @returns The size of the object, which is a number.
|
|
73
76
|
*/
|
|
74
77
|
get size(): number;
|
|
78
|
+
/**
|
|
79
|
+
* Time Complexity: O(n)
|
|
80
|
+
* Space Complexity: O(n)
|
|
81
|
+
*
|
|
82
|
+
* The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
|
|
83
|
+
* array.
|
|
84
|
+
* @param {E[]} data - The `data` parameter is an array of elements of type `E`.
|
|
85
|
+
* @returns The `fromArray` function returns a `SinglyLinkedList` object.
|
|
86
|
+
*/
|
|
87
|
+
static fromArray<E>(data: E[]): SinglyLinkedList<E, any>;
|
|
75
88
|
/**
|
|
76
89
|
* Time Complexity: O(1)
|
|
77
90
|
* Space Complexity: O(1)
|
|
@@ -111,6 +124,33 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
111
124
|
* @returns The `unshift` method is returning a boolean value, specifically `true`.
|
|
112
125
|
*/
|
|
113
126
|
unshift(elementOrNode: E | SinglyLinkedListNode<E>): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Time Complexity: O(k)
|
|
129
|
+
* Space Complexity: O(k)
|
|
130
|
+
*
|
|
131
|
+
* The function `pushMany` iterates over elements and pushes them into a data structure, applying a
|
|
132
|
+
* transformation function if provided.
|
|
133
|
+
* @param {Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>} elements - The `elements`
|
|
134
|
+
* parameter in the `pushMany` function can accept an iterable containing elements of type `E`, `R`,
|
|
135
|
+
* or `SinglyLinkedListNode<E>`.
|
|
136
|
+
* @returns The `pushMany` function returns an array of boolean values indicating whether each
|
|
137
|
+
* element was successfully pushed into the data structure.
|
|
138
|
+
*/
|
|
139
|
+
pushMany(elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>): boolean[];
|
|
140
|
+
/**
|
|
141
|
+
* Time Complexity: O(k)
|
|
142
|
+
* Space Complexity: O(k)
|
|
143
|
+
*
|
|
144
|
+
* The function `unshiftMany` iterates over elements and adds them to a data structure, optionally
|
|
145
|
+
* converting them using a provided function.
|
|
146
|
+
* @param {Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>} elements - The `elements`
|
|
147
|
+
* parameter in the `unshiftMany` function can accept an iterable containing elements of type `E`,
|
|
148
|
+
* `R`, or `SinglyLinkedListNode<E>`. The function iterates over each element in the iterable and
|
|
149
|
+
* performs an `unshift` operation on the linked list for each
|
|
150
|
+
* @returns The `unshiftMany` function is returning an array of boolean values, where each value
|
|
151
|
+
* represents the result of calling the `unshift` method on the current instance of the class.
|
|
152
|
+
*/
|
|
153
|
+
unshiftMany(elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>): boolean[];
|
|
114
154
|
/**
|
|
115
155
|
* Time Complexity: O(n)
|
|
116
156
|
* Space Complexity: O(1)
|
|
@@ -199,12 +239,18 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
199
239
|
*/
|
|
200
240
|
addAt(index: number, newElementOrNode: E | SinglyLinkedListNode<E>): boolean;
|
|
201
241
|
/**
|
|
242
|
+
* Time Complexity: O(1)
|
|
243
|
+
* Space Complexity: O(1)
|
|
244
|
+
*
|
|
202
245
|
* The function checks if the length of a data structure is equal to zero and returns a boolean value indicating
|
|
203
246
|
* whether it is empty or not.
|
|
204
247
|
* @returns A boolean value indicating whether the length of the object is equal to 0.
|
|
205
248
|
*/
|
|
206
249
|
isEmpty(): boolean;
|
|
207
250
|
/**
|
|
251
|
+
* Time Complexity: O(1)
|
|
252
|
+
* Space Complexity: O(1)
|
|
253
|
+
*
|
|
208
254
|
* The `clear` function resets the linked list by setting the head, tail, and length to undefined and 0 respectively.
|
|
209
255
|
*/
|
|
210
256
|
clear(): void;
|
|
@@ -351,16 +397,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
351
397
|
* The function `_getIterator` returns an iterable iterator that yields the values of a linked list.
|
|
352
398
|
*/
|
|
353
399
|
protected _getIterator(): IterableIterator<E>;
|
|
354
|
-
/**
|
|
355
|
-
* Time Complexity: O(n)
|
|
356
|
-
* Space Complexity: O(n)
|
|
357
|
-
*
|
|
358
|
-
* The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
|
|
359
|
-
* array.
|
|
360
|
-
* @param {E[]} data - The `data` parameter is an array of elements of type `E`.
|
|
361
|
-
* @returns The `fromArray` function returns a `SinglyLinkedList` object.
|
|
362
|
-
*/
|
|
363
|
-
static fromArray<E>(data: E[]): SinglyLinkedList<E, any>;
|
|
364
400
|
/**
|
|
365
401
|
* The _isPredicate function in TypeScript checks if the input is a function that takes a
|
|
366
402
|
* SinglyLinkedListNode as an argument and returns a boolean.
|