binary-tree-typed 2.4.5 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -84
- package/dist/cjs/index.cjs +867 -404
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +864 -401
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +867 -404
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +864 -401
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +128 -51
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +210 -164
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +429 -78
- package/dist/types/data-structures/binary-tree/bst.d.ts +311 -28
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +212 -32
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +218 -152
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1281 -5
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1087 -201
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +858 -65
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1133 -5
- package/dist/types/data-structures/graph/directed-graph.d.ts +219 -47
- package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
- package/dist/types/data-structures/graph/undirected-graph.d.ts +204 -59
- package/dist/types/data-structures/hash/hash-map.d.ts +230 -77
- package/dist/types/data-structures/heap/heap.d.ts +287 -99
- package/dist/types/data-structures/heap/max-heap.d.ts +46 -0
- package/dist/types/data-structures/heap/min-heap.d.ts +59 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +286 -44
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +278 -65
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +415 -12
- package/dist/types/data-structures/matrix/matrix.d.ts +331 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +57 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +60 -0
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +60 -0
- package/dist/types/data-structures/queue/deque.d.ts +272 -65
- package/dist/types/data-structures/queue/queue.d.ts +211 -42
- package/dist/types/data-structures/stack/stack.d.ts +174 -32
- package/dist/types/data-structures/trie/trie.d.ts +213 -43
- package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
- package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
- package/dist/umd/binary-tree-typed.js +860 -397
- package/dist/umd/binary-tree-typed.js.map +1 -1
- package/dist/umd/binary-tree-typed.min.js +2 -2
- package/dist/umd/binary-tree-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +4 -5
- package/src/data-structures/binary-tree/avl-tree.ts +134 -51
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +302 -247
- package/src/data-structures/binary-tree/binary-tree.ts +429 -79
- package/src/data-structures/binary-tree/bst.ts +335 -34
- package/src/data-structures/binary-tree/red-black-tree.ts +290 -97
- package/src/data-structures/binary-tree/segment-tree.ts +372 -248
- package/src/data-structures/binary-tree/tree-map.ts +1284 -6
- package/src/data-structures/binary-tree/tree-multi-map.ts +1094 -211
- package/src/data-structures/binary-tree/tree-multi-set.ts +858 -65
- package/src/data-structures/binary-tree/tree-set.ts +1136 -9
- package/src/data-structures/graph/directed-graph.ts +219 -47
- package/src/data-structures/graph/map-graph.ts +59 -1
- package/src/data-structures/graph/undirected-graph.ts +204 -59
- package/src/data-structures/hash/hash-map.ts +230 -77
- package/src/data-structures/heap/heap.ts +287 -99
- package/src/data-structures/heap/max-heap.ts +46 -0
- package/src/data-structures/heap/min-heap.ts +59 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +286 -44
- package/src/data-structures/linked-list/singly-linked-list.ts +278 -65
- package/src/data-structures/linked-list/skip-linked-list.ts +689 -90
- package/src/data-structures/matrix/matrix.ts +416 -12
- package/src/data-structures/priority-queue/max-priority-queue.ts +57 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +60 -0
- package/src/data-structures/priority-queue/priority-queue.ts +60 -0
- package/src/data-structures/queue/deque.ts +272 -65
- package/src/data-structures/queue/queue.ts +211 -42
- package/src/data-structures/stack/stack.ts +174 -32
- package/src/data-structures/trie/trie.ts +213 -43
- package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
- package/src/types/data-structures/linked-list/skip-linked-list.ts +2 -1
|
@@ -18,71 +18,6 @@ import { LinearBase } from '../base/linear-base';
|
|
|
18
18
|
* 4. Efficiency: Adding and removing elements at both ends of a deque is usually very fast. However, when the dynamic array needs to expand, it may involve copying the entire array to a larger one, and this operation has a time complexity of O(n).
|
|
19
19
|
* 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
|
|
20
20
|
* @example
|
|
21
|
-
* // basic Deque creation and push/pop operations
|
|
22
|
-
* // Create a simple Deque with initial values
|
|
23
|
-
* const deque = new Deque([1, 2, 3, 4, 5]);
|
|
24
|
-
*
|
|
25
|
-
* // Verify the deque maintains insertion order
|
|
26
|
-
* console.log([...deque]); // [1, 2, 3, 4, 5];
|
|
27
|
-
*
|
|
28
|
-
* // Check length
|
|
29
|
-
* console.log(deque.length); // 5;
|
|
30
|
-
*
|
|
31
|
-
* // Push to the end
|
|
32
|
-
* deque.push(6);
|
|
33
|
-
* console.log(deque.length); // 6;
|
|
34
|
-
*
|
|
35
|
-
* // Pop from the end
|
|
36
|
-
* const last = deque.pop();
|
|
37
|
-
* console.log(last); // 6;
|
|
38
|
-
* @example
|
|
39
|
-
* // Deque shift and unshift operations
|
|
40
|
-
* const deque = new Deque<number>([20, 30, 40]);
|
|
41
|
-
*
|
|
42
|
-
* // Unshift adds to the front
|
|
43
|
-
* deque.unshift(10);
|
|
44
|
-
* console.log([...deque]); // [10, 20, 30, 40];
|
|
45
|
-
*
|
|
46
|
-
* // Shift removes from the front (O(1) complexity!)
|
|
47
|
-
* const first = deque.shift();
|
|
48
|
-
* console.log(first); // 10;
|
|
49
|
-
*
|
|
50
|
-
* // Verify remaining elements
|
|
51
|
-
* console.log([...deque]); // [20, 30, 40];
|
|
52
|
-
* console.log(deque.length); // 3;
|
|
53
|
-
* @example
|
|
54
|
-
* // Deque peek at both ends
|
|
55
|
-
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
56
|
-
*
|
|
57
|
-
* // Get first element without removing
|
|
58
|
-
* const first = deque.at(0);
|
|
59
|
-
* console.log(first); // 10;
|
|
60
|
-
*
|
|
61
|
-
* // Get last element without removing
|
|
62
|
-
* const last = deque.at(deque.length - 1);
|
|
63
|
-
* console.log(last); // 50;
|
|
64
|
-
*
|
|
65
|
-
* // Length unchanged
|
|
66
|
-
* console.log(deque.length); // 5;
|
|
67
|
-
* @example
|
|
68
|
-
* // Deque for...of iteration and reverse
|
|
69
|
-
* const deque = new Deque<string>(['A', 'B', 'C', 'D']);
|
|
70
|
-
*
|
|
71
|
-
* // Iterate forward
|
|
72
|
-
* const forward: string[] = [];
|
|
73
|
-
* for (const item of deque) {
|
|
74
|
-
* forward.push(item);
|
|
75
|
-
* }
|
|
76
|
-
* console.log(forward); // ['A', 'B', 'C', 'D'];
|
|
77
|
-
*
|
|
78
|
-
* // Reverse the deque
|
|
79
|
-
* deque.reverse();
|
|
80
|
-
* const backward: string[] = [];
|
|
81
|
-
* for (const item of deque) {
|
|
82
|
-
* backward.push(item);
|
|
83
|
-
* }
|
|
84
|
-
* console.log(backward); // ['D', 'C', 'B', 'A'];
|
|
85
|
-
* @example
|
|
86
21
|
* // Deque as sliding window for stream processing
|
|
87
22
|
* interface DataPoint {
|
|
88
23
|
* timestamp: number;
|
|
@@ -133,6 +68,10 @@ import { LinearBase } from '../base/linear-base';
|
|
|
133
68
|
* console.log(windowResults[2].windowSize); // 3; // Windows are at max size from 3rd onwards
|
|
134
69
|
* console.log(windowResults[4].windowSize); // 3; // Last window still has 3 elements
|
|
135
70
|
* console.log(dataWindow.length); // 3;
|
|
71
|
+
* @example
|
|
72
|
+
* // Convert deque to array
|
|
73
|
+
* const dq = new Deque<number>([10, 20, 30]);
|
|
74
|
+
* console.log(dq.toArray()); // [10, 20, 30];
|
|
136
75
|
*/
|
|
137
76
|
export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
138
77
|
protected _equals: (a: E, b: E) => boolean;
|
|
@@ -227,12 +166,53 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
227
166
|
* Get the first element without removing it.
|
|
228
167
|
* @remarks Time O(1), Space O(1)
|
|
229
168
|
* @returns First element or undefined.
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
* @example
|
|
181
|
+
* // Deque peek at both ends
|
|
182
|
+
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
183
|
+
*
|
|
184
|
+
* // Get first element without removing
|
|
185
|
+
* const first = deque.at(0);
|
|
186
|
+
* console.log(first); // 10;
|
|
187
|
+
*
|
|
188
|
+
* // Get last element without removing
|
|
189
|
+
* const last = deque.at(deque.length - 1);
|
|
190
|
+
* console.log(last); // 50;
|
|
191
|
+
*
|
|
192
|
+
* // Length unchanged
|
|
193
|
+
* console.log(deque.length); // 5;
|
|
230
194
|
*/
|
|
231
195
|
get first(): E | undefined;
|
|
232
196
|
/**
|
|
233
197
|
* Get the last element without removing it.
|
|
234
198
|
* @remarks Time O(1), Space O(1)
|
|
235
199
|
* @returns Last element or undefined.
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
* @example
|
|
212
|
+
* // Peek at the back element
|
|
213
|
+
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
214
|
+
* console.log(dq.last); // 'c';
|
|
215
|
+
* console.log(dq.first); // 'a';
|
|
236
216
|
*/
|
|
237
217
|
get last(): E | undefined;
|
|
238
218
|
/**
|
|
@@ -251,18 +231,79 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
251
231
|
* @remarks Time O(1) amortized, Space O(1)
|
|
252
232
|
* @param element - Element to append.
|
|
253
233
|
* @returns True when appended.
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
* @example
|
|
246
|
+
* // basic Deque creation and push/pop operations
|
|
247
|
+
* // Create a simple Deque with initial values
|
|
248
|
+
* const deque = new Deque([1, 2, 3, 4, 5]);
|
|
249
|
+
*
|
|
250
|
+
* // Verify the deque maintains insertion order
|
|
251
|
+
* console.log([...deque]); // [1, 2, 3, 4, 5];
|
|
252
|
+
*
|
|
253
|
+
* // Check length
|
|
254
|
+
* console.log(deque.length); // 5;
|
|
255
|
+
*
|
|
256
|
+
* // Push to the end
|
|
257
|
+
* deque.push(6);
|
|
258
|
+
* console.log(deque.length); // 6;
|
|
259
|
+
*
|
|
260
|
+
* // Pop from the end
|
|
261
|
+
* const last = deque.pop();
|
|
262
|
+
* console.log(last); // 6;
|
|
254
263
|
*/
|
|
255
264
|
push(element: E): boolean;
|
|
256
265
|
/**
|
|
257
266
|
* Remove and return the last element.
|
|
258
267
|
* @remarks Time O(1), Space O(1)
|
|
259
268
|
* @returns Removed element or undefined.
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
* @example
|
|
281
|
+
* // Remove from the back
|
|
282
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
283
|
+
* console.log(dq.pop()); // 3;
|
|
284
|
+
* console.log(dq.length); // 2;
|
|
260
285
|
*/
|
|
261
286
|
pop(): E | undefined;
|
|
262
287
|
/**
|
|
263
288
|
* Remove and return the first element.
|
|
264
289
|
* @remarks Time O(1) amortized, Space O(1)
|
|
265
290
|
* @returns Removed element or undefined.
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
* @example
|
|
303
|
+
* // Remove from the front
|
|
304
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
305
|
+
* console.log(dq.shift()); // 1;
|
|
306
|
+
* console.log(dq.length); // 2;
|
|
266
307
|
*/
|
|
267
308
|
shift(): E | undefined;
|
|
268
309
|
/**
|
|
@@ -270,6 +311,32 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
270
311
|
* @remarks Time O(1) amortized, Space O(1)
|
|
271
312
|
* @param element - Element to prepend.
|
|
272
313
|
* @returns True when prepended.
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
* @example
|
|
326
|
+
* // Deque shift and unshift operations
|
|
327
|
+
* const deque = new Deque<number>([20, 30, 40]);
|
|
328
|
+
*
|
|
329
|
+
* // Unshift adds to the front
|
|
330
|
+
* deque.unshift(10);
|
|
331
|
+
* console.log([...deque]); // [10, 20, 30, 40];
|
|
332
|
+
*
|
|
333
|
+
* // Shift removes from the front (O(1) complexity!)
|
|
334
|
+
* const first = deque.shift();
|
|
335
|
+
* console.log(first); // 10;
|
|
336
|
+
*
|
|
337
|
+
* // Verify remaining elements
|
|
338
|
+
* console.log([...deque]); // [20, 30, 40];
|
|
339
|
+
* console.log(deque.length); // 3;
|
|
273
340
|
*/
|
|
274
341
|
unshift(element: E): boolean;
|
|
275
342
|
/**
|
|
@@ -290,12 +357,39 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
290
357
|
* Check whether the deque is empty.
|
|
291
358
|
* @remarks Time O(1), Space O(1)
|
|
292
359
|
* @returns True if length is 0.
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
* @example
|
|
370
|
+
* // Check if empty
|
|
371
|
+
* const dq = new Deque();
|
|
372
|
+
* console.log(dq.isEmpty()); // true;
|
|
293
373
|
*/
|
|
294
374
|
isEmpty(): boolean;
|
|
295
375
|
/**
|
|
296
376
|
* Remove all elements and reset structure.
|
|
297
377
|
* @remarks Time O(1), Space O(1)
|
|
298
378
|
* @returns void
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
* @example
|
|
389
|
+
* // Remove all elements
|
|
390
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
391
|
+
* dq.clear();
|
|
392
|
+
* console.log(dq.length); // 0;
|
|
299
393
|
*/
|
|
300
394
|
clear(): void;
|
|
301
395
|
/**
|
|
@@ -303,6 +397,19 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
303
397
|
* @remarks Time O(1), Space O(1)
|
|
304
398
|
* @param pos - Zero-based position from the front.
|
|
305
399
|
* @returns Element or undefined.
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
* @example
|
|
409
|
+
* // Access by index
|
|
410
|
+
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
411
|
+
* console.log(dq.at(0)); // 'a';
|
|
412
|
+
* console.log(dq.at(2)); // 'c';
|
|
306
413
|
*/
|
|
307
414
|
at(pos: number): E | undefined;
|
|
308
415
|
/**
|
|
@@ -359,6 +466,19 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
359
466
|
* @remarks Time O(N), Space O(1)
|
|
360
467
|
* @param element - Element to remove (using the configured equality).
|
|
361
468
|
* @returns True if an element was removed.
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
* @example
|
|
478
|
+
* // Remove element
|
|
479
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
480
|
+
* dq.delete(2);
|
|
481
|
+
* console.log(dq.length); // 2;
|
|
362
482
|
*/
|
|
363
483
|
delete(element: E): boolean;
|
|
364
484
|
/**
|
|
@@ -379,6 +499,35 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
379
499
|
* Reverse the deque by reversing buckets and pointers.
|
|
380
500
|
* @remarks Time O(N), Space O(N)
|
|
381
501
|
* @returns This deque.
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
* @example
|
|
514
|
+
* // Deque for...of iteration and reverse
|
|
515
|
+
* const deque = new Deque<string>(['A', 'B', 'C', 'D']);
|
|
516
|
+
*
|
|
517
|
+
* // Iterate forward
|
|
518
|
+
* const forward: string[] = [];
|
|
519
|
+
* for (const item of deque) {
|
|
520
|
+
* forward.push(item);
|
|
521
|
+
* }
|
|
522
|
+
* console.log(forward); // ['A', 'B', 'C', 'D'];
|
|
523
|
+
*
|
|
524
|
+
* // Reverse the deque
|
|
525
|
+
* deque.reverse();
|
|
526
|
+
* const backward: string[] = [];
|
|
527
|
+
* for (const item of deque) {
|
|
528
|
+
* backward.push(item);
|
|
529
|
+
* }
|
|
530
|
+
* console.log(backward); // ['D', 'C', 'B', 'A'];
|
|
382
531
|
*/
|
|
383
532
|
reverse(): this;
|
|
384
533
|
/**
|
|
@@ -407,6 +556,21 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
407
556
|
* Compact the deque by removing unused buckets.
|
|
408
557
|
* @remarks Time O(N), Space O(1)
|
|
409
558
|
* @returns True if compaction was performed (bucket count reduced).
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
* @example
|
|
568
|
+
* // Reclaim memory
|
|
569
|
+
* const dq = new Deque<number>([1, 2, 3, 4, 5]);
|
|
570
|
+
* dq.shift();
|
|
571
|
+
* dq.shift();
|
|
572
|
+
* dq.compact();
|
|
573
|
+
* console.log(dq.length); // 3;
|
|
410
574
|
*/
|
|
411
575
|
compact(): boolean;
|
|
412
576
|
shrinkToFit(): void;
|
|
@@ -414,6 +578,22 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
414
578
|
* Deep clone this deque, preserving options.
|
|
415
579
|
* @remarks Time O(N), Space O(N)
|
|
416
580
|
* @returns A new deque with the same content and options.
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
* @example
|
|
591
|
+
* // Create independent copy
|
|
592
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
593
|
+
* const copy = dq.clone();
|
|
594
|
+
* copy.pop();
|
|
595
|
+
* console.log(dq.length); // 3;
|
|
596
|
+
* console.log(copy.length); // 2;
|
|
417
597
|
*/
|
|
418
598
|
clone(): this;
|
|
419
599
|
/**
|
|
@@ -422,6 +602,20 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
422
602
|
* @param predicate - Predicate (value, index, deque) → boolean to keep element.
|
|
423
603
|
* @param [thisArg] - Value for `this` inside the predicate.
|
|
424
604
|
* @returns A new deque with kept elements.
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
* @example
|
|
615
|
+
* // Filter elements
|
|
616
|
+
* const dq = new Deque<number>([1, 2, 3, 4]);
|
|
617
|
+
* const result = dq.filter(x => x > 2);
|
|
618
|
+
* console.log(result.length); // 2;
|
|
425
619
|
*/
|
|
426
620
|
filter(predicate: ElementCallback<E, R, boolean>, thisArg?: any): this;
|
|
427
621
|
/**
|
|
@@ -441,6 +635,19 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
|
|
|
441
635
|
* @param [options] - Options for the output deque (e.g., bucketSize, toElementFn, maxLen).
|
|
442
636
|
* @param [thisArg] - Value for `this` inside the callback.
|
|
443
637
|
* @returns A new Deque with mapped elements.
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
* @example
|
|
647
|
+
* // Transform elements
|
|
648
|
+
* const dq = new Deque<number>([1, 2, 3]);
|
|
649
|
+
* const result = dq.map(x => x * 10);
|
|
650
|
+
* console.log(result.toArray()); // [10, 20, 30];
|
|
444
651
|
*/
|
|
445
652
|
map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: IterableElementBaseOptions<EM, RM>, thisArg?: any): Deque<EM, RM>;
|
|
446
653
|
/**
|