data-structure-typed 2.6.0 → 2.6.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 (80) hide show
  1. package/.github/workflows/ci.yml +7 -2
  2. package/.github/workflows/release-package.yml +9 -2
  3. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +108 -108
  4. package/docs-site-docusaurus/docs/api/classes/BST.md +101 -101
  5. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -13
  6. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +66 -66
  7. package/docs-site-docusaurus/docs/api/classes/Deque.md +235 -51
  8. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +21 -21
  9. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +231 -67
  10. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  11. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  12. package/docs-site-docusaurus/docs/api/classes/HashMap.md +14 -14
  13. package/docs-site-docusaurus/docs/api/classes/Heap.md +117 -34
  14. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +83 -13
  15. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +124 -20
  16. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +140 -32
  17. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
  18. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +159 -51
  19. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +20 -20
  20. package/docs-site-docusaurus/docs/api/classes/Matrix.md +23 -23
  21. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -34
  22. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +117 -34
  23. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -34
  24. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +117 -34
  25. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +117 -34
  26. package/docs-site-docusaurus/docs/api/classes/Queue.md +142 -34
  27. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +117 -117
  28. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +8 -8
  29. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +158 -50
  30. package/docs-site-docusaurus/docs/api/classes/SkipList.md +21 -21
  31. package/docs-site-docusaurus/docs/api/classes/Stack.md +108 -26
  32. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +33 -33
  33. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +75 -39
  34. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +301 -39
  35. package/docs-site-docusaurus/docs/api/classes/Trie.md +110 -28
  36. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +20 -20
  37. package/package.json +45 -46
  38. package/src/common/error.ts +15 -32
  39. package/src/common/index.ts +0 -3
  40. package/src/data-structures/base/iterable-element-base.ts +0 -3
  41. package/src/data-structures/base/linear-base.ts +2 -36
  42. package/src/data-structures/binary-tree/avl-tree.ts +31 -529
  43. package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -572
  44. package/src/data-structures/binary-tree/binary-tree.ts +326 -1311
  45. package/src/data-structures/binary-tree/bst.ts +158 -1082
  46. package/src/data-structures/binary-tree/red-black-tree.ts +451 -1290
  47. package/src/data-structures/binary-tree/segment-tree.ts +73 -351
  48. package/src/data-structures/binary-tree/tree-map.ts +462 -5124
  49. package/src/data-structures/binary-tree/tree-multi-map.ts +302 -4914
  50. package/src/data-structures/binary-tree/tree-multi-set.ts +284 -3972
  51. package/src/data-structures/binary-tree/tree-set.ts +338 -4836
  52. package/src/data-structures/graph/abstract-graph.ts +98 -167
  53. package/src/data-structures/graph/directed-graph.ts +137 -562
  54. package/src/data-structures/graph/map-graph.ts +0 -3
  55. package/src/data-structures/graph/undirected-graph.ts +132 -511
  56. package/src/data-structures/hash/hash-map.ts +154 -582
  57. package/src/data-structures/heap/heap.ts +200 -795
  58. package/src/data-structures/linked-list/doubly-linked-list.ts +121 -865
  59. package/src/data-structures/linked-list/singly-linked-list.ts +122 -794
  60. package/src/data-structures/linked-list/skip-linked-list.ts +211 -918
  61. package/src/data-structures/matrix/matrix.ts +179 -518
  62. package/src/data-structures/matrix/navigator.ts +0 -1
  63. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
  64. package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
  65. package/src/data-structures/priority-queue/priority-queue.ts +1 -2
  66. package/src/data-structures/queue/deque.ts +214 -882
  67. package/src/data-structures/queue/queue.ts +102 -625
  68. package/src/data-structures/stack/stack.ts +76 -505
  69. package/src/data-structures/trie/trie.ts +98 -628
  70. package/src/types/common.ts +0 -10
  71. package/src/types/data-structures/binary-tree/bst.ts +0 -7
  72. package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
  73. package/src/types/data-structures/graph/abstract-graph.ts +0 -2
  74. package/src/types/data-structures/hash/hash-map.ts +0 -3
  75. package/src/types/data-structures/hash/index.ts +0 -1
  76. package/src/types/data-structures/matrix/navigator.ts +0 -2
  77. package/src/types/utils/utils.ts +0 -7
  78. package/src/types/utils/validate-type.ts +0 -7
  79. package/src/utils/number.ts +0 -2
  80. package/src/utils/utils.ts +0 -5
@@ -5,7 +5,6 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
-
9
8
  import type { ElementCallback, SinglyLinkedListOptions } from '../../types';
10
9
  import { LinearLinkedBase, LinkedListNode } from '../base/linear-base';
11
10
 
