doubly-linked-list-typed 1.52.4 → 1.52.5
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 +1 -37
- package/dist/data-structures/base/iterable-element-base.js +1 -37
- package/dist/data-structures/base/iterable-entry-base.d.ts +2 -54
- package/dist/data-structures/base/iterable-entry-base.js +1 -49
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
- package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -46
- package/dist/data-structures/binary-tree/avl-tree.js +0 -46
- package/dist/data-structures/binary-tree/binary-tree.d.ts +82 -147
- package/dist/data-structures/binary-tree/binary-tree.js +299 -331
- package/dist/data-structures/binary-tree/bst.d.ts +1 -40
- package/dist/data-structures/binary-tree/bst.js +12 -44
- package/dist/data-structures/binary-tree/rb-tree.d.ts +0 -48
- package/dist/data-structures/binary-tree/rb-tree.js +2 -50
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
- package/dist/data-structures/binary-tree/tree-multi-map.js +9 -41
- package/dist/data-structures/graph/abstract-graph.d.ts +0 -75
- package/dist/data-structures/graph/abstract-graph.js +0 -75
- package/dist/data-structures/graph/directed-graph.d.ts +0 -98
- package/dist/data-structures/graph/directed-graph.js +0 -98
- package/dist/data-structures/graph/undirected-graph.d.ts +0 -50
- package/dist/data-structures/graph/undirected-graph.js +0 -50
- package/dist/data-structures/hash/hash-map.d.ts +5 -92
- package/dist/data-structures/hash/hash-map.js +27 -111
- package/dist/data-structures/heap/heap.d.ts +0 -32
- package/dist/data-structures/heap/heap.js +0 -32
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
- package/dist/data-structures/linked-list/doubly-linked-list.js +5 -88
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +1 -83
- package/dist/data-structures/linked-list/singly-linked-list.js +2 -84
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +1 -35
- package/dist/data-structures/linked-list/skip-linked-list.js +1 -35
- package/dist/data-structures/queue/deque.d.ts +1 -98
- package/dist/data-structures/queue/deque.js +3 -99
- package/dist/data-structures/queue/queue.d.ts +1 -54
- package/dist/data-structures/queue/queue.js +0 -53
- package/dist/data-structures/stack/stack.d.ts +1 -34
- package/dist/data-structures/stack/stack.js +1 -34
- package/dist/data-structures/tree/tree.js +2 -1
- package/dist/data-structures/trie/trie.d.ts +0 -64
- package/dist/data-structures/trie/trie.js +0 -64
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
- package/dist/types/data-structures/binary-tree/binary-tree.js +6 -0
- package/dist/types/utils/utils.d.ts +13 -12
- package/dist/utils/number.d.ts +13 -0
- package/dist/utils/number.js +13 -0
- package/dist/utils/utils.d.ts +125 -3
- package/dist/utils/utils.js +177 -21
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +2 -42
- package/src/data-structures/base/iterable-entry-base.ts +3 -62
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +8 -48
- package/src/data-structures/binary-tree/avl-tree.ts +0 -57
- package/src/data-structures/binary-tree/binary-tree.ts +329 -358
- package/src/data-structures/binary-tree/bst.ts +11 -54
- package/src/data-structures/binary-tree/rb-tree.ts +2 -62
- package/src/data-structures/binary-tree/tree-multi-map.ts +8 -48
- package/src/data-structures/graph/abstract-graph.ts +0 -92
- package/src/data-structures/graph/directed-graph.ts +0 -122
- package/src/data-structures/graph/undirected-graph.ts +0 -62
- package/src/data-structures/hash/hash-map.ts +29 -133
- package/src/data-structures/heap/heap.ts +0 -40
- package/src/data-structures/linked-list/doubly-linked-list.ts +5 -112
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -104
- package/src/data-structures/linked-list/skip-linked-list.ts +1 -44
- package/src/data-structures/queue/deque.ts +2 -125
- package/src/data-structures/queue/queue.ts +1 -68
- package/src/data-structures/stack/stack.ts +1 -43
- package/src/data-structures/tree/tree.ts +1 -1
- package/src/data-structures/trie/trie.ts +0 -80
- package/src/types/data-structures/binary-tree/binary-tree.ts +8 -1
- package/src/types/utils/utils.ts +17 -15
- package/src/utils/number.ts +13 -0
- package/src/utils/utils.ts +174 -18
|
@@ -72,12 +72,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
72
72
|
* @returns The size of the object, which is a number.
|
|
73
73
|
*/
|
|
74
74
|
get size(): number;
|
|
75
|
-
/**
|
|
76
|
-
* Time Complexity: O(n)
|
|
77
|
-
* Space Complexity: O(n)
|
|
78
|
-
* Linear time, where n is the length of the input array, as it performs a loop to push each element into the linked list.
|
|
79
|
-
* Linear space, as it creates a new node for each element in the array.
|
|
80
|
-
*/
|
|
81
75
|
/**
|
|
82
76
|
* Time Complexity: O(n)
|
|
83
77
|
* Space Complexity: O(n)
|
|
@@ -88,10 +82,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
88
82
|
* @returns The `fromArray` function returns a `SinglyLinkedList` object.
|
|
89
83
|
*/
|
|
90
84
|
static fromArray<E>(data: E[]): SinglyLinkedList<E, any>;
|
|
91
|
-
/**
|
|
92
|
-
* Time Complexity: O(1)
|
|
93
|
-
* Space Complexity: O(1)
|
|
94
|
-
*/
|
|
95
85
|
/**
|
|
96
86
|
* Time Complexity: O(1)
|
|
97
87
|
* Space Complexity: O(1)
|
|
@@ -102,11 +92,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
102
92
|
* @returns The `push` method is returning a boolean value, `true`.
|
|
103
93
|
*/
|
|
104
94
|
push(element: E): boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Time Complexity: O(n)
|
|
107
|
-
* Space Complexity: O(1)
|
|
108
|
-
* Linear time in the worst case, as it may need to traverse the list to find the last element.
|
|
109
|
-
*/
|
|
110
95
|
/**
|
|
111
96
|
* Time Complexity: O(n)
|
|
112
97
|
* Space Complexity: O(1)
|
|
@@ -116,10 +101,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
116
101
|
* list.
|
|
117
102
|
*/
|
|
118
103
|
pop(): E | undefined;
|
|
119
|
-
/**
|
|
120
|
-
* Time Complexity: O(1)
|
|
121
|
-
* Space Complexity: O(1)
|
|
122
|
-
*/
|
|
123
104
|
/**
|
|
124
105
|
* Time Complexity: O(1)
|
|
125
106
|
* Space Complexity: O(1)
|
|
@@ -128,10 +109,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
128
109
|
* @returns The value of the removed node.
|
|
129
110
|
*/
|
|
130
111
|
shift(): E | undefined;
|
|
131
|
-
/**
|
|
132
|
-
* Time Complexity: O(1)
|
|
133
|
-
* Space Complexity: O(1)
|
|
134
|
-
*/
|
|
135
112
|
/**
|
|
136
113
|
* Time Complexity: O(1)
|
|
137
114
|
* Space Complexity: O(1)
|
|
@@ -142,10 +119,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
142
119
|
* @returns The `unshift` method is returning a boolean value, `true`.
|
|
143
120
|
*/
|
|
144
121
|
unshift(element: E): boolean;
|
|
145
|
-
/**
|
|
146
|
-
* Time Complexity: O(n)
|
|
147
|
-
* Space Complexity: O(1)
|
|
148
|
-
*/
|
|
149
122
|
/**
|
|
150
123
|
* Time Complexity: O(n)
|
|
151
124
|
* Space Complexity: O(1)
|
|
@@ -157,10 +130,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
157
130
|
* `undefined` if the index is out of bounds.
|
|
158
131
|
*/
|
|
159
132
|
at(index: number): E | undefined;
|
|
160
|
-
/**
|
|
161
|
-
* Time Complexity: O(n)
|
|
162
|
-
* Space Complexity: O(1)
|
|
163
|
-
*/
|
|
164
133
|
/**
|
|
165
134
|
* Time Complexity: O(n)
|
|
166
135
|
* Space Complexity: O(1)
|
|
@@ -172,10 +141,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
172
141
|
* specified index exists, or `undefined` if the index is out of bounds.
|
|
173
142
|
*/
|
|
174
143
|
getNodeAt(index: number): SinglyLinkedListNode<E> | undefined;
|
|
175
|
-
/**
|
|
176
|
-
* Time Complexity: O(n)
|
|
177
|
-
* Space Complexity: O(1)
|
|
178
|
-
*/
|
|
179
144
|
/**
|
|
180
145
|
* Time Complexity: O(n)
|
|
181
146
|
* Space Complexity: O(1)
|
|
@@ -187,10 +152,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
187
152
|
* bounds.
|
|
188
153
|
*/
|
|
189
154
|
deleteAt(index: number): boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Time Complexity: O(n)
|
|
192
|
-
* Space Complexity: O(1)
|
|
193
|
-
*/
|
|
194
155
|
/**
|
|
195
156
|
* Time Complexity: O(n)
|
|
196
157
|
* Space Complexity: O(1)
|
|
@@ -202,10 +163,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
202
163
|
* successfully deleted from the linked list, and `false` if the value or node is not found in the linked list.
|
|
203
164
|
*/
|
|
204
165
|
delete(valueOrNode: E | SinglyLinkedListNode<E> | undefined): boolean;
|
|
205
|
-
/**
|
|
206
|
-
* Time Complexity: O(n)
|
|
207
|
-
* Space Complexity: O(1)
|
|
208
|
-
*/
|
|
209
166
|
/**
|
|
210
167
|
* Time Complexity: O(n)
|
|
211
168
|
* Space Complexity: O(1)
|
|
@@ -229,12 +186,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
229
186
|
* The `clear` function resets the linked list by setting the head, tail, and length to undefined and 0 respectively.
|
|
230
187
|
*/
|
|
231
188
|
clear(): void;
|
|
232
|
-
/**
|
|
233
|
-
* Time Complexity: O(n)
|
|
234
|
-
* Space Complexity: O(n)
|
|
235
|
-
* Linear time, where n is the length of the list, as it needs to traverse the entire list to convert it to an array.
|
|
236
|
-
* Linear space, as it creates an array with the same length as the list.
|
|
237
|
-
*/
|
|
238
189
|
/**
|
|
239
190
|
* Time Complexity: O(n)
|
|
240
191
|
* Space Complexity: O(n)
|
|
@@ -243,10 +194,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
243
194
|
* @returns The `toArray()` method is returning an array of type `E[]`.
|
|
244
195
|
*/
|
|
245
196
|
toArray(): E[];
|
|
246
|
-
/**
|
|
247
|
-
* Time Complexity: O(n)
|
|
248
|
-
* Space Complexity: O(1)
|
|
249
|
-
*/
|
|
250
197
|
/**
|
|
251
198
|
* Time Complexity: O(n)
|
|
252
199
|
* Space Complexity: O(1)
|
|
@@ -255,10 +202,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
255
202
|
* @returns The reverse() method does not return anything. It has a return type of void.
|
|
256
203
|
*/
|
|
257
204
|
reverse(): this;
|
|
258
|
-
/**
|
|
259
|
-
* Time Complexity: O(n)
|
|
260
|
-
* Space Complexity: O(1)
|
|
261
|
-
*/
|
|
262
205
|
/**
|
|
263
206
|
* Time Complexity: O(n)
|
|
264
207
|
* Space Complexity: O(1)
|
|
@@ -269,10 +212,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
269
212
|
* value is not found, it returns -1.
|
|
270
213
|
*/
|
|
271
214
|
indexOf(value: E): number;
|
|
272
|
-
/**
|
|
273
|
-
* Time Complexity: O(n)
|
|
274
|
-
* Space Complexity: O(1)
|
|
275
|
-
*/
|
|
276
215
|
/**
|
|
277
216
|
* Time Complexity: O(n)
|
|
278
217
|
* Space Complexity: O(1)
|
|
@@ -284,10 +223,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
284
223
|
* the specified value is found, the function returns `undefined`.
|
|
285
224
|
*/
|
|
286
225
|
getNode(value: E): SinglyLinkedListNode<E> | undefined;
|
|
287
|
-
/**
|
|
288
|
-
* Time Complexity: O(n)
|
|
289
|
-
* Space Complexity: O(1)
|
|
290
|
-
*/
|
|
291
226
|
/**
|
|
292
227
|
* Time Complexity: O(n)
|
|
293
228
|
* Space Complexity: O(1)
|
|
@@ -300,10 +235,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
300
235
|
* inserted before the existing value, and `false` otherwise.
|
|
301
236
|
*/
|
|
302
237
|
addBefore(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
|
|
303
|
-
/**
|
|
304
|
-
* Time Complexity: O(n)
|
|
305
|
-
* Space Complexity: O(1)
|
|
306
|
-
*/
|
|
307
238
|
/**
|
|
308
239
|
* Time Complexity: O(n)
|
|
309
240
|
* Space Complexity: O(1)
|
|
@@ -316,10 +247,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
316
247
|
* existing value or node, and false if the existing value or node was not found in the linked list.
|
|
317
248
|
*/
|
|
318
249
|
addAfter(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
|
|
319
|
-
/**
|
|
320
|
-
* Time Complexity: O(n)
|
|
321
|
-
* Space Complexity: O(1)
|
|
322
|
-
*/
|
|
323
250
|
/**
|
|
324
251
|
* Time Complexity: O(n)
|
|
325
252
|
* Space Complexity: O(1)
|
|
@@ -329,10 +256,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
329
256
|
* @returns The count of occurrences of the given value in the linked list.
|
|
330
257
|
*/
|
|
331
258
|
countOccurrences(value: E): number;
|
|
332
|
-
/**
|
|
333
|
-
* Time Complexity: O(n)
|
|
334
|
-
* Space Complexity: O(n)
|
|
335
|
-
*/
|
|
336
259
|
/**
|
|
337
260
|
* Time Complexity: O(n)
|
|
338
261
|
* Space Complexity: O(n)
|
|
@@ -343,10 +266,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
343
266
|
* is a clone of the original list.
|
|
344
267
|
*/
|
|
345
268
|
clone(): SinglyLinkedList<E, R>;
|
|
346
|
-
/**
|
|
347
|
-
* Time Complexity: O(n)
|
|
348
|
-
* Space Complexity: O(n)
|
|
349
|
-
*/
|
|
350
269
|
/**
|
|
351
270
|
* Time Complexity: O(n)
|
|
352
271
|
* Space Complexity: O(n)
|
|
@@ -368,8 +287,7 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
|
|
|
368
287
|
/**
|
|
369
288
|
* Time Complexity: O(n)
|
|
370
289
|
* Space Complexity: O(n)
|
|
371
|
-
|
|
372
|
-
/**
|
|
290
|
+
*
|
|
373
291
|
* The `map` function takes a callback function and returns a new SinglyLinkedList with the results
|
|
374
292
|
* of applying the callback to each element in the original list.
|
|
375
293
|
* @param callback - The `callback` parameter is a function that will be called for each element in
|
|
@@ -99,12 +99,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
99
99
|
get size() {
|
|
100
100
|
return this._size;
|
|
101
101
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Time Complexity: O(n)
|
|
104
|
-
* Space Complexity: O(n)
|
|
105
|
-
* Linear time, where n is the length of the input array, as it performs a loop to push each element into the linked list.
|
|
106
|
-
* Linear space, as it creates a new node for each element in the array.
|
|
107
|
-
*/
|
|
108
102
|
/**
|
|
109
103
|
* Time Complexity: O(n)
|
|
110
104
|
* Space Complexity: O(n)
|
|
@@ -121,10 +115,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
121
115
|
}
|
|
122
116
|
return singlyLinkedList;
|
|
123
117
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Time Complexity: O(1)
|
|
126
|
-
* Space Complexity: O(1)
|
|
127
|
-
*/
|
|
128
118
|
/**
|
|
129
119
|
* Time Complexity: O(1)
|
|
130
120
|
* Space Complexity: O(1)
|
|
@@ -147,11 +137,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
147
137
|
this._size++;
|
|
148
138
|
return true;
|
|
149
139
|
}
|
|
150
|
-
/**
|
|
151
|
-
* Time Complexity: O(n)
|
|
152
|
-
* Space Complexity: O(1)
|
|
153
|
-
* Linear time in the worst case, as it may need to traverse the list to find the last element.
|
|
154
|
-
*/
|
|
155
140
|
/**
|
|
156
141
|
* Time Complexity: O(n)
|
|
157
142
|
* Space Complexity: O(1)
|
|
@@ -180,10 +165,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
180
165
|
this._size--;
|
|
181
166
|
return value;
|
|
182
167
|
}
|
|
183
|
-
/**
|
|
184
|
-
* Time Complexity: O(1)
|
|
185
|
-
* Space Complexity: O(1)
|
|
186
|
-
*/
|
|
187
168
|
/**
|
|
188
169
|
* Time Complexity: O(1)
|
|
189
170
|
* Space Complexity: O(1)
|
|
@@ -199,10 +180,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
199
180
|
this._size--;
|
|
200
181
|
return removedNode.value;
|
|
201
182
|
}
|
|
202
|
-
/**
|
|
203
|
-
* Time Complexity: O(1)
|
|
204
|
-
* Space Complexity: O(1)
|
|
205
|
-
*/
|
|
206
183
|
/**
|
|
207
184
|
* Time Complexity: O(1)
|
|
208
185
|
* Space Complexity: O(1)
|
|
@@ -225,10 +202,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
225
202
|
this._size++;
|
|
226
203
|
return true;
|
|
227
204
|
}
|
|
228
|
-
/**
|
|
229
|
-
* Time Complexity: O(n)
|
|
230
|
-
* Space Complexity: O(1)
|
|
231
|
-
*/
|
|
232
205
|
/**
|
|
233
206
|
* Time Complexity: O(n)
|
|
234
207
|
* Space Complexity: O(1)
|
|
@@ -248,10 +221,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
248
221
|
}
|
|
249
222
|
return current.value;
|
|
250
223
|
}
|
|
251
|
-
/**
|
|
252
|
-
* Time Complexity: O(n)
|
|
253
|
-
* Space Complexity: O(1)
|
|
254
|
-
*/
|
|
255
224
|
/**
|
|
256
225
|
* Time Complexity: O(n)
|
|
257
226
|
* Space Complexity: O(1)
|
|
@@ -269,10 +238,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
269
238
|
}
|
|
270
239
|
return current;
|
|
271
240
|
}
|
|
272
|
-
/**
|
|
273
|
-
* Time Complexity: O(n)
|
|
274
|
-
* Space Complexity: O(1)
|
|
275
|
-
*/
|
|
276
241
|
/**
|
|
277
242
|
* Time Complexity: O(n)
|
|
278
243
|
* Space Complexity: O(1)
|
|
@@ -300,10 +265,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
300
265
|
this._size--;
|
|
301
266
|
return true;
|
|
302
267
|
}
|
|
303
|
-
/**
|
|
304
|
-
* Time Complexity: O(n)
|
|
305
|
-
* Space Complexity: O(1)
|
|
306
|
-
*/
|
|
307
268
|
/**
|
|
308
269
|
* Time Complexity: O(n)
|
|
309
270
|
* Space Complexity: O(1)
|
|
@@ -315,7 +276,7 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
315
276
|
* successfully deleted from the linked list, and `false` if the value or node is not found in the linked list.
|
|
316
277
|
*/
|
|
317
278
|
delete(valueOrNode) {
|
|
318
|
-
if (
|
|
279
|
+
if (valueOrNode === undefined)
|
|
319
280
|
return false;
|
|
320
281
|
let value;
|
|
321
282
|
if (valueOrNode instanceof SinglyLinkedListNode) {
|
|
@@ -347,10 +308,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
347
308
|
}
|
|
348
309
|
return false;
|
|
349
310
|
}
|
|
350
|
-
/**
|
|
351
|
-
* Time Complexity: O(n)
|
|
352
|
-
* Space Complexity: O(1)
|
|
353
|
-
*/
|
|
354
311
|
/**
|
|
355
312
|
* Time Complexity: O(n)
|
|
356
313
|
* Space Complexity: O(1)
|
|
@@ -397,12 +354,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
397
354
|
this._tail = undefined;
|
|
398
355
|
this._size = 0;
|
|
399
356
|
}
|
|
400
|
-
/**
|
|
401
|
-
* Time Complexity: O(n)
|
|
402
|
-
* Space Complexity: O(n)
|
|
403
|
-
* Linear time, where n is the length of the list, as it needs to traverse the entire list to convert it to an array.
|
|
404
|
-
* Linear space, as it creates an array with the same length as the list.
|
|
405
|
-
*/
|
|
406
357
|
/**
|
|
407
358
|
* Time Complexity: O(n)
|
|
408
359
|
* Space Complexity: O(n)
|
|
@@ -419,10 +370,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
419
370
|
}
|
|
420
371
|
return array;
|
|
421
372
|
}
|
|
422
|
-
/**
|
|
423
|
-
* Time Complexity: O(n)
|
|
424
|
-
* Space Complexity: O(1)
|
|
425
|
-
*/
|
|
426
373
|
/**
|
|
427
374
|
* Time Complexity: O(n)
|
|
428
375
|
* Space Complexity: O(1)
|
|
@@ -445,10 +392,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
445
392
|
[this._head, this._tail] = [this.tail, this.head];
|
|
446
393
|
return this;
|
|
447
394
|
}
|
|
448
|
-
/**
|
|
449
|
-
* Time Complexity: O(n)
|
|
450
|
-
* Space Complexity: O(1)
|
|
451
|
-
*/
|
|
452
395
|
/**
|
|
453
396
|
* Time Complexity: O(n)
|
|
454
397
|
* Space Complexity: O(1)
|
|
@@ -470,10 +413,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
470
413
|
}
|
|
471
414
|
return -1;
|
|
472
415
|
}
|
|
473
|
-
/**
|
|
474
|
-
* Time Complexity: O(n)
|
|
475
|
-
* Space Complexity: O(1)
|
|
476
|
-
*/
|
|
477
416
|
/**
|
|
478
417
|
* Time Complexity: O(n)
|
|
479
418
|
* Space Complexity: O(1)
|
|
@@ -494,10 +433,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
494
433
|
}
|
|
495
434
|
return undefined;
|
|
496
435
|
}
|
|
497
|
-
/**
|
|
498
|
-
* Time Complexity: O(n)
|
|
499
|
-
* Space Complexity: O(1)
|
|
500
|
-
*/
|
|
501
436
|
/**
|
|
502
437
|
* Time Complexity: O(n)
|
|
503
438
|
* Space Complexity: O(1)
|
|
@@ -536,10 +471,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
536
471
|
}
|
|
537
472
|
return false;
|
|
538
473
|
}
|
|
539
|
-
/**
|
|
540
|
-
* Time Complexity: O(n)
|
|
541
|
-
* Space Complexity: O(1)
|
|
542
|
-
*/
|
|
543
474
|
/**
|
|
544
475
|
* Time Complexity: O(n)
|
|
545
476
|
* Space Complexity: O(1)
|
|
@@ -571,10 +502,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
571
502
|
}
|
|
572
503
|
return false;
|
|
573
504
|
}
|
|
574
|
-
/**
|
|
575
|
-
* Time Complexity: O(n)
|
|
576
|
-
* Space Complexity: O(1)
|
|
577
|
-
*/
|
|
578
505
|
/**
|
|
579
506
|
* Time Complexity: O(n)
|
|
580
507
|
* Space Complexity: O(1)
|
|
@@ -594,10 +521,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
594
521
|
}
|
|
595
522
|
return count;
|
|
596
523
|
}
|
|
597
|
-
/**
|
|
598
|
-
* Time Complexity: O(n)
|
|
599
|
-
* Space Complexity: O(n)
|
|
600
|
-
*/
|
|
601
524
|
/**
|
|
602
525
|
* Time Complexity: O(n)
|
|
603
526
|
* Space Complexity: O(n)
|
|
@@ -610,10 +533,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
610
533
|
clone() {
|
|
611
534
|
return new SinglyLinkedList(this, { toElementFn: this.toElementFn });
|
|
612
535
|
}
|
|
613
|
-
/**
|
|
614
|
-
* Time Complexity: O(n)
|
|
615
|
-
* Space Complexity: O(n)
|
|
616
|
-
*/
|
|
617
536
|
/**
|
|
618
537
|
* Time Complexity: O(n)
|
|
619
538
|
* Space Complexity: O(n)
|
|
@@ -645,8 +564,7 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
645
564
|
/**
|
|
646
565
|
* Time Complexity: O(n)
|
|
647
566
|
* Space Complexity: O(n)
|
|
648
|
-
|
|
649
|
-
/**
|
|
567
|
+
*
|
|
650
568
|
* The `map` function takes a callback function and returns a new SinglyLinkedList with the results
|
|
651
569
|
* of applying the callback to each element in the original list.
|
|
652
570
|
* @param callback - The `callback` parameter is a function that will be called for each element in
|
|
@@ -46,10 +46,6 @@ export declare class SkipList<K, V> {
|
|
|
46
46
|
* @returns The probability value stored in the protected variable `_probability` is being returned.
|
|
47
47
|
*/
|
|
48
48
|
get probability(): number;
|
|
49
|
-
/**
|
|
50
|
-
* Time Complexity: O(log n)
|
|
51
|
-
* Space Complexity: O(1)
|
|
52
|
-
*/
|
|
53
49
|
/**
|
|
54
50
|
* Time Complexity: O(1)
|
|
55
51
|
* Space Complexity: O(1)
|
|
@@ -58,10 +54,6 @@ export declare class SkipList<K, V> {
|
|
|
58
54
|
* @returns The value of the first element, or undefined if the Skip List is empty.
|
|
59
55
|
*/
|
|
60
56
|
get first(): V | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* Time Complexity: O(log n)
|
|
63
|
-
* Space Complexity: O(1)
|
|
64
|
-
*/
|
|
65
57
|
/**
|
|
66
58
|
* Time Complexity: O(log n)
|
|
67
59
|
* Space Complexity: O(1)
|
|
@@ -70,10 +62,6 @@ export declare class SkipList<K, V> {
|
|
|
70
62
|
* @returns The value of the last element, or undefined if the Skip List is empty.
|
|
71
63
|
*/
|
|
72
64
|
get last(): V | undefined;
|
|
73
|
-
/**
|
|
74
|
-
* Time Complexity: O(log n)
|
|
75
|
-
* Space Complexity: O(1)
|
|
76
|
-
*/
|
|
77
65
|
/**
|
|
78
66
|
* Time Complexity: O(log n)
|
|
79
67
|
* Space Complexity: O(1)
|
|
@@ -84,10 +72,6 @@ export declare class SkipList<K, V> {
|
|
|
84
72
|
* List.
|
|
85
73
|
*/
|
|
86
74
|
add(key: K, value: V): void;
|
|
87
|
-
/**
|
|
88
|
-
* Time Complexity: O(log n)
|
|
89
|
-
* Space Complexity: O(1)
|
|
90
|
-
*/
|
|
91
75
|
/**
|
|
92
76
|
* Time Complexity: O(log n)
|
|
93
77
|
* Space Complexity: O(1)
|
|
@@ -101,18 +85,13 @@ export declare class SkipList<K, V> {
|
|
|
101
85
|
/**
|
|
102
86
|
* Time Complexity: O(log n)
|
|
103
87
|
* Space Complexity: O(1)
|
|
104
|
-
|
|
105
|
-
/**
|
|
88
|
+
*
|
|
106
89
|
* The function checks if a key exists in a data structure.
|
|
107
90
|
* @param {K} key - The parameter "key" is of type K, which represents the type of the key being
|
|
108
91
|
* checked.
|
|
109
92
|
* @returns a boolean value.
|
|
110
93
|
*/
|
|
111
94
|
has(key: K): boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Time Complexity: O(log n)
|
|
114
|
-
* Space Complexity: O(1)
|
|
115
|
-
*/
|
|
116
95
|
/**
|
|
117
96
|
* Time Complexity: O(log n)
|
|
118
97
|
* Space Complexity: O(1)
|
|
@@ -123,10 +102,6 @@ export declare class SkipList<K, V> {
|
|
|
123
102
|
* skip list, and `false` if the key was not found in the skip list.
|
|
124
103
|
*/
|
|
125
104
|
delete(key: K): boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Time Complexity: O(log n)
|
|
128
|
-
* Space Complexity: O(1)
|
|
129
|
-
*/
|
|
130
105
|
/**
|
|
131
106
|
* Time Complexity: O(log n)
|
|
132
107
|
* Space Complexity: O(1)
|
|
@@ -136,10 +111,6 @@ export declare class SkipList<K, V> {
|
|
|
136
111
|
* @returns The value of the first element greater than the given key, or undefined if there is no such element.
|
|
137
112
|
*/
|
|
138
113
|
higher(key: K): V | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* Time Complexity: O(log n)
|
|
141
|
-
* Space Complexity: O(1)
|
|
142
|
-
*/
|
|
143
114
|
/**
|
|
144
115
|
* Time Complexity: O(log n)
|
|
145
116
|
* Space Complexity: O(1)
|
|
@@ -149,11 +120,6 @@ export declare class SkipList<K, V> {
|
|
|
149
120
|
* @returns The value of the last element less than the given key, or undefined if there is no such element.
|
|
150
121
|
*/
|
|
151
122
|
lower(key: K): V | undefined;
|
|
152
|
-
/**
|
|
153
|
-
* Time Complexity: O(maxLevel)
|
|
154
|
-
* Space Complexity: O(1)
|
|
155
|
-
* where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
|
|
156
|
-
*/
|
|
157
123
|
/**
|
|
158
124
|
* Time Complexity: O(maxLevel)
|
|
159
125
|
* Space Complexity: O(1)
|
|
@@ -63,10 +63,6 @@ class SkipList {
|
|
|
63
63
|
get probability() {
|
|
64
64
|
return this._probability;
|
|
65
65
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Time Complexity: O(log n)
|
|
68
|
-
* Space Complexity: O(1)
|
|
69
|
-
*/
|
|
70
66
|
/**
|
|
71
67
|
* Time Complexity: O(1)
|
|
72
68
|
* Space Complexity: O(1)
|
|
@@ -78,10 +74,6 @@ class SkipList {
|
|
|
78
74
|
const firstNode = this.head.forward[0];
|
|
79
75
|
return firstNode ? firstNode.value : undefined;
|
|
80
76
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Time Complexity: O(log n)
|
|
83
|
-
* Space Complexity: O(1)
|
|
84
|
-
*/
|
|
85
77
|
/**
|
|
86
78
|
* Time Complexity: O(log n)
|
|
87
79
|
* Space Complexity: O(1)
|
|
@@ -98,10 +90,6 @@ class SkipList {
|
|
|
98
90
|
}
|
|
99
91
|
return current.value;
|
|
100
92
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Time Complexity: O(log n)
|
|
103
|
-
* Space Complexity: O(1)
|
|
104
|
-
*/
|
|
105
93
|
/**
|
|
106
94
|
* Time Complexity: O(log n)
|
|
107
95
|
* Space Complexity: O(1)
|
|
@@ -129,10 +117,6 @@ class SkipList {
|
|
|
129
117
|
this._level = Math.max(this.level, newNode.forward.length);
|
|
130
118
|
}
|
|
131
119
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Time Complexity: O(log n)
|
|
134
|
-
* Space Complexity: O(1)
|
|
135
|
-
*/
|
|
136
120
|
/**
|
|
137
121
|
* Time Complexity: O(log n)
|
|
138
122
|
* Space Complexity: O(1)
|
|
@@ -158,8 +142,7 @@ class SkipList {
|
|
|
158
142
|
/**
|
|
159
143
|
* Time Complexity: O(log n)
|
|
160
144
|
* Space Complexity: O(1)
|
|
161
|
-
|
|
162
|
-
/**
|
|
145
|
+
*
|
|
163
146
|
* The function checks if a key exists in a data structure.
|
|
164
147
|
* @param {K} key - The parameter "key" is of type K, which represents the type of the key being
|
|
165
148
|
* checked.
|
|
@@ -168,10 +151,6 @@ class SkipList {
|
|
|
168
151
|
has(key) {
|
|
169
152
|
return this.get(key) !== undefined;
|
|
170
153
|
}
|
|
171
|
-
/**
|
|
172
|
-
* Time Complexity: O(log n)
|
|
173
|
-
* Space Complexity: O(1)
|
|
174
|
-
*/
|
|
175
154
|
/**
|
|
176
155
|
* Time Complexity: O(log n)
|
|
177
156
|
* Space Complexity: O(1)
|
|
@@ -205,10 +184,6 @@ class SkipList {
|
|
|
205
184
|
}
|
|
206
185
|
return false;
|
|
207
186
|
}
|
|
208
|
-
/**
|
|
209
|
-
* Time Complexity: O(log n)
|
|
210
|
-
* Space Complexity: O(1)
|
|
211
|
-
*/
|
|
212
187
|
/**
|
|
213
188
|
* Time Complexity: O(log n)
|
|
214
189
|
* Space Complexity: O(1)
|
|
@@ -227,10 +202,6 @@ class SkipList {
|
|
|
227
202
|
const nextNode = current.forward[0];
|
|
228
203
|
return nextNode ? nextNode.value : undefined;
|
|
229
204
|
}
|
|
230
|
-
/**
|
|
231
|
-
* Time Complexity: O(log n)
|
|
232
|
-
* Space Complexity: O(1)
|
|
233
|
-
*/
|
|
234
205
|
/**
|
|
235
206
|
* Time Complexity: O(log n)
|
|
236
207
|
* Space Complexity: O(1)
|
|
@@ -252,11 +223,6 @@ class SkipList {
|
|
|
252
223
|
}
|
|
253
224
|
return lastLess ? lastLess.value : undefined;
|
|
254
225
|
}
|
|
255
|
-
/**
|
|
256
|
-
* Time Complexity: O(maxLevel)
|
|
257
|
-
* Space Complexity: O(1)
|
|
258
|
-
* where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
|
|
259
|
-
*/
|
|
260
226
|
/**
|
|
261
227
|
* Time Complexity: O(maxLevel)
|
|
262
228
|
* Space Complexity: O(1)
|