min-heap-typed 1.52.3 → 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 +29 -115
- 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 +5 -58
- package/dist/data-structures/queue/queue.js +4 -57
- 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 +31 -139
- 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 +5 -72
- 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
|
@@ -96,10 +96,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
96
96
|
* @return The last element in the array
|
|
97
97
|
*/
|
|
98
98
|
get last(): E | undefined;
|
|
99
|
-
/**
|
|
100
|
-
* Time Complexity - Amortized O(1) (possible reallocation)
|
|
101
|
-
* Space Complexity - O(n) (due to potential resizing).
|
|
102
|
-
*/
|
|
103
99
|
/**
|
|
104
100
|
* Time Complexity - Amortized O(1) (possible reallocation),
|
|
105
101
|
* Space Complexity - O(n) (due to potential resizing).
|
|
@@ -110,10 +106,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
110
106
|
* @returns The size of the data structure after the element has been pushed.
|
|
111
107
|
*/
|
|
112
108
|
push(element: E): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Time Complexity: O(1)
|
|
115
|
-
* Space Complexity: O(1)
|
|
116
|
-
*/
|
|
117
109
|
/**
|
|
118
110
|
* Time Complexity: O(1)
|
|
119
111
|
* Space Complexity: O(1)
|
|
@@ -123,10 +115,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
123
115
|
* @returns The element that was removed from the data structure is being returned.
|
|
124
116
|
*/
|
|
125
117
|
pop(): E | undefined;
|
|
126
|
-
/**
|
|
127
|
-
* Time Complexity: Amortized O(1)
|
|
128
|
-
* Space Complexity: O(n)
|
|
129
|
-
*/
|
|
130
118
|
/**
|
|
131
119
|
* Time Complexity: Amortized O(1)
|
|
132
120
|
* Space Complexity: O(n)
|
|
@@ -138,10 +126,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
138
126
|
* @returns The size of the data structure after the element has been added.
|
|
139
127
|
*/
|
|
140
128
|
unshift(element: E): boolean;
|
|
141
|
-
/**
|
|
142
|
-
* Time Complexity: O(1)
|
|
143
|
-
* Space Complexity: O(1)
|
|
144
|
-
*/
|
|
145
129
|
/**
|
|
146
130
|
* Time Complexity: O(1)
|
|
147
131
|
* Space Complexity: O(1)
|
|
@@ -152,10 +136,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
152
136
|
* returned.
|
|
153
137
|
*/
|
|
154
138
|
shift(): E | undefined;
|
|
155
|
-
/**
|
|
156
|
-
* Time Complexity: O(1)
|
|
157
|
-
* Space Complexity: O(1)
|
|
158
|
-
*/
|
|
159
139
|
/**
|
|
160
140
|
* Time Complexity: O(1)
|
|
161
141
|
* Space Complexity: O(1)
|
|
@@ -164,10 +144,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
164
144
|
* @returns A boolean value indicating whether the size of the object is 0 or not.
|
|
165
145
|
*/
|
|
166
146
|
isEmpty(): boolean;
|
|
167
|
-
/**
|
|
168
|
-
* Time Complexity: O(1)
|
|
169
|
-
* Space Complexity: O(1)
|
|
170
|
-
*/
|
|
171
147
|
/**
|
|
172
148
|
* Time Complexity: O(1)
|
|
173
149
|
* Space Complexity: O(1)
|
|
@@ -185,10 +161,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
185
161
|
* the last element.
|
|
186
162
|
*/
|
|
187
163
|
reverseBegin(): Generator<E>;
|
|
188
|
-
/**
|
|
189
|
-
* Time Complexity: O(1)
|
|
190
|
-
* Space Complexity: O(1)
|
|
191
|
-
*/
|
|
192
164
|
/**
|
|
193
165
|
* Time Complexity: O(1)
|
|
194
166
|
* Space Complexity: O(1)
|
|
@@ -200,10 +172,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
200
172
|
* @returns The element at the specified position in the data structure is being returned.
|
|
201
173
|
*/
|
|
202
174
|
at(pos: number): E;
|
|
203
|
-
/**
|
|
204
|
-
* Time Complexity: O(1)
|
|
205
|
-
* Space Complexity: O(1)
|
|
206
|
-
*/
|
|
207
175
|
/**
|
|
208
176
|
* Time Complexity: O(1)
|
|
209
177
|
* Space Complexity: O(1)
|
|
@@ -215,10 +183,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
215
183
|
* position in the data structure.
|
|
216
184
|
*/
|
|
217
185
|
setAt(pos: number, element: E): boolean;
|
|
218
|
-
/**
|
|
219
|
-
* Time Complexity: O(n)
|
|
220
|
-
* Space Complexity: O(n)
|
|
221
|
-
*/
|
|
222
186
|
/**
|
|
223
187
|
* Time Complexity: O(n)
|
|
224
188
|
* Space Complexity: O(n)
|
|
@@ -235,10 +199,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
235
199
|
* @returns The size of the array after the insertion is being returned.
|
|
236
200
|
*/
|
|
237
201
|
addAt(pos: number, element: E, num?: number): boolean;
|
|
238
|
-
/**
|
|
239
|
-
* Time Complexity: O(1)
|
|
240
|
-
* Space Complexity: O(1)
|
|
241
|
-
*/
|
|
242
202
|
/**
|
|
243
203
|
* Time Complexity: O(1)
|
|
244
204
|
* Space Complexity: O(1)
|
|
@@ -251,10 +211,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
251
211
|
* @returns The method is returning the updated size of the data structure.
|
|
252
212
|
*/
|
|
253
213
|
cut(pos: number, isCutSelf?: boolean): Deque<E>;
|
|
254
|
-
/**
|
|
255
|
-
* Time Complexity: O(1)
|
|
256
|
-
* Space Complexity: O(1) or O(n)
|
|
257
|
-
*/
|
|
258
214
|
/**
|
|
259
215
|
* Time Complexity: O(1)
|
|
260
216
|
* Space Complexity: O(1) or O(n)
|
|
@@ -271,10 +227,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
271
227
|
* (`newDeque`) depending on the value of the `isCutSelf` parameter.
|
|
272
228
|
*/
|
|
273
229
|
cutRest(pos: number, isCutSelf?: boolean): Deque<E>;
|
|
274
|
-
/**
|
|
275
|
-
* Time Complexity: O(n)
|
|
276
|
-
* Space Complexity: O(1) or O(n)
|
|
277
|
-
*/
|
|
278
230
|
/**
|
|
279
231
|
* Time Complexity: O(n)
|
|
280
232
|
* Space Complexity: O(1) or O(n)
|
|
@@ -287,10 +239,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
287
239
|
* @returns The size of the data structure after the deletion operation is performed.
|
|
288
240
|
*/
|
|
289
241
|
deleteAt(pos: number): boolean;
|
|
290
|
-
/**
|
|
291
|
-
* Time Complexity: O(n)
|
|
292
|
-
* Space Complexity: O(1)
|
|
293
|
-
*/
|
|
294
242
|
/**
|
|
295
243
|
* Time Complexity: O(n)
|
|
296
244
|
* Space Complexity: O(1)
|
|
@@ -302,10 +250,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
302
250
|
* @returns The size of the data structure after the element has been deleted.
|
|
303
251
|
*/
|
|
304
252
|
delete(element: E): boolean;
|
|
305
|
-
/**
|
|
306
|
-
* Time Complexity: O(n)
|
|
307
|
-
* Space Complexity: O(1)
|
|
308
|
-
*/
|
|
309
253
|
/**
|
|
310
254
|
* Time Complexity: O(n)
|
|
311
255
|
* Space Complexity: O(1)
|
|
@@ -316,10 +260,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
316
260
|
* operation on the buckets and updating the relevant properties.
|
|
317
261
|
*/
|
|
318
262
|
reverse(): this;
|
|
319
|
-
/**
|
|
320
|
-
* Time Complexity: O(n)
|
|
321
|
-
* Space Complexity: O(1)
|
|
322
|
-
*/
|
|
323
263
|
/**
|
|
324
264
|
* Time Complexity: O(n)
|
|
325
265
|
* Space Complexity: O(1)
|
|
@@ -329,10 +269,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
329
269
|
* @returns The size of the modified array is being returned.
|
|
330
270
|
*/
|
|
331
271
|
unique(): this;
|
|
332
|
-
/**
|
|
333
|
-
* Time Complexity: O(n log n)
|
|
334
|
-
* Space Complexity: O(n)
|
|
335
|
-
*/
|
|
336
272
|
/**
|
|
337
273
|
* Time Complexity: O(n log n)
|
|
338
274
|
* Space Complexity: O(n)
|
|
@@ -344,10 +280,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
344
280
|
* @returns Deque<E>
|
|
345
281
|
*/
|
|
346
282
|
sort(comparator?: (x: E, y: E) => number): this;
|
|
347
|
-
/**
|
|
348
|
-
* Time Complexity: O(n)
|
|
349
|
-
* Space Complexity: O(n)
|
|
350
|
-
*/
|
|
351
283
|
/**
|
|
352
284
|
* Time Complexity: O(n)
|
|
353
285
|
* Space Complexity: O(n)
|
|
@@ -358,10 +290,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
358
290
|
* `this.size` is 0, but it does not return any value.
|
|
359
291
|
*/
|
|
360
292
|
shrinkToFit(): void;
|
|
361
|
-
/**
|
|
362
|
-
* Time Complexity: O(n)
|
|
363
|
-
* Space Complexity: O(1)
|
|
364
|
-
*/
|
|
365
293
|
/**
|
|
366
294
|
* Time Complexity: O(n)
|
|
367
295
|
* Space Complexity: O(1)
|
|
@@ -374,10 +302,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
374
302
|
* in the data structure. If the element is not found, it returns -1.
|
|
375
303
|
*/
|
|
376
304
|
indexOf(element: E): number;
|
|
377
|
-
/**
|
|
378
|
-
* Time Complexity: O(n)
|
|
379
|
-
* Space Complexity: O(n)
|
|
380
|
-
*/
|
|
381
305
|
/**
|
|
382
306
|
* Time Complexity: O(n)
|
|
383
307
|
* Space Complexity: O(n)
|
|
@@ -386,10 +310,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
386
310
|
* @returns The `toArray()` method is returning an array of elements of type `E`.
|
|
387
311
|
*/
|
|
388
312
|
toArray(): E[];
|
|
389
|
-
/**
|
|
390
|
-
* Time Complexity: O(n)
|
|
391
|
-
* Space Complexity: O(n)
|
|
392
|
-
*/
|
|
393
313
|
/**
|
|
394
314
|
* Time Complexity: O(n)
|
|
395
315
|
* Space Complexity: O(n)
|
|
@@ -400,10 +320,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
400
320
|
* elements as the original deque (`this`) and the same bucket size.
|
|
401
321
|
*/
|
|
402
322
|
clone(): Deque<E, R>;
|
|
403
|
-
/**
|
|
404
|
-
* Time Complexity: O(n)
|
|
405
|
-
* Space Complexity: O(n)
|
|
406
|
-
*/
|
|
407
323
|
/**
|
|
408
324
|
* Time Complexity: O(n)
|
|
409
325
|
* Space Complexity: O(n)
|
|
@@ -424,8 +340,7 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
424
340
|
/**
|
|
425
341
|
* Time Complexity: O(n)
|
|
426
342
|
* Space Complexity: O(n)
|
|
427
|
-
|
|
428
|
-
/**
|
|
343
|
+
*
|
|
429
344
|
* The `map` function takes a callback function and applies it to each element in the deque,
|
|
430
345
|
* returning a new deque with the results.
|
|
431
346
|
* @param callback - The callback parameter is a function that will be called for each element in the
|
|
@@ -441,10 +356,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
441
356
|
* @returns a new Deque object with elements of type EM and raw elements of type RM.
|
|
442
357
|
*/
|
|
443
358
|
map<EM, RM>(callback: ElementCallback<E, R, EM, Deque<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): Deque<EM, RM>;
|
|
444
|
-
/**
|
|
445
|
-
* Time Complexity: O(n)
|
|
446
|
-
* Space Complexity: O(1)
|
|
447
|
-
*/
|
|
448
359
|
/**
|
|
449
360
|
* Time Complexity: O(n)
|
|
450
361
|
* Space Complexity: O(1)
|
|
@@ -453,10 +364,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
453
364
|
* object to be iterated over using a for...of loop.
|
|
454
365
|
*/
|
|
455
366
|
protected _getIterator(): IterableIterator<E>;
|
|
456
|
-
/**
|
|
457
|
-
* Time Complexity: O(n)
|
|
458
|
-
* Space Complexity: O(n)
|
|
459
|
-
*/
|
|
460
367
|
/**
|
|
461
368
|
* Time Complexity: O(n)
|
|
462
369
|
* Space Complexity: O(n)
|
|
@@ -467,10 +374,6 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
467
374
|
* current bucket count (`this._bucketCount >> 1`) or 1 if the current bucket count is less than 2.
|
|
468
375
|
*/
|
|
469
376
|
protected _reallocate(needBucketNum?: number): void;
|
|
470
|
-
/**
|
|
471
|
-
* Time Complexity: O(1)
|
|
472
|
-
* Space Complexity: O(1)
|
|
473
|
-
*/
|
|
474
377
|
/**
|
|
475
378
|
* Time Complexity: O(1)
|
|
476
379
|
* Space Complexity: O(1)
|
|
@@ -155,10 +155,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
155
155
|
return;
|
|
156
156
|
return this._buckets[this._bucketLast][this._lastInBucket];
|
|
157
157
|
}
|
|
158
|
-
/**
|
|
159
|
-
* Time Complexity - Amortized O(1) (possible reallocation)
|
|
160
|
-
* Space Complexity - O(n) (due to potential resizing).
|
|
161
|
-
*/
|
|
162
158
|
/**
|
|
163
159
|
* Time Complexity - Amortized O(1) (possible reallocation),
|
|
164
160
|
* Space Complexity - O(n) (due to potential resizing).
|
|
@@ -190,10 +186,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
190
186
|
this.shift();
|
|
191
187
|
return true;
|
|
192
188
|
}
|
|
193
|
-
/**
|
|
194
|
-
* Time Complexity: O(1)
|
|
195
|
-
* Space Complexity: O(1)
|
|
196
|
-
*/
|
|
197
189
|
/**
|
|
198
190
|
* Time Complexity: O(1)
|
|
199
191
|
* Space Complexity: O(1)
|
|
@@ -222,10 +214,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
222
214
|
this._size -= 1;
|
|
223
215
|
return element;
|
|
224
216
|
}
|
|
225
|
-
/**
|
|
226
|
-
* Time Complexity: Amortized O(1)
|
|
227
|
-
* Space Complexity: O(n)
|
|
228
|
-
*/
|
|
229
217
|
/**
|
|
230
218
|
* Time Complexity: Amortized O(1)
|
|
231
219
|
* Space Complexity: O(n)
|
|
@@ -258,10 +246,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
258
246
|
this.pop();
|
|
259
247
|
return true;
|
|
260
248
|
}
|
|
261
|
-
/**
|
|
262
|
-
* Time Complexity: O(1)
|
|
263
|
-
* Space Complexity: O(1)
|
|
264
|
-
*/
|
|
265
249
|
/**
|
|
266
250
|
* Time Complexity: O(1)
|
|
267
251
|
* Space Complexity: O(1)
|
|
@@ -291,10 +275,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
291
275
|
this._size -= 1;
|
|
292
276
|
return element;
|
|
293
277
|
}
|
|
294
|
-
/**
|
|
295
|
-
* Time Complexity: O(1)
|
|
296
|
-
* Space Complexity: O(1)
|
|
297
|
-
*/
|
|
298
278
|
/**
|
|
299
279
|
* Time Complexity: O(1)
|
|
300
280
|
* Space Complexity: O(1)
|
|
@@ -305,10 +285,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
305
285
|
isEmpty() {
|
|
306
286
|
return this.size === 0;
|
|
307
287
|
}
|
|
308
|
-
/**
|
|
309
|
-
* Time Complexity: O(1)
|
|
310
|
-
* Space Complexity: O(1)
|
|
311
|
-
*/
|
|
312
288
|
/**
|
|
313
289
|
* Time Complexity: O(1)
|
|
314
290
|
* Space Complexity: O(1)
|
|
@@ -343,10 +319,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
343
319
|
index--;
|
|
344
320
|
}
|
|
345
321
|
}
|
|
346
|
-
/**
|
|
347
|
-
* Time Complexity: O(1)
|
|
348
|
-
* Space Complexity: O(1)
|
|
349
|
-
*/
|
|
350
322
|
/**
|
|
351
323
|
* Time Complexity: O(1)
|
|
352
324
|
* Space Complexity: O(1)
|
|
@@ -362,10 +334,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
362
334
|
const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
|
|
363
335
|
return this._buckets[bucketIndex][indexInBucket];
|
|
364
336
|
}
|
|
365
|
-
/**
|
|
366
|
-
* Time Complexity: O(1)
|
|
367
|
-
* Space Complexity: O(1)
|
|
368
|
-
*/
|
|
369
337
|
/**
|
|
370
338
|
* Time Complexity: O(1)
|
|
371
339
|
* Space Complexity: O(1)
|
|
@@ -382,10 +350,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
382
350
|
this._buckets[bucketIndex][indexInBucket] = element;
|
|
383
351
|
return true;
|
|
384
352
|
}
|
|
385
|
-
/**
|
|
386
|
-
* Time Complexity: O(n)
|
|
387
|
-
* Space Complexity: O(n)
|
|
388
|
-
*/
|
|
389
353
|
/**
|
|
390
354
|
* Time Complexity: O(n)
|
|
391
355
|
* Space Complexity: O(n)
|
|
@@ -425,10 +389,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
425
389
|
}
|
|
426
390
|
return true;
|
|
427
391
|
}
|
|
428
|
-
/**
|
|
429
|
-
* Time Complexity: O(1)
|
|
430
|
-
* Space Complexity: O(1)
|
|
431
|
-
*/
|
|
432
392
|
/**
|
|
433
393
|
* Time Complexity: O(1)
|
|
434
394
|
* Space Complexity: O(1)
|
|
@@ -460,10 +420,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
460
420
|
return newDeque;
|
|
461
421
|
}
|
|
462
422
|
}
|
|
463
|
-
/**
|
|
464
|
-
* Time Complexity: O(1)
|
|
465
|
-
* Space Complexity: O(1) or O(n)
|
|
466
|
-
*/
|
|
467
423
|
/**
|
|
468
424
|
* Time Complexity: O(1)
|
|
469
425
|
* Space Complexity: O(1) or O(n)
|
|
@@ -482,7 +438,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
482
438
|
cutRest(pos, isCutSelf = false) {
|
|
483
439
|
if (isCutSelf) {
|
|
484
440
|
if (pos < 0) {
|
|
485
|
-
this.clear();
|
|
486
441
|
return this;
|
|
487
442
|
}
|
|
488
443
|
const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
|
|
@@ -493,16 +448,14 @@ class Deque extends base_1.IterableElementBase {
|
|
|
493
448
|
}
|
|
494
449
|
else {
|
|
495
450
|
const newDeque = new Deque([], { bucketSize: this._bucketSize });
|
|
451
|
+
if (pos < 0)
|
|
452
|
+
pos = 0;
|
|
496
453
|
for (let i = pos; i < this.size; i++) {
|
|
497
454
|
newDeque.push(this.at(i));
|
|
498
455
|
}
|
|
499
456
|
return newDeque;
|
|
500
457
|
}
|
|
501
458
|
}
|
|
502
|
-
/**
|
|
503
|
-
* Time Complexity: O(n)
|
|
504
|
-
* Space Complexity: O(1) or O(n)
|
|
505
|
-
*/
|
|
506
459
|
/**
|
|
507
460
|
* Time Complexity: O(n)
|
|
508
461
|
* Space Complexity: O(1) or O(n)
|
|
@@ -533,10 +486,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
533
486
|
}
|
|
534
487
|
return true;
|
|
535
488
|
}
|
|
536
|
-
/**
|
|
537
|
-
* Time Complexity: O(n)
|
|
538
|
-
* Space Complexity: O(1)
|
|
539
|
-
*/
|
|
540
489
|
/**
|
|
541
490
|
* Time Complexity: O(n)
|
|
542
491
|
* Space Complexity: O(1)
|
|
@@ -564,10 +513,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
564
513
|
this.cut(index - 1, true);
|
|
565
514
|
return true;
|
|
566
515
|
}
|
|
567
|
-
/**
|
|
568
|
-
* Time Complexity: O(n)
|
|
569
|
-
* Space Complexity: O(1)
|
|
570
|
-
*/
|
|
571
516
|
/**
|
|
572
517
|
* Time Complexity: O(n)
|
|
573
518
|
* Space Complexity: O(1)
|
|
@@ -588,10 +533,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
588
533
|
this._lastInBucket = this._bucketSize - _firstInBucket - 1;
|
|
589
534
|
return this;
|
|
590
535
|
}
|
|
591
|
-
/**
|
|
592
|
-
* Time Complexity: O(n)
|
|
593
|
-
* Space Complexity: O(1)
|
|
594
|
-
*/
|
|
595
536
|
/**
|
|
596
537
|
* Time Complexity: O(n)
|
|
597
538
|
* Space Complexity: O(1)
|
|
@@ -616,10 +557,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
616
557
|
this.cut(index - 1, true);
|
|
617
558
|
return this;
|
|
618
559
|
}
|
|
619
|
-
/**
|
|
620
|
-
* Time Complexity: O(n log n)
|
|
621
|
-
* Space Complexity: O(n)
|
|
622
|
-
*/
|
|
623
560
|
/**
|
|
624
561
|
* Time Complexity: O(n log n)
|
|
625
562
|
* Space Complexity: O(n)
|
|
@@ -641,10 +578,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
641
578
|
}
|
|
642
579
|
return this;
|
|
643
580
|
}
|
|
644
|
-
/**
|
|
645
|
-
* Time Complexity: O(n)
|
|
646
|
-
* Space Complexity: O(n)
|
|
647
|
-
*/
|
|
648
581
|
/**
|
|
649
582
|
* Time Complexity: O(n)
|
|
650
583
|
* Space Complexity: O(n)
|
|
@@ -677,10 +610,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
677
610
|
this._bucketLast = newBuckets.length - 1;
|
|
678
611
|
this._buckets = newBuckets;
|
|
679
612
|
}
|
|
680
|
-
/**
|
|
681
|
-
* Time Complexity: O(n)
|
|
682
|
-
* Space Complexity: O(1)
|
|
683
|
-
*/
|
|
684
613
|
/**
|
|
685
614
|
* Time Complexity: O(n)
|
|
686
615
|
* Space Complexity: O(1)
|
|
@@ -700,10 +629,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
700
629
|
}
|
|
701
630
|
return -1;
|
|
702
631
|
}
|
|
703
|
-
/**
|
|
704
|
-
* Time Complexity: O(n)
|
|
705
|
-
* Space Complexity: O(n)
|
|
706
|
-
*/
|
|
707
632
|
/**
|
|
708
633
|
* Time Complexity: O(n)
|
|
709
634
|
* Space Complexity: O(n)
|
|
@@ -714,10 +639,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
714
639
|
toArray() {
|
|
715
640
|
return [...this];
|
|
716
641
|
}
|
|
717
|
-
/**
|
|
718
|
-
* Time Complexity: O(n)
|
|
719
|
-
* Space Complexity: O(n)
|
|
720
|
-
*/
|
|
721
642
|
/**
|
|
722
643
|
* Time Complexity: O(n)
|
|
723
644
|
* Space Complexity: O(n)
|
|
@@ -730,10 +651,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
730
651
|
clone() {
|
|
731
652
|
return new Deque(this, { bucketSize: this.bucketSize, toElementFn: this.toElementFn });
|
|
732
653
|
}
|
|
733
|
-
/**
|
|
734
|
-
* Time Complexity: O(n)
|
|
735
|
-
* Space Complexity: O(n)
|
|
736
|
-
*/
|
|
737
654
|
/**
|
|
738
655
|
* Time Complexity: O(n)
|
|
739
656
|
* Space Complexity: O(n)
|
|
@@ -764,8 +681,7 @@ class Deque extends base_1.IterableElementBase {
|
|
|
764
681
|
/**
|
|
765
682
|
* Time Complexity: O(n)
|
|
766
683
|
* Space Complexity: O(n)
|
|
767
|
-
|
|
768
|
-
/**
|
|
684
|
+
*
|
|
769
685
|
* The `map` function takes a callback function and applies it to each element in the deque,
|
|
770
686
|
* returning a new deque with the results.
|
|
771
687
|
* @param callback - The callback parameter is a function that will be called for each element in the
|
|
@@ -789,10 +705,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
789
705
|
}
|
|
790
706
|
return newDeque;
|
|
791
707
|
}
|
|
792
|
-
/**
|
|
793
|
-
* Time Complexity: O(n)
|
|
794
|
-
* Space Complexity: O(1)
|
|
795
|
-
*/
|
|
796
708
|
/**
|
|
797
709
|
* Time Complexity: O(n)
|
|
798
710
|
* Space Complexity: O(1)
|
|
@@ -805,10 +717,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
805
717
|
yield this.at(i);
|
|
806
718
|
}
|
|
807
719
|
}
|
|
808
|
-
/**
|
|
809
|
-
* Time Complexity: O(n)
|
|
810
|
-
* Space Complexity: O(n)
|
|
811
|
-
*/
|
|
812
720
|
/**
|
|
813
721
|
* Time Complexity: O(n)
|
|
814
722
|
* Space Complexity: O(n)
|
|
@@ -839,10 +747,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
839
747
|
this._buckets = newBuckets;
|
|
840
748
|
this._bucketCount = newBuckets.length;
|
|
841
749
|
}
|
|
842
|
-
/**
|
|
843
|
-
* Time Complexity: O(1)
|
|
844
|
-
* Space Complexity: O(1)
|
|
845
|
-
*/
|
|
846
750
|
/**
|
|
847
751
|
* Time Complexity: O(1)
|
|
848
752
|
* Space Complexity: O(1)
|
|
@@ -34,10 +34,6 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
34
34
|
* @returns {number} The size of the array, which is the difference between the length of the array and the offset.
|
|
35
35
|
*/
|
|
36
36
|
get size(): number;
|
|
37
|
-
/**
|
|
38
|
-
* Time Complexity: O(1)
|
|
39
|
-
* Space Complexity: O(1)
|
|
40
|
-
*/
|
|
41
37
|
/**
|
|
42
38
|
* Time Complexity: O(1)
|
|
43
39
|
* Space Complexity: O(1)
|
|
@@ -47,10 +43,6 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
47
43
|
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
|
|
48
44
|
*/
|
|
49
45
|
get first(): E | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Time Complexity: O(1)
|
|
52
|
-
* Space Complexity: O(1)
|
|
53
|
-
*/
|
|
54
46
|
/**
|
|
55
47
|
* Time Complexity: O(1)
|
|
56
48
|
* Space Complexity: O(1)
|
|
@@ -60,7 +52,7 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
60
52
|
* array is empty, it returns `undefined`.
|
|
61
53
|
*/
|
|
62
54
|
get last(): E | undefined;
|
|
63
|
-
_autoCompactRatio: number;
|
|
55
|
+
protected _autoCompactRatio: number;
|
|
64
56
|
/**
|
|
65
57
|
* This function returns the value of the autoCompactRatio property.
|
|
66
58
|
* @returns The `autoCompactRatio` property of the object, which is a number.
|
|
@@ -72,10 +64,6 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
72
64
|
* `_autoCompactRatio` property.
|
|
73
65
|
*/
|
|
74
66
|
set autoCompactRatio(v: number);
|
|
75
|
-
/**
|
|
76
|
-
* Time Complexity: O(n)
|
|
77
|
-
* Space Complexity: O(n)
|
|
78
|
-
*/
|
|
79
67
|
/**
|
|
80
68
|
* Time Complexity: O(n)
|
|
81
69
|
* Space Complexity: O(n)
|
|
@@ -87,23 +75,15 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
87
75
|
* array.
|
|
88
76
|
*/
|
|
89
77
|
static fromArray<E>(elements: E[]): Queue<E>;
|
|
90
|
-
/**
|
|
91
|
-
* Time Complexity: O(1)
|
|
92
|
-
* Space Complexity: O(1)
|
|
93
|
-
*/
|
|
94
78
|
/**
|
|
95
79
|
* Time Complexity: O(1)
|
|
96
80
|
* Space Complexity: O(1)
|
|
97
81
|
*
|
|
98
|
-
* The push function adds an element to the end of the queue and returns
|
|
82
|
+
* The push function adds an element to the end of the queue and returns true. Adds an element at the back of the queue.
|
|
99
83
|
* @param {E} element - The `element` parameter represents the element that you want to add to the queue.
|
|
100
|
-
* @returns
|
|
84
|
+
* @returns Always returns true, indicating the element was successfully added.
|
|
101
85
|
*/
|
|
102
86
|
push(element: E): boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Time Complexity: O(1)
|
|
105
|
-
* Space Complexity: O(1)
|
|
106
|
-
*/
|
|
107
87
|
/**
|
|
108
88
|
* Time Complexity: O(1)
|
|
109
89
|
* Space Complexity: O(1)
|
|
@@ -115,20 +95,16 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
115
95
|
shift(): E | undefined;
|
|
116
96
|
/**
|
|
117
97
|
* The delete function removes an element from the list.
|
|
118
|
-
* @param element
|
|
98
|
+
* @param {E} element - Specify the element to be deleted
|
|
119
99
|
* @return A boolean value indicating whether the element was successfully deleted or not
|
|
120
100
|
*/
|
|
121
101
|
delete(element: E): boolean;
|
|
122
102
|
/**
|
|
123
103
|
* The deleteAt function deletes the element at a given index.
|
|
124
|
-
* @param index
|
|
104
|
+
* @param {number} index - Determine the index of the element to be deleted
|
|
125
105
|
* @return A boolean value
|
|
126
106
|
*/
|
|
127
107
|
deleteAt(index: number): boolean;
|
|
128
|
-
/**
|
|
129
|
-
* Time Complexity: O(1)
|
|
130
|
-
* Space Complexity: O(1)
|
|
131
|
-
*/
|
|
132
108
|
/**
|
|
133
109
|
* Time Complexity: O(1)
|
|
134
110
|
* Space Complexity: O(1)
|
|
@@ -136,10 +112,6 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
136
112
|
* @param index
|
|
137
113
|
*/
|
|
138
114
|
at(index: number): E | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* Time Complexity: O(1)
|
|
141
|
-
* Space Complexity: O(1)
|
|
142
|
-
*/
|
|
143
115
|
/**
|
|
144
116
|
* Time Complexity: O(1)
|
|
145
117
|
* Space Complexity: O(1)
|
|
@@ -148,10 +120,6 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
148
120
|
* @returns {boolean} A boolean value indicating whether the size of the object is 0 or not.
|
|
149
121
|
*/
|
|
150
122
|
isEmpty(): boolean;
|
|
151
|
-
/**
|
|
152
|
-
* Time Complexity: O(1)
|
|
153
|
-
* Space Complexity: O(n)
|
|
154
|
-
*/
|
|
155
123
|
/**
|
|
156
124
|
* Time Complexity: O(1)
|
|
157
125
|
* Space Complexity: O(n)
|
|
@@ -160,10 +128,6 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
160
128
|
* @returns An array of type E is being returned.
|
|
161
129
|
*/
|
|
162
130
|
toArray(): E[];
|
|
163
|
-
/**
|
|
164
|
-
* Time Complexity: O(1)
|
|
165
|
-
* Space Complexity: O(1)
|
|
166
|
-
*/
|
|
167
131
|
/**
|
|
168
132
|
* Time Complexity: O(1)
|
|
169
133
|
* Space Complexity: O(1)
|
|
@@ -177,11 +141,6 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
177
141
|
* @returns The `compact()` method is returning a boolean value of `true`.
|
|
178
142
|
*/
|
|
179
143
|
compact(): boolean;
|
|
180
|
-
/**
|
|
181
|
-
* Time Complexity: O(n)
|
|
182
|
-
* Space Complexity: O(n)
|
|
183
|
-
* where n is the number of elements in the queue. It creates a shallow copy of the internal array. the space required is proportional to the number of elements in the queue.
|
|
184
|
-
*/
|
|
185
144
|
/**
|
|
186
145
|
* Time Complexity: O(n)
|
|
187
146
|
* Space Complexity: O(n)
|
|
@@ -190,10 +149,6 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
190
149
|
* @returns The `clone()` method is returning a new instance of the `Queue` class.
|
|
191
150
|
*/
|
|
192
151
|
clone(): Queue<E, R>;
|
|
193
|
-
/**
|
|
194
|
-
* Time Complexity: O(n)
|
|
195
|
-
* Space Complexity: O(n)
|
|
196
|
-
*/
|
|
197
152
|
/**
|
|
198
153
|
* Time Complexity: O(n)
|
|
199
154
|
* Space Complexity: O(n)
|
|
@@ -216,10 +171,6 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
216
171
|
* Space Complexity: O(n)
|
|
217
172
|
*/
|
|
218
173
|
map<EM, RM>(callback: ElementCallback<E, R, EM, Queue<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): Queue<EM, RM>;
|
|
219
|
-
/**
|
|
220
|
-
* Time Complexity: O(n)
|
|
221
|
-
* Space Complexity: O(n)
|
|
222
|
-
*/
|
|
223
174
|
/**
|
|
224
175
|
* Time Complexity: O(n)
|
|
225
176
|
* Space Complexity: O(n)
|
|
@@ -235,10 +186,6 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
235
186
|
* 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
|
|
236
187
|
*/
|
|
237
188
|
export declare class LinkedListQueue<E = any, R = any> extends SinglyLinkedList<E, R> {
|
|
238
|
-
/**
|
|
239
|
-
* Time Complexity: O(n)
|
|
240
|
-
* Space Complexity: O(n)
|
|
241
|
-
*/
|
|
242
189
|
/**
|
|
243
190
|
* Time Complexity: O(n)
|
|
244
191
|
* Space Complexity: O(n)
|