@@ -21,7 +20,6 @@ export class SinglyLinkedListNode<E = any> extends LinkedListNode<E> {
21
20
  * @param value - Element value to store.
22
21
  * @returns New node instance.
23
22
  */
24
-
25
23
  constructor(value: E) {
26
24
  super(value);
27
25
  this._value = value;
@@ -35,7 +33,6 @@ export class SinglyLinkedListNode<E = any> extends LinkedListNode<E> {
35
33
  * @remarks Time O(1), Space O(1)
36
34
  * @returns Next node or undefined.
37
35
  */
38
-
39
36
  override get next(): SinglyLinkedListNode<E> | undefined {
40
37
  return this._next;
41
38
  }
@@ -46,7 +43,6 @@ export class SinglyLinkedListNode<E = any> extends LinkedListNode<E> {
46
43
  * @param value - Next node or undefined.
47
44
  * @returns void
48
45
  */
49
-
50
46
  override set next(value: SinglyLinkedListNode<E> | undefined) {
51
47
  this._next = value;
52
48
  }
@@ -192,8 +188,6 @@ export class SinglyLinkedListNode<E = any> extends LinkedListNode<E> {
192
188
  * console.log(result); // [10, 20, 30];
193
189
  */
194
190
  export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, SinglyLinkedListNode<E>> {
195
- protected _equals: (a: E, b: E) => boolean = (a, b) => Object.is(a, b);
196
-
197
191
  /**
198
192
  * Create a SinglyLinkedList and optionally bulk-insert elements.
199
193
  * @remarks Time O(N), Space O(N)
@@ -201,7 +195,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
201
195
  * @param [options] - Options such as maxLen and toElementFn.
202
196
  * @returns New SinglyLinkedList instance.
203
197
  */
204
-
205
198
  constructor(
206
199
  elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>> = [],
207
200
  options?: SinglyLinkedListOptions<E, R>
@@ -217,7 +210,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
217
210
  * @remarks Time O(1), Space O(1)
218
211
  * @returns Head node or undefined.
219
212
  */
220
-
221
213
  get head(): SinglyLinkedListNode<E> | undefined {
222
214
  return this._head;
223
215
  }
@@ -229,7 +221,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
229
221
  * @remarks Time O(1), Space O(1)
230
222
  * @returns Tail node or undefined.
231
223
  */
232
-
233
224
  get tail(): SinglyLinkedListNode<E> | undefined {
234
225
  return this._tail;
235
226
  }
@@ -241,7 +232,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
241
232
  * @remarks Time O(1), Space O(1)
242
233
  * @returns Current length.
243
234
  */
244
-
245
235
  get length(): number {
246
236
  return this._length;
247
237
  }
@@ -251,7 +241,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
251
241
  * @remarks Time O(1), Space O(1)
252
242
  * @returns First element or undefined.
253
243
  */
254
-
255
244
  get first(): E | undefined {
256
245
  return this.head?.value;
257
246
  }
@@ -261,7 +250,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
261
250
  * @remarks Time O(1), Space O(1)
262
251
  * @returns Last element or undefined.
263
252
  */
264
-
265
253
  get last(): E | undefined {
266
254
  return this.tail?.value;
267
255
  }
@@ -277,7 +265,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
277
265
  * @param [options] - Options forwarded to the constructor.
278
266
  * @returns A new list populated with the iterable's elements.
279
267
  */
280
-
281
268
  static from<E, R = any, S extends SinglyLinkedList<E, R> = SinglyLinkedList<E, R>>(
282
269
  this: new (
283
270
  elements?: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>,
@@ -296,65 +283,22 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
296
283
  * @remarks Time O(1), Space O(1)
297
284
  * @param elementOrNode - Element or node to append.
298
285
  * @returns True when appended.
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
-
326
-
327
-
328
-
329
-
330
-
331
-
332
-
333
-
334
-
335
-
336
-
337
-
338
-
339
-
340
-
341
- * @example
342
- * // basic SinglyLinkedList creation and push operation
343
- * // Create a simple SinglyLinkedList with initial values
344
- * const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
345
- *
346
- * // Verify the list maintains insertion order
347
- * console.log([...list]); // [1, 2, 3, 4, 5];
348
- *
349
- * // Check length
350
- * console.log(list.length); // 5;
351
- *
352
- * // Push a new element to the end
353
- * list.push(6);
354
- * console.log(list.length); // 6;
355
- * console.log([...list]); // [1, 2, 3, 4, 5, 6];
286
+ * @example
287
+ * // basic SinglyLinkedList creation and push operation
288
+ * // Create a simple SinglyLinkedList with initial values
289
+ * const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
290
+ *
291
+ * // Verify the list maintains insertion order
292
+ * console.log([...list]); // [1, 2, 3, 4, 5];
293
+ *
294
+ * // Check length
295
+ * console.log(list.length); // 5;
296
+ *
297
+ * // Push a new element to the end
298
+ * list.push(6);
299
+ * console.log(list.length); // 6;
300
+ * console.log([...list]); // [1, 2, 3, 4, 5, 6];
356
301
  */
357
-
358
302
  push(elementOrNode: E | SinglyLinkedListNode<E>): boolean {
359
303
  const newNode = this._ensureNode(elementOrNode);
360
304
  if (!this.head) {
@@ -372,65 +316,22 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
372
316
  * Remove and return the tail element.
373
317
  * @remarks Time O(N), Space O(1)
374
318
  * @returns Removed element or undefined.
375
-
376
-
377
-
378
-
379
-
380
-
381
-
382
-
383
-
384
-
385
-
386
-
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
- * @example
418
- * // SinglyLinkedList pop and shift operations
419
- * const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
420
- *
421
- * // Pop removes from the end
422
- * const last = list.pop();
423
- * console.log(last); // 50;
424
- *
425
- * // Shift removes from the beginning
426
- * const first = list.shift();
427
- * console.log(first); // 10;
428
- *
429
- * // Verify remaining elements
430
- * console.log([...list]); // [20, 30, 40];
431
- * console.log(list.length); // 3;
319
+ * @example
320
+ * // SinglyLinkedList pop and shift operations
321
+ * const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
322
+ *
323
+ * // Pop removes from the end
324
+ * const last = list.pop();
325
+ * console.log(last); // 50;
326
+ *
327
+ * // Shift removes from the beginning
328
+ * const first = list.shift();
329
+ * console.log(first); // 10;
330
+ *
331
+ * // Verify remaining elements
332
+ * console.log([...list]); // [20, 30, 40];
333
+ * console.log(list.length); // 3;
432
334
  */
433
-
434
335
  pop(): E | undefined {
435
336
  if (!this.head) return undefined;
436
337
  if (this.head === this.tail) {
@@ -453,55 +354,12 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
453
354
  * Remove and return the head element.
454
355
  * @remarks Time O(1), Space O(1)
455
356
  * @returns Removed element or undefined.
456
-
457
-
458
-
459
-
460
-
461
-
462
-
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
-
494
-
495
-
496
-
497
-
498
- * @example
499
- * // Remove from the front
500
- * const list = new SinglyLinkedList<number>([10, 20, 30]);
501
- * console.log(list.shift()); // 10;
502
- * console.log(list.length); // 2;
357
+ * @example
358
+ * // Remove from the front
359
+ * const list = new SinglyLinkedList<number>([10, 20, 30]);
360
+ * console.log(list.shift()); // 10;
361
+ * console.log(list.length); // 2;
503
362
  */
504
-
505
363
  shift(): E | undefined {
506
364
  if (!this.head) return undefined;
507
365
  const removed = this.head;
@@ -516,70 +374,27 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
516
374
  * @remarks Time O(1), Space O(1)
517
375
  * @param elementOrNode - Element or node to prepend.
518
376
  * @returns True when prepended.
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
-
549
-
550
-
551
-
552
-
553
-
554
-
555
-
556
-
557
-
558
-
559
-
560
-
561
- * @example
562
- * // SinglyLinkedList unshift and forward traversal
563
- * const list = new SinglyLinkedList<number>([20, 30, 40]);
564
- *
565
- * // Unshift adds to the beginning
566
- * list.unshift(10);
567
- * console.log([...list]); // [10, 20, 30, 40];
568
- *
569
- * // Access elements (forward traversal only for singly linked)
570
- * const second = list.at(1);
571
- * console.log(second); // 20;
572
- *
573
- * // SinglyLinkedList allows forward iteration only
574
- * const elements: number[] = [];
575
- * for (const item of list) {
576
- * elements.push(item);
577
- * }
578
- * console.log(elements); // [10, 20, 30, 40];
579
- *
580
- * console.log(list.length); // 4;
377
+ * @example
378
+ * // SinglyLinkedList unshift and forward traversal
379
+ * const list = new SinglyLinkedList<number>([20, 30, 40]);
380
+ *
381
+ * // Unshift adds to the beginning
382
+ * list.unshift(10);
383
+ * console.log([...list]); // [10, 20, 30, 40];
384
+ *
385
+ * // Access elements (forward traversal only for singly linked)
386
+ * const second = list.at(1);
387
+ * console.log(second); // 20;
388
+ *
389
+ * // SinglyLinkedList allows forward iteration only
390
+ * const elements: number[] = [];
391
+ * for (const item of list) {
392
+ * elements.push(item);
393
+ * }
394
+ * console.log(elements); // [10, 20, 30, 40];
395
+ *
396
+ * console.log(list.length); // 4;
581
397
  */
582
-
583
398
  unshift(elementOrNode: E | SinglyLinkedListNode<E>): boolean {
584
399
  const newNode = this._ensureNode(elementOrNode);
585
400
  if (!this.head) {
@@ -598,7 +413,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
598
413
  * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).
599
414
  * @returns Array of per-element success flags.
600
415
  */
601
-
602
416
  pushMany(elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>): boolean[] {
603
417
  const ans: boolean[] = [];
604
418
  for (const el of elements) {
@@ -614,7 +428,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
614
428
  * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).
615
429
  * @returns Array of per-element success flags.
616
430
  */
617
-
618
431
  unshiftMany(elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>): boolean[] {
619
432
  const ans: boolean[] = [];
620
433
  for (const el of elements) {
@@ -630,7 +443,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
630
443
  * @param elementNodeOrPredicate - Element, node, or node predicate to match.
631
444
  * @returns Matched value or undefined.
632
445
  */
633
-
634
446
  search(
635
447
  elementNodeOrPredicate: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)
636
448
  ): E | undefined {
@@ -648,56 +460,13 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
648
460
  * @remarks Time O(N), Space O(1)
649
461
  * @param index - Zero-based index.
650
462
  * @returns Element or undefined.
651
-
652
-
653
-
654
-
655
-
656
-
657
-
658
-
659
-
660
-
661
-
662
-
663
-
664
-
665
-
666
-
667
-
668
-
669
-
670
-
671
-
672
-
673
-
674
-
675
-
676
-
677
-
678
-
679
-
680
-
681
-
682
-
683
-
684
-
685
-
686
-
687
-
688
-
689
-
690
-
691
-
692
-
693
- * @example
694
- * // Access element by index
695
- * const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
696
- * console.log(list.at(0)); // 'a';
697
- * console.log(list.at(2)); // 'c';
698
- * console.log(list.at(3)); // 'd';
463
+ * @example
464
+ * // Access element by index
465
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
466
+ * console.log(list.at(0)); // 'a';
467
+ * console.log(list.at(2)); // 'c';
468
+ * console.log(list.at(3)); // 'd';
699
469
  */
700
-
701
470
  at(index: number): E | undefined {
702
471
  if (index < 0 || index >= this._length) return undefined;
703
472
  let current = this.head;
@@ -711,7 +480,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
711
480
  * @param elementNodeOrPredicate - Element, node, or predicate.
712
481
  * @returns True if the value is a SinglyLinkedListNode.
713
482
  */
714
-
715
483
  isNode(
716
484
  elementNodeOrPredicate: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)
717
485
  ): elementNodeOrPredicate is SinglyLinkedListNode<E> {
@@ -723,51 +491,11 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
723
491
  * @remarks Time O(N), Space O(1)
724
492
  * @param index - Zero-based index.
725
493
  * @returns Node or undefined.
726
-
727
-
728
-
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
-
760
-
761
-
762
-
763
-
764
-
765
- * @example
766
- * // Get node at index
767
- * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
768
- * console.log(list.getNodeAt(1)?.value); // 'b';
494
+ * @example
495
+ * // Get node at index
496
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
497
+ * console.log(list.getNodeAt(1)?.value); // 'b';
769
498
  */
770
-
771
499
  getNodeAt(index: number): SinglyLinkedListNode<E> | undefined {
772
500
  if (index < 0 || index >= this._length) return undefined;
773
501
  let current = this.head;
@@ -780,52 +508,12 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
780
508
  * @remarks Time O(N), Space O(1)
781
509
  * @param index - Zero-based index.
782
510
  * @returns Removed element or undefined.
783
-
784
-
785
-
786
-
787
-
788
-
789
-
790
-
791
-
792
-
793
-
794
-
795
-
796
-
797
-
798
-
799
-
800
-
801
-
802
-
803
-
804
-
805
-
806
-
807
-
808
-
809
-
810
-
811
-
812
-
813
-
814
-
815
-
816
-
817
-
818
-
819
-
820
-
821
-
822
- * @example
823
- * // Remove by index
824
- * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
825
- * list.deleteAt(1);
826
- * console.log(list.toArray()); // ['a', 'c'];
511
+ * @example
512
+ * // Remove by index
513
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
514
+ * list.deleteAt(1);
515
+ * console.log(list.toArray()); // ['a', 'c'];
827
516
  */
828
-
829
517
  deleteAt(index: number): E | undefined {
830
518
  if (index < 0 || index >= this._length) return undefined;
831
519
  if (index === 0) return this.shift();
@@ -843,58 +531,17 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
843
531
  * @remarks Time O(N), Space O(1)
844
532
  * @param [elementOrNode] - Element or node to remove; if omitted/undefined, nothing happens.
845
533
  * @returns True if removed.
846
-
847
-
848
-
849
-
850
-
851
-
852
-
853
-
854
-
855
-
856
-
857
-
858
-
859
-
860
-
861
-
862
-
863
-
864
-
865
-
866
-
867
-
868
-
869
-
870
-
871
-
872
-
873
-
874
-
875
-
876
-
877
-
878
-
879
-
880
-
881
-
882
-
883
-
884
-
885
- * @example
886
- * // Remove first occurrence
887
- * const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
888
- * list.delete(2);
889
- * console.log(list.toArray()); // [1, 3, 2];
534
+ * @example
535
+ * // Remove first occurrence
536
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
537
+ * list.delete(2);
538
+ * console.log(list.toArray()); // [1, 3, 2];
890
539
  */
891
-
892
540
  delete(elementOrNode: E | SinglyLinkedListNode<E> | undefined): boolean {
893
541
  if (elementOrNode === undefined || !this.head) return false;
894
542
  const node = this.isNode(elementOrNode) ? elementOrNode : this.getNode(elementOrNode);
895
543
  if (!node) return false;
896
544
  const prevNode = this._getPrevNode(node);
897
-
898
545
  if (!prevNode) {
899
546
  this._head = node.next;
900
547
  if (node === this.tail) this._tail = undefined;
@@ -912,52 +559,12 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
912
559
  * @param index - Zero-based index.
913
560
  * @param newElementOrNode - Element or node to insert.
914
561
  * @returns True if inserted.
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
-
944
-
945
-
946
-
947
-
948
-
949
-
950
-
951
-
952
-
953
-
954
- * @example
955
- * // Insert at index
956
- * const list = new SinglyLinkedList<number>([1, 3]);
957
- * list.addAt(1, 2);
958
- * console.log(list.toArray()); // [1, 2, 3];
562
+ * @example
563
+ * // Insert at index
564
+ * const list = new SinglyLinkedList<number>([1, 3]);
565
+ * list.addAt(1, 2);
566
+ * console.log(list.toArray()); // [1, 2, 3];
959
567
  */
960
-
961
568
  addAt(index: number, newElementOrNode: E | SinglyLinkedListNode<E>): boolean {
962
569
  if (index < 0 || index > this._length) return false;
963
570
  if (index === 0) return this.unshift(newElementOrNode);
@@ -977,7 +584,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
977
584
  * @param value - New value.
978
585
  * @returns True if updated.
979
586
  */
980
-
981
587
  setAt(index: number, value: E): boolean {
982
588
  const node = this.getNodeAt(index);
983
589
  if (!node) return false;
@@ -989,51 +595,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
989
595
  * Check whether the list is empty.
990
596
  * @remarks Time O(1), Space O(1)
991
597
  * @returns True if length is 0.
992
-
993
-
994
-
995
-
996
-
997
-
998
-
999
-
1000
-
1001
-
1002
-
1003
-
1004
-
1005
-
1006
-
1007
-
1008
-
1009
-
1010
-
1011
-
1012
-
1013
-
1014
-
1015
-
1016
-
1017
-
1018
-
1019
-
1020
-
1021
-
1022
-
1023
-
1024
-
1025
-
1026
-
1027
-
1028
-
1029
-
1030
-
1031
-
1032
- * @example
1033
- * // Check empty
1034
- * console.log(new SinglyLinkedList().isEmpty()); // true;
598
+ * @example
599
+ * // Check empty
600
+ * console.log(new SinglyLinkedList().isEmpty()); // true;
1035
601
  */
1036
-
1037
602
  isEmpty(): boolean {
1038
603
  return this._length === 0;
1039
604
  }
@@ -1042,53 +607,12 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1042
607
  * Remove all nodes and reset length.
1043
608
  * @remarks Time O(N), Space O(1)
1044
609
  * @returns void
1045
-
1046
-
1047
-
1048
-
1049
-
1050
-
1051
-
1052
-
1053
-
1054
-
1055
-
1056
-
1057
-
1058
-
1059
-
1060
-
1061
-
1062
-
1063
-
1064
-
1065
-
1066
-
1067
-
1068
-
1069
-
1070
-
1071
-
1072
-
1073
-
1074
-
1075
-
1076
-
1077
-
1078
-
1079
-
1080
-
1081
-
1082
-
1083
-
1084
-
1085
- * @example
1086
- * // Remove all
1087
- * const list = new SinglyLinkedList<number>([1, 2, 3]);
1088
- * list.clear();
1089
- * console.log(list.isEmpty()); // true;
610
+ * @example
611
+ * // Remove all
612
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
613
+ * list.clear();
614
+ * console.log(list.isEmpty()); // true;
1090
615
  */
1091
-
1092
616
  clear(): void {
1093
617
  this._head = undefined;
1094
618
  this._tail = undefined;
@@ -1099,55 +623,12 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1099
623
  * Reverse the list in place.
1100
624
  * @remarks Time O(N), Space O(1)
1101
625
  * @returns This list.
1102
-
1103
-
1104
-
1105
-
1106
-
1107
-
1108
-
1109
-
1110
-
1111
-
1112
-
1113
-
1114
-
1115
-
1116
-
1117
-
1118
-
1119
-
1120
-
1121
-
1122
-
1123
-
1124
-
1125
-
1126
-
1127
-
1128
-
1129
-
1130
-
1131
-
1132
-
1133
-
1134
-
1135
-
1136
-
1137
-
1138
-
1139
-
1140
-
1141
-
1142
-
1143
-
1144
- * @example
1145
- * // Reverse the list in-place
1146
- * const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
1147
- * list.reverse();
1148
- * console.log([...list]); // [4, 3, 2, 1];
626
+ * @example
627
+ * // Reverse the list in-place
628
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
629
+ * list.reverse();
630
+ * console.log([...list]); // [4, 3, 2, 1];
1149
631
  */
1150
-
1151
632
  reverse(): this {
1152
633
  if (!this.head || this.head === this.tail) return this;
1153
634
  let prev: SinglyLinkedListNode<E> | undefined;
@@ -1169,7 +650,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1169
650
  * @param [elementNodeOrPredicate] - Element, node, or node predicate to match.
1170
651
  * @returns Matching node or undefined.
1171
652
  */
1172
-
1173
653
  getNode(
1174
654
  elementNodeOrPredicate: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean) | undefined
1175
655
  ): SinglyLinkedListNode<E> | undefined {
@@ -1191,7 +671,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1191
671
  * @param newElementOrNode - Element or node to insert.
1192
672
  * @returns True if inserted.
1193
673
  */
1194
-
1195
674
  addBefore(
1196
675
  existingElementOrNode: E | SinglyLinkedListNode<E>,
1197
676
  newElementOrNode: E | SinglyLinkedListNode<E>
@@ -1200,7 +679,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1200
679
  if (!existingNode) return false;
1201
680
  const prevNode = this._getPrevNode(existingNode);
1202
681
  const newNode = this._ensureNode(newElementOrNode);
1203
-
1204
682
  if (!prevNode) {
1205
683
  newNode.next = this._head;
1206
684
  this._head = newNode;
@@ -1221,7 +699,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1221
699
  * @param newElementOrNode - Element or node to insert.
1222
700
  * @returns True if inserted.
1223
701
  */
1224
-
1225
702
  addAfter(existingElementOrNode: E | SinglyLinkedListNode<E>, newElementOrNode: E | SinglyLinkedListNode<E>): boolean {
1226
703
  const existingNode = this.getNode(existingElementOrNode);
1227
704
  if (!existingNode) return false;
@@ -1241,16 +718,12 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1241
718
  * @param [items] - Elements to insert after `start`.
1242
719
  * @returns A new list containing the removed elements (typed as `this`).
1243
720
  */
1244
-
1245
721
  override splice(start: number, deleteCount = 0, ...items: E[]): this {
1246
722
  start = Math.max(0, Math.min(start, this.length));
1247
723
  deleteCount = Math.max(0, deleteCount);
1248
-
1249
724
  const removedList = this._createInstance();
1250
-
1251
725
  const prevNode = start === 0 ? undefined : this.getNodeAt(start - 1);
1252
726
  let cur = prevNode ? prevNode.next : this.head;
1253
-
1254
727
  let removedCount = 0;
1255
728
  while (removedCount < deleteCount && cur) {
1256
729
  removedList.push(cur.value);
@@ -1258,14 +731,12 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1258
731
  removedCount++;
1259
732
  }
1260
733
  const afterNode = cur;
1261
-
1262
734
  if (prevNode) {
1263
735
  prevNode.next = afterNode;
1264
736
  } else {
1265
737
  this._head = afterNode;
1266
738
  }
1267
739
  if (!afterNode) this._tail = prevNode;
1268
-
1269
740
  if (items.length > 0) {
1270
741
  let firstInserted: SinglyLinkedListNode<E> | undefined;
1271
742
  let lastInserted: SinglyLinkedListNode<E> | undefined;
@@ -1277,17 +748,14 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1277
748
  }
1278
749
  if (prevNode) prevNode.next = firstInserted!;
1279
750
  else this._head = firstInserted!;
1280
-
1281
751
  lastInserted!.next = afterNode;
1282
752
  if (!afterNode) this._tail = lastInserted!;
1283
753
  }
1284
-
1285
754
  this._length += items.length - removedCount;
1286
755
  if (this._length === 0) {
1287
756
  this._head = undefined;
1288
757
  this._tail = undefined;
1289
758
  }
1290
-
1291
759
  return removedList as unknown as this;
1292
760
  }
1293
761
 
@@ -1297,7 +765,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1297
765
  * @param elementOrNode - Element, node, or node predicate to match.
1298
766
  * @returns Number of matches in the list.
1299
767
  */
1300
-
1301
768
  countOccurrences(elementOrNode: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)): number {
1302
769
  const predicate = elementOrPredicate(elementOrNode, this._equals);
1303
770
  let count = 0;
@@ -1315,7 +782,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1315
782
  * @param equals - Equality predicate (a, b) → boolean.
1316
783
  * @returns This list.
1317
784
  */
1318
-
1319
785
  setEquality(equals: (a: E, b: E) => boolean): this {
1320
786
  this._equals = equals;
1321
787
  return this;
@@ -1327,7 +793,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1327
793
  * @param predicate - Predicate (value, index, list) → boolean to decide deletion.
1328
794
  * @returns True if a node was removed.
1329
795
  */
1330
-
1331
796
  deleteWhere(predicate: (value: E, index: number, list: this) => boolean): boolean {
1332
797
  let prev: SinglyLinkedListNode<E> | undefined;
1333
798
  let current = this.head;
@@ -1354,55 +819,14 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1354
819
  * Deep clone this list (values are copied by reference).
1355
820
  * @remarks Time O(N), Space O(N)
1356
821
  * @returns A new list with the same element sequence.
1357
-
1358
-
1359
-
1360
-
1361
-
1362
-
1363
-
1364
-
1365
-
1366
-
1367
-
1368
-
1369
-
1370
-
1371
-
1372
-
1373
-
1374
-
1375
-
1376
-
1377
-
1378
-
1379
-
1380
-
1381
-
1382
-
1383
-
1384
-
1385
-
1386
-
1387
-
1388
-
1389
-
1390
-
1391
-
1392
-
1393
-
1394
-
1395
-
1396
-
1397
- * @example
1398
- * // Deep copy
1399
- * const list = new SinglyLinkedList<number>([1, 2, 3]);
1400
- * const copy = list.clone();
1401
- * copy.pop();
1402
- * console.log(list.length); // 3;
1403
- * console.log(copy.length); // 2;
822
+ * @example
823
+ * // Deep copy
824
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
825
+ * const copy = list.clone();
826
+ * copy.pop();
827
+ * console.log(list.length); // 3;
828
+ * console.log(copy.length); // 2;
1404
829
  */
1405
-
1406
830
  clone(): this {
1407
831
  const out = this._createInstance();
1408
832
  for (const v of this) out.push(v);
@@ -1415,65 +839,22 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1415
839
  * @param callback - Predicate (value, index, list) → boolean to keep value.
1416
840
  * @param [thisArg] - Value for `this` inside the callback.
1417
841
  * @returns A new list with kept values.
1418
-
1419
-
1420
-
1421
-
1422
-
1423
-
1424
-
1425
-
1426
-
1427
-
1428
-
1429
-
1430
-
1431
-
1432
-
1433
-
1434
-
1435
-
1436
-
1437
-
1438
-
1439
-
1440
-
1441
-
1442
-
1443
-
1444
-
1445
-
1446
-
1447
-
1448
-
1449
-
1450
-
1451
-
1452
-
1453
-
1454
-
1455
-
1456
-
1457
-
1458
-
1459
-
1460
- * @example
1461
- * // SinglyLinkedList filter and map operations
1462
- * const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
1463
- *
1464
- * // Filter even numbers
1465
- * const filtered = list.filter(value => value % 2 === 0);
1466
- * console.log(filtered.length); // 2;
1467
- *
1468
- * // Map to double values
1469
- * const doubled = list.map(value => value * 2);
1470
- * console.log(doubled.length); // 5;
1471
- *
1472
- * // Use reduce to sum
1473
- * const sum = list.reduce((acc, value) => acc + value, 0);
1474
- * console.log(sum); // 15;
842
+ * @example
843
+ * // SinglyLinkedList filter and map operations
844
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
845
+ *
846
+ * // Filter even numbers
847
+ * const filtered = list.filter(value => value % 2 === 0);
848
+ * console.log(filtered.length); // 2;
849
+ *
850
+ * // Map to double values
851
+ * const doubled = list.map(value => value * 2);
852
+ * console.log(doubled.length); // 5;
853
+ *
854
+ * // Use reduce to sum
855
+ * const sum = list.reduce((acc, value) => acc + value, 0);
856
+ * console.log(sum); // 15;
1475
857
  */
1476
-
1477
858
  filter(callback: ElementCallback<E, R, boolean>, thisArg?: unknown): this {
1478
859
  const out = this._createInstance();
1479
860
  let index = 0;
@@ -1488,7 +869,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1488
869
  * @param [thisArg] - Value for `this` inside the callback.
1489
870
  * @returns A new list with mapped values.
1490
871
  */
1491
-
1492
872
  mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this {
1493
873
  const out = this._createInstance();
1494
874
  let index = 0;
@@ -1508,55 +888,12 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1508
888
  * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
1509
889
  * @param [thisArg] - Value for `this` inside the callback.
1510
890
  * @returns A new SinglyLinkedList with mapped values.
1511
-
1512
-
1513
-
1514
-
1515
-
1516
-
1517
-
1518
-
1519
-
1520
-
1521
-
1522
-
1523
-
1524
-
1525
-
1526
-
1527
-
1528
-
1529
-
1530
-
1531
-
1532
-
1533
-
1534
-
1535
-
1536
-
1537
-
1538
-
1539
-
1540
-
1541
-
1542
-
1543
-
1544
-
1545
-
1546
-
1547
-
1548
-
1549
-
1550
-
1551
-
1552
-
1553
- * @example
1554
- * // Transform elements
1555
- * const list = new SinglyLinkedList<number>([1, 2, 3]);
1556
- * const doubled = list.map(n => n * 2);
1557
- * console.log([...doubled]); // [2, 4, 6];
891
+ * @example
892
+ * // Transform elements
893
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
894
+ * const doubled = list.map(n => n * 2);
895
+ * console.log([...doubled]); // [2, 4, 6];
1558
896
  */
1559
-
1560
897
  map<EM, RM = any>(
1561
898
  callback: ElementCallback<E, R, EM>,
1562
899
  options?: SinglyLinkedListOptions<EM, RM>,
@@ -1568,13 +905,14 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1568
905
  return out;
1569
906
  }
1570
907
 
908
+ protected _equals: (a: E, b: E) => boolean = (a, b) => Object.is(a, b);
909
+
1571
910
  /**
1572
911
  * (Protected) Create a node from a value.
1573
912
  * @remarks Time O(1), Space O(1)
1574
913
  * @param value - Value to wrap in a node.
1575
914
  * @returns A new SinglyLinkedListNode instance.
1576
915
  */
1577
-
1578
916
  protected createNode(value: E): SinglyLinkedListNode<E> {
1579
917
  return new SinglyLinkedListNode<E>(value);
1580
918
  }
@@ -1585,7 +923,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1585
923
  * @param elementNodeOrPredicate - Element, node, or node predicate.
1586
924
  * @returns True if input is a predicate function.
1587
925
  */
1588
-
1589
926
  protected _isPredicate(
1590
927
  elementNodeOrPredicate: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)
1591
928
  ): elementNodeOrPredicate is (node: SinglyLinkedListNode<E>) => boolean {
@@ -1598,7 +935,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1598
935
  * @param elementOrNode - Element or node.
1599
936
  * @returns A SinglyLinkedListNode for the provided input.
1600
937
  */
1601
-
1602
938
  protected _ensureNode(elementOrNode: E | SinglyLinkedListNode<E>) {
1603
939
  if (this.isNode(elementOrNode)) return elementOrNode;
1604
940
  return this.createNode(elementOrNode);
@@ -1610,7 +946,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1610
946
  * @param elementNodeOrPredicate - Element, node, or predicate.
1611
947
  * @returns A predicate taking a node and returning true/false.
1612
948
  */
1613
-
1614
949
  protected _ensurePredicate(
1615
950
  elementNodeOrPredicate: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)
1616
951
  ) {
@@ -1626,7 +961,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1626
961
  * @param node - A node in the list.
1627
962
  * @returns Previous node or undefined.
1628
963
  */
1629
-
1630
964
  protected _getPrevNode(node: SinglyLinkedListNode<E>): SinglyLinkedListNode<E> | undefined {
1631
965
  if (!this.head || this.head === node) return undefined;
1632
966
  let current = this.head;
@@ -1639,7 +973,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1639
973
  * @remarks Time O(N), Space O(1)
1640
974
  * @returns Iterator of values (E).
1641
975
  */
1642
-
1643
976
  protected *_getIterator(): IterableIterator<E> {
1644
977
  let current = this.head;
1645
978
  while (current) {
@@ -1653,7 +986,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1653
986
  * @remarks Time O(N), Space O(N)
1654
987
  * @returns Iterator of values (E).
1655
988
  */
1656
-
1657
989
  protected *_getReverseIterator(): IterableIterator<E> {
1658
990
  const reversedArr = [...this].reverse();
1659
991
  for (const item of reversedArr) yield item;
@@ -1664,7 +996,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1664
996
  * @remarks Time O(N), Space O(1)
1665
997
  * @returns Iterator of nodes.
1666
998
  */
1667
-
1668
999
  protected *_getNodeIterator(): IterableIterator<SinglyLinkedListNode<E>> {
1669
1000
  let current = this.head;
1670
1001
  while (current) {
@@ -1679,7 +1010,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1679
1010
  * @param [options] - Options forwarded to the constructor.
1680
1011
  * @returns An empty like-kind list instance.
1681
1012
  */
1682
-
1683
1013
  protected _createInstance(options?: SinglyLinkedListOptions<E, R>): this {
1684
1014
  const Ctor = this.constructor as new (
1685
1015
  elements?: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>,
@@ -1697,7 +1027,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1697
1027
  * @param [options] - Options forwarded to the constructor.
1698
1028
  * @returns A like-kind SinglyLinkedList instance.
1699
1029
  */
1700
-
1701
1030
  protected _createLike<EM, RM>(
1702
1031
  elements: Iterable<EM> | Iterable<RM> | Iterable<SinglyLinkedListNode<EM>> = [],
1703
1032
  options?: SinglyLinkedListOptions<EM, RM>
@@ -1717,7 +1046,6 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1717
1046
  * @param [options] - Options forwarded to the constructor.
1718
1047
  * @returns An empty like-kind SinglyLinkedList instance.
1719
1048
  */
1720
-
1721
1049
  protected _spawnLike<EM, RM>(options?: SinglyLinkedListOptions<EM, RM>): SinglyLinkedList<EM, RM> {
1722
1050
  return this._createLike<EM, RM>([], options);
1723
1051
  }