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.
Files changed (94) hide show
  1. package/README.md +0 -84
  2. package/dist/cjs/index.cjs +1476 -404
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs-legacy/index.cjs +1473 -401
  5. package/dist/cjs-legacy/index.cjs.map +1 -1
  6. package/dist/esm/index.mjs +1476 -404
  7. package/dist/esm/index.mjs.map +1 -1
  8. package/dist/esm-legacy/index.mjs +1473 -401
  9. package/dist/esm-legacy/index.mjs.map +1 -1
  10. package/dist/types/data-structures/base/index.d.ts +1 -0
  11. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  12. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  13. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  14. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +380 -51
  15. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +487 -147
  16. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +956 -80
  17. package/dist/types/data-structures/binary-tree/bst.d.ts +816 -29
  18. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +610 -31
  19. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +326 -135
  20. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3781 -6
  21. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3607 -201
  22. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2874 -65
  23. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3528 -6
  24. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  25. package/dist/types/data-structures/graph/directed-graph.d.ts +429 -47
  26. package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
  27. package/dist/types/data-structures/graph/undirected-graph.d.ts +393 -59
  28. package/dist/types/data-structures/hash/hash-map.d.ts +473 -89
  29. package/dist/types/data-structures/heap/heap.d.ts +581 -99
  30. package/dist/types/data-structures/heap/max-heap.d.ts +46 -0
  31. package/dist/types/data-structures/heap/min-heap.d.ts +59 -0
  32. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +646 -47
  33. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +596 -68
  34. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +793 -12
  35. package/dist/types/data-structures/matrix/matrix.d.ts +499 -0
  36. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +57 -0
  37. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +60 -0
  38. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +60 -0
  39. package/dist/types/data-structures/queue/deque.d.ts +593 -71
  40. package/dist/types/data-structures/queue/queue.d.ts +463 -42
  41. package/dist/types/data-structures/stack/stack.d.ts +384 -32
  42. package/dist/types/data-structures/trie/trie.d.ts +470 -48
  43. package/dist/types/interfaces/graph.d.ts +1 -1
  44. package/dist/types/types/common.d.ts +2 -2
  45. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
  46. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  47. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
  48. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  49. package/dist/types/types/utils/validate-type.d.ts +4 -4
  50. package/dist/umd/binary-tree-typed.js +1469 -397
  51. package/dist/umd/binary-tree-typed.js.map +1 -1
  52. package/dist/umd/binary-tree-typed.min.js +5 -5
  53. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  54. package/package.json +2 -2
  55. package/src/data-structures/base/index.ts +1 -0
  56. package/src/data-structures/base/iterable-element-base.ts +4 -5
  57. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  58. package/src/data-structures/base/linear-base.ts +3 -3
  59. package/src/data-structures/binary-tree/avl-tree.ts +386 -51
  60. package/src/data-structures/binary-tree/binary-indexed-tree.ts +596 -247
  61. package/src/data-structures/binary-tree/binary-tree.ts +956 -81
  62. package/src/data-structures/binary-tree/bst.ts +840 -35
  63. package/src/data-structures/binary-tree/red-black-tree.ts +689 -97
  64. package/src/data-structures/binary-tree/segment-tree.ts +498 -249
  65. package/src/data-structures/binary-tree/tree-map.ts +3784 -7
  66. package/src/data-structures/binary-tree/tree-multi-map.ts +3614 -211
  67. package/src/data-structures/binary-tree/tree-multi-set.ts +2874 -65
  68. package/src/data-structures/binary-tree/tree-set.ts +3531 -10
  69. package/src/data-structures/graph/abstract-graph.ts +4 -4
  70. package/src/data-structures/graph/directed-graph.ts +429 -47
  71. package/src/data-structures/graph/map-graph.ts +59 -1
  72. package/src/data-structures/graph/undirected-graph.ts +393 -59
  73. package/src/data-structures/hash/hash-map.ts +476 -92
  74. package/src/data-structures/heap/heap.ts +581 -99
  75. package/src/data-structures/heap/max-heap.ts +46 -0
  76. package/src/data-structures/heap/min-heap.ts +59 -0
  77. package/src/data-structures/linked-list/doubly-linked-list.ts +646 -47
  78. package/src/data-structures/linked-list/singly-linked-list.ts +596 -68
  79. package/src/data-structures/linked-list/skip-linked-list.ts +1067 -90
  80. package/src/data-structures/matrix/matrix.ts +584 -12
  81. package/src/data-structures/priority-queue/max-priority-queue.ts +57 -0
  82. package/src/data-structures/priority-queue/min-priority-queue.ts +60 -0
  83. package/src/data-structures/priority-queue/priority-queue.ts +60 -0
  84. package/src/data-structures/queue/deque.ts +592 -70
  85. package/src/data-structures/queue/queue.ts +463 -42
  86. package/src/data-structures/stack/stack.ts +384 -32
  87. package/src/data-structures/trie/trie.ts +470 -48
  88. package/src/interfaces/graph.ts +1 -1
  89. package/src/types/common.ts +2 -2
  90. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
  91. package/src/types/data-structures/heap/heap.ts +1 -0
  92. package/src/types/data-structures/linked-list/skip-linked-list.ts +2 -1
  93. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  94. package/src/types/utils/validate-type.ts +4 -4
