binary-tree-typed 2.4.5 → 2.5.1
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 +1476 -404
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +1473 -401
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1476 -404
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +1473 -401
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +380 -51
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +487 -147
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +956 -80
- package/dist/types/data-structures/binary-tree/bst.d.ts +816 -29
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +610 -31
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +326 -135
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +3781 -6
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3607 -201
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2874 -65
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +3528 -6
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +429 -47
- package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
- package/dist/types/data-structures/graph/undirected-graph.d.ts +393 -59
- package/dist/types/data-structures/hash/hash-map.d.ts +473 -89
- package/dist/types/data-structures/heap/heap.d.ts +581 -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 +646 -47
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +596 -68
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +793 -12
- package/dist/types/data-structures/matrix/matrix.d.ts +499 -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 +593 -71
- package/dist/types/data-structures/queue/queue.d.ts +463 -42
- package/dist/types/data-structures/stack/stack.d.ts +384 -32
- package/dist/types/data-structures/trie/trie.d.ts +470 -48
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
- package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/binary-tree-typed.js +1469 -397
- package/dist/umd/binary-tree-typed.js.map +1 -1
- package/dist/umd/binary-tree-typed.min.js +5 -5
- package/dist/umd/binary-tree-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/index.ts +1 -0
- package/src/data-structures/base/iterable-element-base.ts +4 -5
- package/src/data-structures/base/iterable-entry-base.ts +8 -8
- package/src/data-structures/base/linear-base.ts +3 -3
- package/src/data-structures/binary-tree/avl-tree.ts +386 -51
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +596 -247
- package/src/data-structures/binary-tree/binary-tree.ts +956 -81
- package/src/data-structures/binary-tree/bst.ts +840 -35
- package/src/data-structures/binary-tree/red-black-tree.ts +689 -97
- package/src/data-structures/binary-tree/segment-tree.ts +498 -249
- package/src/data-structures/binary-tree/tree-map.ts +3784 -7
- package/src/data-structures/binary-tree/tree-multi-map.ts +3614 -211
- package/src/data-structures/binary-tree/tree-multi-set.ts +2874 -65
- package/src/data-structures/binary-tree/tree-set.ts +3531 -10
- package/src/data-structures/graph/abstract-graph.ts +4 -4
- package/src/data-structures/graph/directed-graph.ts +429 -47
- package/src/data-structures/graph/map-graph.ts +59 -1
- package/src/data-structures/graph/undirected-graph.ts +393 -59
- package/src/data-structures/hash/hash-map.ts +476 -92
- package/src/data-structures/heap/heap.ts +581 -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 +646 -47
- package/src/data-structures/linked-list/singly-linked-list.ts +596 -68
- package/src/data-structures/linked-list/skip-linked-list.ts +1067 -90
- package/src/data-structures/matrix/matrix.ts +584 -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 +592 -70
- package/src/data-structures/queue/queue.ts +463 -42
- package/src/data-structures/stack/stack.ts +384 -32
- package/src/data-structures/trie/trie.ts +470 -48
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/linked-list/skip-linked-list.ts +2 -1
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
|
@@ -19,38 +19,6 @@ import { IterableElementBase } from '../base';
|
|
|
19
19
|
* 5. Expression Evaluation: Used for the evaluation of arithmetic or logical expressions, especially when dealing with parenthesis matching and operator precedence.
|
|
20
20
|
* 6. Backtracking Algorithms: In problems where multiple branches need to be explored but only one branch can be explored at a time, stacks can be used to save the state at each branching point.
|
|
21
21
|
* @example
|
|
22
|
-
* // basic Stack creation and push operation
|
|
23
|
-
* // Create a simple Stack with initial values
|
|
24
|
-
* const stack = new Stack([1, 2, 3, 4, 5]);
|
|
25
|
-
*
|
|
26
|
-
* // Verify the stack maintains insertion order (LIFO will be shown in pop)
|
|
27
|
-
* console.log([...stack]); // [1, 2, 3, 4, 5];
|
|
28
|
-
*
|
|
29
|
-
* // Check length
|
|
30
|
-
* console.log(stack.size); // 5;
|
|
31
|
-
*
|
|
32
|
-
* // Push a new element to the top
|
|
33
|
-
* stack.push(6);
|
|
34
|
-
* console.log(stack.size); // 6;
|
|
35
|
-
* @example
|
|
36
|
-
* // Stack pop operation (LIFO - Last In First Out)
|
|
37
|
-
* const stack = new Stack<number>([10, 20, 30, 40, 50]);
|
|
38
|
-
*
|
|
39
|
-
* // Peek at the top element without removing
|
|
40
|
-
* const top = stack.peek();
|
|
41
|
-
* console.log(top); // 50;
|
|
42
|
-
*
|
|
43
|
-
* // Pop removes from the top (LIFO order)
|
|
44
|
-
* const popped = stack.pop();
|
|
45
|
-
* console.log(popped); // 50;
|
|
46
|
-
*
|
|
47
|
-
* // Next pop gets the previous element
|
|
48
|
-
* const next = stack.pop();
|
|
49
|
-
* console.log(next); // 40;
|
|
50
|
-
*
|
|
51
|
-
* // Verify length decreased
|
|
52
|
-
* console.log(stack.size); // 3;
|
|
53
|
-
* @example
|
|
54
22
|
* // Function Call Stack
|
|
55
23
|
* const functionStack = new Stack<string>();
|
|
56
24
|
* functionStack.push('main');
|
|
@@ -157,6 +125,10 @@ import { IterableElementBase } from '../base';
|
|
|
157
125
|
* else if (segment && segment !== '.') stack.push(segment);
|
|
158
126
|
* });
|
|
159
127
|
* console.log(stack.elements.join('/')); // 'c';
|
|
128
|
+
* @example
|
|
129
|
+
* // Convert stack to array
|
|
130
|
+
* const stack = new Stack<number>([1, 2, 3]);
|
|
131
|
+
* console.log(stack.toArray()); // [1, 2, 3];
|
|
160
132
|
*/
|
|
161
133
|
export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
162
134
|
protected _equals: (a: E, b: E) => boolean;
|
|
@@ -179,6 +151,40 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
179
151
|
* Get the number of stored elements.
|
|
180
152
|
* @remarks Time O(1), Space O(1)
|
|
181
153
|
* @returns Current size.
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
* @example
|
|
185
|
+
* // Get number of elements
|
|
186
|
+
* const stack = new Stack<number>([1, 2, 3]);
|
|
187
|
+
* console.log(stack.size); // 3;
|
|
182
188
|
*/
|
|
183
189
|
get size(): number;
|
|
184
190
|
/**
|
|
@@ -196,12 +202,87 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
196
202
|
* Check whether the stack is empty.
|
|
197
203
|
* @remarks Time O(1), Space O(1)
|
|
198
204
|
* @returns True if size is 0.
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
* @example
|
|
238
|
+
* // Check if stack has elements
|
|
239
|
+
* const stack = new Stack<number>();
|
|
240
|
+
* console.log(stack.isEmpty()); // true;
|
|
241
|
+
* stack.push(1);
|
|
242
|
+
* console.log(stack.isEmpty()); // false;
|
|
199
243
|
*/
|
|
200
244
|
isEmpty(): boolean;
|
|
201
245
|
/**
|
|
202
246
|
* Get the top element without removing it.
|
|
203
247
|
* @remarks Time O(1), Space O(1)
|
|
204
248
|
* @returns Top element or undefined.
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
* @example
|
|
282
|
+
* // View the top element without removing it
|
|
283
|
+
* const stack = new Stack<string>(['a', 'b', 'c']);
|
|
284
|
+
* console.log(stack.peek()); // 'c';
|
|
285
|
+
* console.log(stack.size); // 3;
|
|
205
286
|
*/
|
|
206
287
|
peek(): E | undefined;
|
|
207
288
|
/**
|
|
@@ -209,12 +290,108 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
209
290
|
* @remarks Time O(1), Space O(1)
|
|
210
291
|
* @param element - Element to push.
|
|
211
292
|
* @returns True when pushed.
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
* @example
|
|
326
|
+
* // basic Stack creation and push operation
|
|
327
|
+
* // Create a simple Stack with initial values
|
|
328
|
+
* const stack = new Stack([1, 2, 3, 4, 5]);
|
|
329
|
+
*
|
|
330
|
+
* // Verify the stack maintains insertion order (LIFO will be shown in pop)
|
|
331
|
+
* console.log([...stack]); // [1, 2, 3, 4, 5];
|
|
332
|
+
*
|
|
333
|
+
* // Check length
|
|
334
|
+
* console.log(stack.size); // 5;
|
|
335
|
+
*
|
|
336
|
+
* // Push a new element to the top
|
|
337
|
+
* stack.push(6);
|
|
338
|
+
* console.log(stack.size); // 6;
|
|
212
339
|
*/
|
|
213
340
|
push(element: E): boolean;
|
|
214
341
|
/**
|
|
215
342
|
* Pop and return the top element.
|
|
216
343
|
* @remarks Time O(1), Space O(1)
|
|
217
344
|
* @returns Removed element or undefined.
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
* @example
|
|
378
|
+
* // Stack pop operation (LIFO - Last In First Out)
|
|
379
|
+
* const stack = new Stack<number>([10, 20, 30, 40, 50]);
|
|
380
|
+
*
|
|
381
|
+
* // Peek at the top element without removing
|
|
382
|
+
* const top = stack.peek();
|
|
383
|
+
* console.log(top); // 50;
|
|
384
|
+
*
|
|
385
|
+
* // Pop removes from the top (LIFO order)
|
|
386
|
+
* const popped = stack.pop();
|
|
387
|
+
* console.log(popped); // 50;
|
|
388
|
+
*
|
|
389
|
+
* // Next pop gets the previous element
|
|
390
|
+
* const next = stack.pop();
|
|
391
|
+
* console.log(next); // 40;
|
|
392
|
+
*
|
|
393
|
+
* // Verify length decreased
|
|
394
|
+
* console.log(stack.size); // 3;
|
|
218
395
|
*/
|
|
219
396
|
pop(): E | undefined;
|
|
220
397
|
/**
|
|
@@ -229,6 +406,40 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
229
406
|
* @remarks Time O(N), Space O(1)
|
|
230
407
|
* @param element - Element to remove (using the configured equality).
|
|
231
408
|
* @returns True if an element was removed.
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
* @example
|
|
439
|
+
* // Remove element
|
|
440
|
+
* const stack = new Stack<number>([1, 2, 3]);
|
|
441
|
+
* stack.delete(2);
|
|
442
|
+
* console.log(stack.toArray()); // [1, 3];
|
|
232
443
|
*/
|
|
233
444
|
delete(element: E): boolean;
|
|
234
445
|
/**
|
|
@@ -249,12 +460,84 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
249
460
|
* Remove all elements and reset storage.
|
|
250
461
|
* @remarks Time O(1), Space O(1)
|
|
251
462
|
* @returns void
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
* @example
|
|
494
|
+
* // Remove all elements
|
|
495
|
+
* const stack = new Stack<number>([1, 2, 3]);
|
|
496
|
+
* stack.clear();
|
|
497
|
+
* console.log(stack.isEmpty()); // true;
|
|
252
498
|
*/
|
|
253
499
|
clear(): void;
|
|
254
500
|
/**
|
|
255
501
|
* Deep clone this stack.
|
|
256
502
|
* @remarks Time O(N), Space O(N)
|
|
257
503
|
* @returns A new stack with the same content.
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
* @example
|
|
535
|
+
* // Create independent copy
|
|
536
|
+
* const stack = new Stack<number>([1, 2, 3]);
|
|
537
|
+
* const copy = stack.clone();
|
|
538
|
+
* copy.pop();
|
|
539
|
+
* console.log(stack.size); // 3;
|
|
540
|
+
* console.log(copy.size); // 2;
|
|
258
541
|
*/
|
|
259
542
|
clone(): this;
|
|
260
543
|
/**
|
|
@@ -263,6 +546,41 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
263
546
|
* @param predicate - Predicate (value, index, stack) → boolean to keep value.
|
|
264
547
|
* @param [thisArg] - Value for `this` inside the predicate.
|
|
265
548
|
* @returns A new stack with kept values.
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
* @example
|
|
580
|
+
* // Filter elements
|
|
581
|
+
* const stack = new Stack<number>([1, 2, 3, 4, 5]);
|
|
582
|
+
* const evens = stack.filter(x => x % 2 === 0);
|
|
583
|
+
* console.log(evens.toArray()); // [2, 4];
|
|
266
584
|
*/
|
|
267
585
|
filter(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
|
|
268
586
|
/**
|
|
@@ -282,6 +600,40 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
282
600
|
* @param [options] - Options for the output stack (e.g., toElementFn).
|
|
283
601
|
* @param [thisArg] - Value for `this` inside the callback.
|
|
284
602
|
* @returns A new Stack with mapped elements.
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
* @example
|
|
633
|
+
* // Transform elements
|
|
634
|
+
* const stack = new Stack<number>([1, 2, 3]);
|
|
635
|
+
* const doubled = stack.map(x => x * 2);
|
|
636
|
+
* console.log(doubled.toArray()); // [2, 4, 6];
|
|
285
637
|
*/
|
|
286
638
|
map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: IterableElementBaseOptions<EM, RM>, thisArg?: unknown): Stack<EM, RM>;
|
|
287
639
|
/**
|