min-heap-typed 1.50.1 → 1.50.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-structures/base/iterable-base.d.ts +114 -9
- package/dist/data-structures/base/iterable-base.js +143 -7
- package/dist/data-structures/binary-tree/avl-tree.d.ts +43 -46
- package/dist/data-structures/binary-tree/avl-tree.js +68 -71
- package/dist/data-structures/binary-tree/binary-tree.d.ts +244 -199
- package/dist/data-structures/binary-tree/binary-tree.js +484 -376
- package/dist/data-structures/binary-tree/bst.d.ts +54 -74
- package/dist/data-structures/binary-tree/bst.js +30 -71
- package/dist/data-structures/binary-tree/rb-tree.d.ts +78 -60
- package/dist/data-structures/binary-tree/rb-tree.js +84 -89
- package/dist/data-structures/binary-tree/tree-multimap.d.ts +37 -56
- package/dist/data-structures/binary-tree/tree-multimap.js +64 -85
- package/dist/data-structures/graph/abstract-graph.d.ts +1 -0
- package/dist/data-structures/graph/abstract-graph.js +3 -0
- package/dist/data-structures/graph/directed-graph.d.ts +14 -0
- package/dist/data-structures/graph/directed-graph.js +26 -0
- package/dist/data-structures/graph/map-graph.d.ts +8 -0
- package/dist/data-structures/graph/map-graph.js +14 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +16 -0
- package/dist/data-structures/graph/undirected-graph.js +25 -0
- package/dist/data-structures/hash/hash-map.d.ts +121 -15
- package/dist/data-structures/hash/hash-map.js +160 -25
- package/dist/data-structures/heap/heap.d.ts +66 -6
- package/dist/data-structures/heap/heap.js +66 -6
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +67 -50
- package/dist/data-structures/linked-list/doubly-linked-list.js +70 -64
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +128 -103
- package/dist/data-structures/linked-list/singly-linked-list.js +130 -112
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +63 -36
- package/dist/data-structures/linked-list/skip-linked-list.js +63 -36
- package/dist/data-structures/matrix/matrix.d.ts +35 -4
- package/dist/data-structures/matrix/matrix.js +50 -11
- package/dist/data-structures/queue/deque.d.ts +49 -19
- package/dist/data-structures/queue/deque.js +101 -47
- package/dist/data-structures/queue/queue.d.ts +39 -5
- package/dist/data-structures/queue/queue.js +47 -5
- package/dist/data-structures/stack/stack.d.ts +16 -0
- package/dist/data-structures/stack/stack.js +22 -0
- package/dist/data-structures/trie/trie.d.ts +38 -1
- package/dist/data-structures/trie/trie.js +41 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/types/data-structures/hash/hash-map.d.ts +4 -3
- package/dist/types/utils/utils.d.ts +1 -0
- package/package.json +2 -2
- package/src/data-structures/base/iterable-base.ts +172 -19
- package/src/data-structures/binary-tree/avl-tree.ts +97 -97
- package/src/data-structures/binary-tree/binary-tree.ts +674 -671
- package/src/data-structures/binary-tree/bst.ts +89 -131
- package/src/data-structures/binary-tree/rb-tree.ts +127 -155
- package/src/data-structures/binary-tree/tree-multimap.ts +96 -112
- package/src/data-structures/graph/abstract-graph.ts +4 -0
- package/src/data-structures/graph/directed-graph.ts +30 -0
- package/src/data-structures/graph/map-graph.ts +15 -0
- package/src/data-structures/graph/undirected-graph.ts +28 -0
- package/src/data-structures/hash/hash-map.ts +175 -34
- package/src/data-structures/heap/heap.ts +66 -6
- package/src/data-structures/linked-list/doubly-linked-list.ts +72 -66
- package/src/data-structures/linked-list/singly-linked-list.ts +132 -114
- package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
- package/src/data-structures/matrix/matrix.ts +52 -12
- package/src/data-structures/queue/deque.ts +108 -49
- package/src/data-structures/queue/queue.ts +51 -5
- package/src/data-structures/stack/stack.ts +24 -0
- package/src/data-structures/trie/trie.ts +45 -1
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/hash/hash-map.ts +4 -3
- package/src/types/utils/utils.ts +2 -0
|
@@ -19,22 +19,39 @@ export declare class SinglyLinkedListNode<E = any> {
|
|
|
19
19
|
}
|
|
20
20
|
export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
21
21
|
/**
|
|
22
|
-
* The constructor initializes
|
|
22
|
+
* The constructor initializes a new instance of a class with an optional iterable of elements.
|
|
23
|
+
* @param elements - The `elements` parameter is an optional iterable object that contains the
|
|
24
|
+
* initial elements to be added to the instance of the class. If no `elements` are provided, an empty
|
|
25
|
+
* array will be used as the default value.
|
|
23
26
|
*/
|
|
24
27
|
constructor(elements?: Iterable<E>);
|
|
25
28
|
protected _head: SinglyLinkedListNode<E> | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The `head` function returns the first node of a singly linked list.
|
|
31
|
+
* @returns The method is returning either a SinglyLinkedListNode object or undefined.
|
|
32
|
+
*/
|
|
26
33
|
get head(): SinglyLinkedListNode<E> | undefined;
|
|
27
34
|
protected _tail: SinglyLinkedListNode<E> | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The `tail` function returns the last node of a singly linked list.
|
|
37
|
+
* @returns The method is returning either a SinglyLinkedListNode object or undefined.
|
|
38
|
+
*/
|
|
28
39
|
get tail(): SinglyLinkedListNode<E> | undefined;
|
|
29
40
|
protected _size: number;
|
|
41
|
+
/**
|
|
42
|
+
* The function returns the size of an object.
|
|
43
|
+
* @returns The size of the object, which is a number.
|
|
44
|
+
*/
|
|
30
45
|
get size(): number;
|
|
31
46
|
/**
|
|
32
|
-
* Time Complexity: O(n)
|
|
33
|
-
* Space Complexity: O(n)
|
|
47
|
+
* Time Complexity: O(n)
|
|
48
|
+
* Space Complexity: O(n)
|
|
49
|
+
* Linear time, where n is the length of the input array, as it performs a loop to push each element into the linked list.
|
|
50
|
+
* Linear space, as it creates a new node for each element in the array.
|
|
34
51
|
*/
|
|
35
52
|
/**
|
|
36
|
-
* Time Complexity: O(n)
|
|
37
|
-
* Space Complexity: O(n)
|
|
53
|
+
* Time Complexity: O(n)
|
|
54
|
+
* Space Complexity: O(n)
|
|
38
55
|
*
|
|
39
56
|
* The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
|
|
40
57
|
* array.
|
|
@@ -43,12 +60,14 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
43
60
|
*/
|
|
44
61
|
static fromArray<E>(data: E[]): SinglyLinkedList<E>;
|
|
45
62
|
/**
|
|
46
|
-
* Time Complexity: O(1)
|
|
47
|
-
* Space Complexity: O(1)
|
|
63
|
+
* Time Complexity: O(1)
|
|
64
|
+
* Space Complexity: O(1)
|
|
65
|
+
* Constant time, as it involves basic pointer adjustments.
|
|
66
|
+
* Constant space, as it only creates a new node.
|
|
48
67
|
*/
|
|
49
68
|
/**
|
|
50
|
-
* Time Complexity: O(1)
|
|
51
|
-
* Space Complexity: O(1)
|
|
69
|
+
* Time Complexity: O(1)
|
|
70
|
+
* Space Complexity: O(1)
|
|
52
71
|
*
|
|
53
72
|
* The `push` function adds a new node with the given value to the end of a singly linked list.
|
|
54
73
|
* @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
|
|
@@ -56,12 +75,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
56
75
|
*/
|
|
57
76
|
push(value: E): boolean;
|
|
58
77
|
/**
|
|
59
|
-
* Time Complexity: O(1)
|
|
60
|
-
* Space Complexity: O(1)
|
|
78
|
+
* Time Complexity: O(1)
|
|
79
|
+
* Space Complexity: O(1)
|
|
61
80
|
*/
|
|
62
81
|
/**
|
|
63
|
-
* Time Complexity: O(1)
|
|
64
|
-
* Space Complexity: O(1)
|
|
82
|
+
* Time Complexity: O(1)
|
|
83
|
+
* Space Complexity: O(1)
|
|
65
84
|
*
|
|
66
85
|
* The `push` function adds a new node with the given value to the end of a singly linked list.
|
|
67
86
|
* @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
|
|
@@ -69,12 +88,13 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
69
88
|
*/
|
|
70
89
|
addLast(value: E): boolean;
|
|
71
90
|
/**
|
|
72
|
-
* Time Complexity: O(n)
|
|
73
|
-
* Space Complexity: O(1)
|
|
91
|
+
* Time Complexity: O(n)
|
|
92
|
+
* Space Complexity: O(1)
|
|
93
|
+
* Linear time in the worst case, as it may need to traverse the list to find the last element.
|
|
74
94
|
*/
|
|
75
95
|
/**
|
|
76
|
-
* Time Complexity: O(n)
|
|
77
|
-
* Space Complexity: O(1)
|
|
96
|
+
* Time Complexity: O(n)
|
|
97
|
+
* Space Complexity: O(1)
|
|
78
98
|
*
|
|
79
99
|
* The `pop()` function removes and returns the value of the last element in a linked list, updating the head and tail
|
|
80
100
|
* pointers accordingly.
|
|
@@ -83,12 +103,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
83
103
|
*/
|
|
84
104
|
pop(): E | undefined;
|
|
85
105
|
/**
|
|
86
|
-
* Time Complexity: O(n)
|
|
87
|
-
* Space Complexity: O(1)
|
|
106
|
+
* Time Complexity: O(n)
|
|
107
|
+
* Space Complexity: O(1)
|
|
88
108
|
*/
|
|
89
109
|
/**
|
|
90
|
-
* Time Complexity: O(n)
|
|
91
|
-
* Space Complexity: O(1)
|
|
110
|
+
* Time Complexity: O(n)
|
|
111
|
+
* Space Complexity: O(1)
|
|
92
112
|
*
|
|
93
113
|
* The `pollLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
|
|
94
114
|
* pointers accordingly.
|
|
@@ -97,36 +117,36 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
97
117
|
*/
|
|
98
118
|
pollLast(): E | undefined;
|
|
99
119
|
/**
|
|
100
|
-
* Time Complexity: O(1)
|
|
101
|
-
* Space Complexity: O(1)
|
|
120
|
+
* Time Complexity: O(1)
|
|
121
|
+
* Space Complexity: O(1)
|
|
102
122
|
*/
|
|
103
123
|
/**
|
|
104
|
-
* Time Complexity: O(1)
|
|
105
|
-
* Space Complexity: O(1)
|
|
124
|
+
* Time Complexity: O(1)
|
|
125
|
+
* Space Complexity: O(1)
|
|
106
126
|
*
|
|
107
127
|
* The `shift()` function removes and returns the value of the first node in a linked list.
|
|
108
128
|
* @returns The value of the node that is being removed from the beginning of the linked list.
|
|
109
129
|
*/
|
|
110
130
|
shift(): E | undefined;
|
|
111
131
|
/**
|
|
112
|
-
* Time Complexity: O(1)
|
|
113
|
-
* Space Complexity: O(1)
|
|
132
|
+
* Time Complexity: O(1)
|
|
133
|
+
* Space Complexity: O(1)
|
|
114
134
|
*/
|
|
115
135
|
/**
|
|
116
|
-
* Time Complexity: O(1)
|
|
117
|
-
* Space Complexity: O(1)
|
|
136
|
+
* Time Complexity: O(1)
|
|
137
|
+
* Space Complexity: O(1)
|
|
118
138
|
*
|
|
119
139
|
* The `pollFirst()` function removes and returns the value of the first node in a linked list.
|
|
120
140
|
* @returns The value of the node that is being removed from the beginning of the linked list.
|
|
121
141
|
*/
|
|
122
142
|
pollFirst(): E | undefined;
|
|
123
143
|
/**
|
|
124
|
-
* Time Complexity: O(1)
|
|
125
|
-
* Space Complexity: O(1)
|
|
144
|
+
* Time Complexity: O(1)
|
|
145
|
+
* Space Complexity: O(1)
|
|
126
146
|
*/
|
|
127
147
|
/**
|
|
128
|
-
* Time Complexity: O(1)
|
|
129
|
-
* Space Complexity: O(1)
|
|
148
|
+
* Time Complexity: O(1)
|
|
149
|
+
* Space Complexity: O(1)
|
|
130
150
|
*
|
|
131
151
|
* The unshift function adds a new node with the given value to the beginning of a singly linked list.
|
|
132
152
|
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
|
|
@@ -134,12 +154,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
134
154
|
*/
|
|
135
155
|
unshift(value: E): boolean;
|
|
136
156
|
/**
|
|
137
|
-
* Time Complexity: O(1)
|
|
138
|
-
* Space Complexity: O(1)
|
|
157
|
+
* Time Complexity: O(1)
|
|
158
|
+
* Space Complexity: O(1)
|
|
139
159
|
*/
|
|
140
160
|
/**
|
|
141
|
-
* Time Complexity: O(1)
|
|
142
|
-
* Space Complexity: O(1)
|
|
161
|
+
* Time Complexity: O(1)
|
|
162
|
+
* Space Complexity: O(1)
|
|
143
163
|
*
|
|
144
164
|
* The addFirst function adds a new node with the given value to the beginning of a singly linked list.
|
|
145
165
|
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
|
|
@@ -147,27 +167,28 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
147
167
|
*/
|
|
148
168
|
addFirst(value: E): boolean;
|
|
149
169
|
/**
|
|
150
|
-
* Time Complexity: O(n)
|
|
151
|
-
* Space Complexity: O(1)
|
|
170
|
+
* Time Complexity: O(n)
|
|
171
|
+
* Space Complexity: O(1)
|
|
172
|
+
* Linear time, where n is the index, as it may need to traverse the list to find the desired node.
|
|
152
173
|
*/
|
|
153
174
|
/**
|
|
154
|
-
* Time Complexity: O(n)
|
|
155
|
-
* Space Complexity: O(1)
|
|
175
|
+
* Time Complexity: O(n)
|
|
176
|
+
* Space Complexity: O(1)
|
|
156
177
|
*
|
|
157
|
-
* The function `
|
|
178
|
+
* The function `at` returns the value at a specified index in a linked list, or undefined if the index is out of range.
|
|
158
179
|
* @param {number} index - The index parameter is a number that represents the position of the element we want to
|
|
159
180
|
* retrieve from the list.
|
|
160
|
-
* @returns The method `
|
|
181
|
+
* @returns The method `at(index: number): E | undefined` returns the value at the specified index in the linked list, or
|
|
161
182
|
* `undefined` if the index is out of bounds.
|
|
162
183
|
*/
|
|
163
|
-
|
|
184
|
+
at(index: number): E | undefined;
|
|
164
185
|
/**
|
|
165
|
-
* Time Complexity: O(n)
|
|
166
|
-
* Space Complexity: O(1)
|
|
186
|
+
* Time Complexity: O(n)
|
|
187
|
+
* Space Complexity: O(1)
|
|
167
188
|
*/
|
|
168
189
|
/**
|
|
169
|
-
* Time Complexity: O(n)
|
|
170
|
-
* Space Complexity: O(1)
|
|
190
|
+
* Time Complexity: O(n)
|
|
191
|
+
* Space Complexity: O(1)
|
|
171
192
|
*
|
|
172
193
|
* The function `getNodeAt` returns the node at a given index in a singly linked list.
|
|
173
194
|
* @param {number} index - The `index` parameter is a number that represents the position of the node we want to
|
|
@@ -177,12 +198,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
177
198
|
*/
|
|
178
199
|
getNodeAt(index: number): SinglyLinkedListNode<E> | undefined;
|
|
179
200
|
/**
|
|
180
|
-
* Time Complexity: O(n)
|
|
181
|
-
* Space Complexity: O(1)
|
|
201
|
+
* Time Complexity: O(n)
|
|
202
|
+
* Space Complexity: O(1)
|
|
182
203
|
*/
|
|
183
204
|
/**
|
|
184
|
-
* Time Complexity: O(n)
|
|
185
|
-
* Space Complexity: O(1)
|
|
205
|
+
* Time Complexity: O(n)
|
|
206
|
+
* Space Complexity: O(1)
|
|
186
207
|
*
|
|
187
208
|
* The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
|
|
188
209
|
* @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
|
|
@@ -192,12 +213,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
192
213
|
*/
|
|
193
214
|
deleteAt(index: number): boolean;
|
|
194
215
|
/**
|
|
195
|
-
* Time Complexity: O(n)
|
|
196
|
-
* Space Complexity: O(1)
|
|
216
|
+
* Time Complexity: O(n)
|
|
217
|
+
* Space Complexity: O(1)
|
|
197
218
|
*/
|
|
198
219
|
/**
|
|
199
|
-
* Time Complexity: O(n)
|
|
200
|
-
* Space Complexity: O(1)
|
|
220
|
+
* Time Complexity: O(n)
|
|
221
|
+
* Space Complexity: O(1)
|
|
201
222
|
*
|
|
202
223
|
* The delete function removes a node with a specific value from a singly linked list.
|
|
203
224
|
* @param {E | SinglyLinkedListNode<E>} valueOrNode - The `valueOrNode` parameter can accept either a value of type `E`
|
|
@@ -207,12 +228,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
207
228
|
*/
|
|
208
229
|
delete(valueOrNode: E | SinglyLinkedListNode<E> | undefined): boolean;
|
|
209
230
|
/**
|
|
210
|
-
* Time Complexity: O(n)
|
|
211
|
-
* Space Complexity: O(1)
|
|
231
|
+
* Time Complexity: O(n)
|
|
232
|
+
* Space Complexity: O(1)
|
|
212
233
|
*/
|
|
213
234
|
/**
|
|
214
|
-
* Time Complexity: O(n)
|
|
215
|
-
* Space Complexity: O(1)
|
|
235
|
+
* Time Complexity: O(n)
|
|
236
|
+
* Space Complexity: O(1)
|
|
216
237
|
*
|
|
217
238
|
* The `addAt` function inserts a value at a specified index in a singly linked list.
|
|
218
239
|
* @param {number} index - The index parameter represents the position at which the new value should be inserted in the
|
|
@@ -234,51 +255,38 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
234
255
|
*/
|
|
235
256
|
clear(): void;
|
|
236
257
|
/**
|
|
237
|
-
* Time Complexity: O(n)
|
|
238
|
-
* Space Complexity: O(n)
|
|
258
|
+
* Time Complexity: O(n)
|
|
259
|
+
* Space Complexity: O(n)
|
|
260
|
+
* Linear time, where n is the length of the list, as it needs to traverse the entire list to convert it to an array.
|
|
261
|
+
* Linear space, as it creates an array with the same length as the list.
|
|
239
262
|
*/
|
|
240
263
|
/**
|
|
241
|
-
* Time Complexity: O(n)
|
|
242
|
-
* Space Complexity: O(n)
|
|
264
|
+
* Time Complexity: O(n)
|
|
265
|
+
* Space Complexity: O(n)
|
|
243
266
|
*
|
|
244
267
|
* The `toArray` function converts a linked list into an array.
|
|
245
268
|
* @returns The `toArray()` method is returning an array of type `E[]`.
|
|
246
269
|
*/
|
|
247
270
|
toArray(): E[];
|
|
248
271
|
/**
|
|
249
|
-
* Time Complexity: O(n)
|
|
250
|
-
* Space Complexity: O(1)
|
|
272
|
+
* Time Complexity: O(n)
|
|
273
|
+
* Space Complexity: O(1)
|
|
251
274
|
*/
|
|
252
275
|
/**
|
|
253
|
-
* Time Complexity: O(n)
|
|
254
|
-
* Space Complexity: O(1)
|
|
276
|
+
* Time Complexity: O(n)
|
|
277
|
+
* Space Complexity: O(1)
|
|
255
278
|
*
|
|
256
279
|
* The `reverse` function reverses the order of the nodes in a singly linked list.
|
|
257
280
|
* @returns The reverse() method does not return anything. It has a return type of void.
|
|
258
281
|
*/
|
|
259
282
|
reverse(): this;
|
|
260
283
|
/**
|
|
261
|
-
* Time Complexity: O(n)
|
|
262
|
-
* Space Complexity: O(1)
|
|
263
|
-
*/
|
|
264
|
-
/**
|
|
265
|
-
* Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
|
|
266
|
-
* Space Complexity: O(1) - Constant space.
|
|
267
|
-
*
|
|
268
|
-
* The `find` function iterates through a linked list and returns the first element that satisfies a given condition.
|
|
269
|
-
* @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
|
|
270
|
-
* function is used to determine whether a particular value in the linked list satisfies a certain condition.
|
|
271
|
-
* @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
|
|
272
|
-
* the callback function. If no element satisfies the condition, it returns `undefined`.
|
|
273
|
-
*/
|
|
274
|
-
find(callback: (value: E) => boolean): E | undefined;
|
|
275
|
-
/**
|
|
276
|
-
* Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
|
|
277
|
-
* Space Complexity: O(1) - Constant space.
|
|
284
|
+
* Time Complexity: O(n)
|
|
285
|
+
* Space Complexity: O(1)
|
|
278
286
|
*/
|
|
279
287
|
/**
|
|
280
|
-
* Time Complexity: O(n)
|
|
281
|
-
* Space Complexity: O(1)
|
|
288
|
+
* Time Complexity: O(n)
|
|
289
|
+
* Space Complexity: O(1)
|
|
282
290
|
*
|
|
283
291
|
* The `indexOf` function returns the index of the first occurrence of a given value in a linked list.
|
|
284
292
|
* @param {E} value - The value parameter is the value that you want to find the index of in the linked list.
|
|
@@ -287,12 +295,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
287
295
|
*/
|
|
288
296
|
indexOf(value: E): number;
|
|
289
297
|
/**
|
|
290
|
-
* Time Complexity: O(n)
|
|
291
|
-
* Space Complexity: O(1)
|
|
298
|
+
* Time Complexity: O(n)
|
|
299
|
+
* Space Complexity: O(1)
|
|
292
300
|
*/
|
|
293
301
|
/**
|
|
294
|
-
* Time Complexity: O(n)
|
|
295
|
-
* Space Complexity: O(1)
|
|
302
|
+
* Time Complexity: O(n)
|
|
303
|
+
* Space Complexity: O(1)
|
|
296
304
|
*
|
|
297
305
|
* The function finds a node in a singly linked list by its value and returns the node if found, otherwise returns
|
|
298
306
|
* undefined.
|
|
@@ -302,12 +310,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
302
310
|
*/
|
|
303
311
|
getNode(value: E): SinglyLinkedListNode<E> | undefined;
|
|
304
312
|
/**
|
|
305
|
-
* Time Complexity: O(n)
|
|
306
|
-
* Space Complexity: O(1)
|
|
313
|
+
* Time Complexity: O(n)
|
|
314
|
+
* Space Complexity: O(1)
|
|
307
315
|
*/
|
|
308
316
|
/**
|
|
309
|
-
* Time Complexity: O(n)
|
|
310
|
-
* Space Complexity: O(1)
|
|
317
|
+
* Time Complexity: O(n)
|
|
318
|
+
* Space Complexity: O(1)
|
|
311
319
|
*
|
|
312
320
|
* The `addBefore` function inserts a new value before an existing value in a singly linked list.
|
|
313
321
|
* @param {E | SinglyLinkedListNode<E>} existingValueOrNode - The existing value or node that you want to insert the
|
|
@@ -318,12 +326,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
318
326
|
*/
|
|
319
327
|
addBefore(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
|
|
320
328
|
/**
|
|
321
|
-
* Time Complexity: O(n)
|
|
322
|
-
* Space Complexity: O(1)
|
|
329
|
+
* Time Complexity: O(n)
|
|
330
|
+
* Space Complexity: O(1)
|
|
323
331
|
*/
|
|
324
332
|
/**
|
|
325
|
-
* Time Complexity: O(n)
|
|
326
|
-
* Space Complexity: O(1)
|
|
333
|
+
* Time Complexity: O(n)
|
|
334
|
+
* Space Complexity: O(1)
|
|
327
335
|
*
|
|
328
336
|
* The `addAfter` function inserts a new node with a given value after an existing node in a singly linked list.
|
|
329
337
|
* @param {E | SinglyLinkedListNode<E>} existingValueOrNode - The existing value or node in the linked list after which
|
|
@@ -334,18 +342,32 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
334
342
|
*/
|
|
335
343
|
addAfter(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
|
|
336
344
|
/**
|
|
337
|
-
* Time Complexity: O(n)
|
|
338
|
-
* Space Complexity: O(1)
|
|
345
|
+
* Time Complexity: O(n)
|
|
346
|
+
* Space Complexity: O(1)
|
|
339
347
|
*/
|
|
340
348
|
/**
|
|
341
|
-
* Time Complexity: O(n)
|
|
342
|
-
* Space Complexity: O(1)
|
|
349
|
+
* Time Complexity: O(n)
|
|
350
|
+
* Space Complexity: O(1)
|
|
343
351
|
*
|
|
344
352
|
* The function counts the number of occurrences of a given value in a linked list.
|
|
345
353
|
* @param {E} value - The value parameter is the value that you want to count the occurrences of in the linked list.
|
|
346
354
|
* @returns The count of occurrences of the given value in the linked list.
|
|
347
355
|
*/
|
|
348
356
|
countOccurrences(value: E): number;
|
|
357
|
+
/**
|
|
358
|
+
* Time Complexity: O(n)
|
|
359
|
+
* Space Complexity: O(n)
|
|
360
|
+
*/
|
|
361
|
+
/**
|
|
362
|
+
* Time Complexity: O(n)
|
|
363
|
+
* Space Complexity: O(n)
|
|
364
|
+
*
|
|
365
|
+
* The `clone` function returns a new instance of the `SinglyLinkedList` class with the same values
|
|
366
|
+
* as the original list.
|
|
367
|
+
* @returns The `clone()` method is returning a new instance of the `SinglyLinkedList` class, which
|
|
368
|
+
* is a clone of the original list.
|
|
369
|
+
*/
|
|
370
|
+
clone(): SinglyLinkedList<E>;
|
|
349
371
|
/**
|
|
350
372
|
* Time Complexity: O(n)
|
|
351
373
|
* Space Complexity: O(n)
|
|
@@ -387,5 +409,8 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
|
|
|
387
409
|
* of applying the provided `callback` function to each element in the original list.
|
|
388
410
|
*/
|
|
389
411
|
map<T>(callback: ElementCallback<E, T>, thisArg?: any): SinglyLinkedList<T>;
|
|
412
|
+
/**
|
|
413
|
+
* The function `_getIterator` returns an iterable iterator that yields the values of a linked list.
|
|
414
|
+
*/
|
|
390
415
|
protected _getIterator(): IterableIterator<E>;
|
|
391
416
|
}
|