@@ -46,71 +46,6 @@ export declare class SinglyLinkedListNode<E = any> extends LinkedListNode<E> {
46
46
  * 4. High Efficiency in Insertion and Deletion: Adding or removing elements in a linked list does not require moving other elements, making these operations more efficient than in arrays.
47
47
  * Caution: Although our linked list classes provide methods such as at, setAt, addAt, and indexOf that are based on array indices, their time complexity, like that of the native Array.lastIndexOf, is 𝑂(𝑛). If you need to use these methods frequently, you might want to consider other data structures, such as Deque or Queue (designed for random access). Similarly, since the native Array.shift method has a time complexity of 𝑂(𝑛), using an array to simulate a queue can be inefficient. In such cases, you should use Queue or Deque, as these data structures leverage deferred array rearrangement, effectively reducing the average time complexity to 𝑂(1).
48
48
  * @example
49
- * // basic SinglyLinkedList creation and push operation
50
- * // Create a simple SinglyLinkedList with initial values
51
- * const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
52
- *
53
- * // Verify the list maintains insertion order
54
- * console.log([...list]); // [1, 2, 3, 4, 5];
55
- *
56
- * // Check length
57
- * console.log(list.length); // 5;
58
- *
59
- * // Push a new element to the end
60
- * list.push(6);
61
- * console.log(list.length); // 6;
62
- * console.log([...list]); // [1, 2, 3, 4, 5, 6];
63
- * @example
64
- * // SinglyLinkedList pop and shift operations
65
- * const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
66
- *
67
- * // Pop removes from the end
68
- * const last = list.pop();
69
- * console.log(last); // 50;
70
- *
71
- * // Shift removes from the beginning
72
- * const first = list.shift();
73
- * console.log(first); // 10;
74
- *
75
- * // Verify remaining elements
76
- * console.log([...list]); // [20, 30, 40];
77
- * console.log(list.length); // 3;
78
- * @example
79
- * // SinglyLinkedList unshift and forward traversal
80
- * const list = new SinglyLinkedList<number>([20, 30, 40]);
81
- *
82
- * // Unshift adds to the beginning
83
- * list.unshift(10);
84
- * console.log([...list]); // [10, 20, 30, 40];
85
- *
86
- * // Access elements (forward traversal only for singly linked)
87
- * const second = list.at(1);
88
- * console.log(second); // 20;
89
- *
90
- * // SinglyLinkedList allows forward iteration only
91
- * const elements: number[] = [];
92
- * for (const item of list) {
93
- * elements.push(item);
94
- * }
95
- * console.log(elements); // [10, 20, 30, 40];
96
- *
97
- * console.log(list.length); // 4;
98
- * @example
99
- * // SinglyLinkedList filter and map operations
100
- * const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
101
- *
102
- * // Filter even numbers
103
- * const filtered = list.filter(value => value % 2 === 0);
104
- * console.log(filtered.length); // 2;
105
- *
106
- * // Map to double values
107
- * const doubled = list.map(value => value * 2);
108
- * console.log(doubled.length); // 5;
109
- *
110
- * // Use reduce to sum
111
- * const sum = list.reduce((acc, value) => acc + value, 0);
112
- * console.log(sum); // 15;
113
- * @example
114
49
  * // SinglyLinkedList for sequentially processed data stream
115
50
  * interface LogEntry {
116
51
  * timestamp: number;
@@ -227,6 +162,17 @@ export declare class SinglyLinkedListNode<E = any> extends LinkedListNode<E> {
227
162
  * editor.moveCursor(1);
228
163
  * editor.insert('a');
229
164
  * console.log(editor.getText()); // 'Haello';
165
+ * @example
166
+ * // Find first matching element
167
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
168
+ * console.log(list.find(n => n > 3)); // 4;
169
+ * console.log(list.find(n => n > 10)); // undefined;
170
+ * @example
171
+ * // Iterate over elements
172
+ * const list = new SinglyLinkedList<number>([10, 20, 30]);
173
+ * const result: number[] = [];
174
+ * list.forEach(n => result.push(n));
175
+ * console.log(result); // [10, 20, 30];
230
176
  */
231
177
  export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, SinglyLinkedListNode<E>> {
232
178
  protected _equals: (a: E, b: E) => boolean;
@@ -288,18 +234,149 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
288
234
  * @remarks Time O(1), Space O(1)
289
235
  * @param elementOrNode - Element or node to append.
290
236
  * @returns True when appended.
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+ * @example
270
+ * // basic SinglyLinkedList creation and push operation
271
+ * // Create a simple SinglyLinkedList with initial values
272
+ * const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
273
+ *
274
+ * // Verify the list maintains insertion order
275
+ * console.log([...list]); // [1, 2, 3, 4, 5];
276
+ *
277
+ * // Check length
278
+ * console.log(list.length); // 5;
279
+ *
280
+ * // Push a new element to the end
281
+ * list.push(6);
282
+ * console.log(list.length); // 6;
283
+ * console.log([...list]); // [1, 2, 3, 4, 5, 6];
291
284
  */
292
285
  push(elementOrNode: E | SinglyLinkedListNode<E>): boolean;
293
286
  /**
294
287
  * Remove and return the tail element.
295
288
  * @remarks Time O(N), Space O(1)
296
289
  * @returns Removed element or undefined.
290
+
291
+
292
+
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
+ * @example
323
+ * // SinglyLinkedList pop and shift operations
324
+ * const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
325
+ *
326
+ * // Pop removes from the end
327
+ * const last = list.pop();
328
+ * console.log(last); // 50;
329
+ *
330
+ * // Shift removes from the beginning
331
+ * const first = list.shift();
332
+ * console.log(first); // 10;
333
+ *
334
+ * // Verify remaining elements
335
+ * console.log([...list]); // [20, 30, 40];
336
+ * console.log(list.length); // 3;
297
337
  */
298
338
  pop(): E | undefined;
299
339
  /**
300
340
  * Remove and return the head element.
301
341
  * @remarks Time O(1), Space O(1)
302
342
  * @returns Removed element or undefined.
343
+
344
+
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
+ * @example
376
+ * // Remove from the front
377
+ * const list = new SinglyLinkedList<number>([10, 20, 30]);
378
+ * console.log(list.shift()); // 10;
379
+ * console.log(list.length); // 2;
303
380
  */
304
381
  shift(): E | undefined;
305
382
  /**
@@ -307,6 +384,58 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
307
384
  * @remarks Time O(1), Space O(1)
308
385
  * @param elementOrNode - Element or node to prepend.
309
386
  * @returns True when prepended.
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+ * @example
420
+ * // SinglyLinkedList unshift and forward traversal
421
+ * const list = new SinglyLinkedList<number>([20, 30, 40]);
422
+ *
423
+ * // Unshift adds to the beginning
424
+ * list.unshift(10);
425
+ * console.log([...list]); // [10, 20, 30, 40];
426
+ *
427
+ * // Access elements (forward traversal only for singly linked)
428
+ * const second = list.at(1);
429
+ * console.log(second); // 20;
430
+ *
431
+ * // SinglyLinkedList allows forward iteration only
432
+ * const elements: number[] = [];
433
+ * for (const item of list) {
434
+ * elements.push(item);
435
+ * }
436
+ * console.log(elements); // [10, 20, 30, 40];
437
+ *
438
+ * console.log(list.length); // 4;
310
439
  */
311
440
  unshift(elementOrNode: E | SinglyLinkedListNode<E>): boolean;
312
441
  /**
@@ -335,6 +464,44 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
335
464
  * @remarks Time O(N), Space O(1)
336
465
  * @param index - Zero-based index.
337
466
  * @returns Element or undefined.
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
+
494
+
495
+
496
+
497
+
498
+
499
+ * @example
500
+ * // Access element by index
501
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
502
+ * console.log(list.at(0)); // 'a';
503
+ * console.log(list.at(2)); // 'c';
504
+ * console.log(list.at(3)); // 'd';
338
505
  */
339
506
  at(index: number): E | undefined;
340
507
  /**
@@ -349,6 +516,39 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
349
516
  * @remarks Time O(N), Space O(1)
350
517
  * @param index - Zero-based index.
351
518
  * @returns Node or undefined.
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+ * @example
549
+ * // Get node at index
550
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
551
+ * console.log(list.getNodeAt(1)?.value); // 'b';
352
552
  */
353
553
  getNodeAt(index: number): SinglyLinkedListNode<E> | undefined;
354
554
  /**
@@ -356,6 +556,40 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
356
556
  * @remarks Time O(N), Space O(1)
357
557
  * @param index - Zero-based index.
358
558
  * @returns Removed element or undefined.
559
+
560
+
561
+
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+
573
+
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+
588
+ * @example
589
+ * // Remove by index
590
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
591
+ * list.deleteAt(1);
592
+ * console.log(list.toArray()); // ['a', 'c'];
359
593
  */
360
594
  deleteAt(index: number): E | undefined;
361
595
  /**
@@ -363,6 +597,40 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
363
597
  * @remarks Time O(N), Space O(1)
364
598
  * @param [elementOrNode] - Element or node to remove; if omitted/undefined, nothing happens.
365
599
  * @returns True if removed.
600
+
601
+
602
+
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
+ * @example
630
+ * // Remove first occurrence
631
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
632
+ * list.delete(2);
633
+ * console.log(list.toArray()); // [1, 3, 2];
366
634
  */
367
635
  delete(elementOrNode: E | SinglyLinkedListNode<E> | undefined): boolean;
368
636
  /**
@@ -371,6 +639,40 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
371
639
  * @param index - Zero-based index.
372
640
  * @param newElementOrNode - Element or node to insert.
373
641
  * @returns True if inserted.
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+
662
+
663
+
664
+
665
+
666
+
667
+
668
+
669
+
670
+
671
+ * @example
672
+ * // Insert at index
673
+ * const list = new SinglyLinkedList<number>([1, 3]);
674
+ * list.addAt(1, 2);
675
+ * console.log(list.toArray()); // [1, 2, 3];
374
676
  */
375
677
  addAt(index: number, newElementOrNode: E | SinglyLinkedListNode<E>): boolean;
376
678
  /**
@@ -385,18 +687,123 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
385
687
  * Check whether the list is empty.
386
688
  * @remarks Time O(1), Space O(1)
387
689
  * @returns True if length is 0.
690
+
691
+
692
+
693
+
694
+
695
+
696
+
697
+
698
+
699
+
700
+
701
+
702
+
703
+
704
+
705
+
706
+
707
+
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+ * @example
721
+ * // Check empty
722
+ * console.log(new SinglyLinkedList().isEmpty()); // true;
388
723
  */
389
724
  isEmpty(): boolean;
390
725
  /**
391
726
  * Remove all nodes and reset length.
392
727
  * @remarks Time O(N), Space O(1)
393
728
  * @returns void
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
742
+
743
+
744
+
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+ * @example
760
+ * // Remove all
761
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
762
+ * list.clear();
763
+ * console.log(list.isEmpty()); // true;
394
764
  */
395
765
  clear(): void;
396
766
  /**
397
767
  * Reverse the list in place.
398
768
  * @remarks Time O(N), Space O(1)
399
769
  * @returns This list.
770
+
771
+
772
+
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+
790
+
791
+
792
+
793
+
794
+
795
+
796
+
797
+
798
+
799
+
800
+
801
+
802
+ * @example
803
+ * // Reverse the list in-place
804
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
805
+ * list.reverse();
806
+ * console.log([...list]); // [4, 3, 2, 1];
400
807
  */
401
808
  reverse(): this;
402
809
  /**
@@ -456,6 +863,43 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
456
863
  * Deep clone this list (values are copied by reference).
457
864
  * @remarks Time O(N), Space O(N)
458
865
  * @returns A new list with the same element sequence.
866
+
867
+
868
+
869
+
870
+
871
+
872
+
873
+
874
+
875
+
876
+
877
+
878
+
879
+
880
+
881
+
882
+
883
+
884
+
885
+
886
+
887
+
888
+
889
+
890
+
891
+
892
+
893
+
894
+
895
+
896
+ * @example
897
+ * // Deep copy
898
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
899
+ * const copy = list.clone();
900
+ * copy.pop();
901
+ * console.log(list.length); // 3;
902
+ * console.log(copy.length); // 2;
459
903
  */
460
904
  clone(): this;
461
905
  /**
@@ -464,8 +908,55 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
464
908
  * @param callback - Predicate (value, index, list) → boolean to keep value.
465
909
  * @param [thisArg] - Value for `this` inside the callback.
466
910
  * @returns A new list with kept values.
911
+
912
+
913
+
914
+
915
+
916
+
917
+
918
+
919
+
920
+
921
+
922
+
923
+
924
+
925
+
926
+
927
+
928
+
929
+
930
+
931
+
932
+
933
+
934
+
935
+
936
+
937
+
938
+
939
+
940
+
941
+
942
+
943
+ * @example
944
+ * // SinglyLinkedList filter and map operations
945
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
946
+ *
947
+ * // Filter even numbers
948
+ * const filtered = list.filter(value => value % 2 === 0);
949
+ * console.log(filtered.length); // 2;
950
+ *
951
+ * // Map to double values
952
+ * const doubled = list.map(value => value * 2);
953
+ * console.log(doubled.length); // 5;
954
+ *
955
+ * // Use reduce to sum
956
+ * const sum = list.reduce((acc, value) => acc + value, 0);
957
+ * console.log(sum); // 15;
467
958
  */
468
- filter(callback: ElementCallback<E, R, boolean>, thisArg?: any): this;
959
+ filter(callback: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
469
960
  /**
470
961
  * Map values into a new list of the same class.
471
962
  * @remarks Time O(N), Space O(N)
@@ -473,7 +964,7 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
473
964
  * @param [thisArg] - Value for `this` inside the callback.
474
965
  * @returns A new list with mapped values.
475
966
  */
476
- mapSame(callback: ElementCallback<E, R, E>, thisArg?: any): this;
967
+ mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this;
477
968
  /**
478
969
  * Map values into a new list (possibly different element type).
479
970
  * @remarks Time O(N), Space O(N)
@@ -483,8 +974,45 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
483
974
  * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
484
975
  * @param [thisArg] - Value for `this` inside the callback.
485
976
  * @returns A new SinglyLinkedList with mapped values.
977
+
978
+
979
+
980
+
981
+
982
+
983
+
984
+
985
+
986
+
987
+
988
+
989
+
990
+
991
+
992
+
993
+
994
+
995
+
996
+
997
+
998
+
999
+
1000
+
1001
+
1002
+
1003
+
1004
+
1005
+
1006
+
1007
+
1008
+
1009
+ * @example
1010
+ * // Transform elements
1011
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
1012
+ * const doubled = list.map(n => n * 2);
1013
+ * console.log([...doubled]); // [2, 4, 6];
486
1014
  */
487
- map<EM, RM = any>(callback: ElementCallback<E, R, EM>, options?: SinglyLinkedListOptions<EM, RM>, thisArg?: any): SinglyLinkedList<EM, RM>;
1015
+ map<EM, RM = any>(callback: ElementCallback<E, R, EM>, options?: SinglyLinkedListOptions<EM, RM>, thisArg?: unknown): SinglyLinkedList<EM, RM>;
488
1016
  /**
489
1017
  * (Protected) Create a node from a value.
490
1018
  * @remarks Time O(1), Space O(1)