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
@@ -370,7 +370,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
370
370
  addAfter(existingElementOrNode, newElementOrNode): boolean;
371
371
  ```
372
372
 
373
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:829](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L829)
373
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:850](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L850)
374
374
 
375
375
  Insert a new element/node after an existing one.
376
376
 
@@ -410,7 +410,7 @@ Time O(N), Space O(1)
410
410
  addAt(index, newElementOrNode): boolean;
411
411
  ```
412
412
 
413
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:778](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L778)
413
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:799](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L799)
414
414
 
415
415
  Insert a new element/node at an index, shifting following nodes.
416
416
 
@@ -461,7 +461,7 @@ Time O(N), Space O(1)
461
461
  addBefore(existingElementOrNode, newElementOrNode): boolean;
462
462
  ```
463
463
 
464
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:802](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L802)
464
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:823](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L823)
465
465
 
466
466
  Insert a new element/node before an existing one.
467
467
 
@@ -501,7 +501,7 @@ Time O(N), Space O(1)
501
501
  at(index): E | undefined;
502
502
  ```
503
503
 
504
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:629](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L629)
504
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:644](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L644)
505
505
 
506
506
  Get the element at a given index.
507
507
 
@@ -546,7 +546,7 @@ Time O(N), Space O(1)
546
546
  clear(): void;
547
547
  ```
548
548
 
549
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1084](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1084)
549
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1117](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1117)
550
550
 
551
551
  Remove all nodes and reset length.
552
552
 
@@ -583,7 +583,7 @@ Time O(N), Space O(1)
583
583
  clone(): this;
584
584
  ```
585
585
 
586
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1353](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1353)
586
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1435](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1435)
587
587
 
588
588
  Deep clone this list (values are copied by reference).
589
589
 
@@ -621,7 +621,7 @@ Time O(N), Space O(N)
621
621
  concat(...items): this;
622
622
  ```
623
623
 
624
- Defined in: [data-structures/base/linear-base.ts:473](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L473)
624
+ Defined in: [data-structures/base/linear-base.ts:484](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L484)
625
625
 
626
626
  Concatenate lists/elements preserving order.
627
627
 
@@ -657,7 +657,7 @@ Time O(sum(length)), Space O(sum(length))
657
657
  delete(elementOrNode?): boolean;
658
658
  ```
659
659
 
660
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:970](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L970)
660
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:997](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L997)
661
661
 
662
662
  Delete the first match by value/node.
663
663
 
@@ -702,7 +702,7 @@ Time O(N), Space O(1)
702
702
  deleteAt(index): E | undefined;
703
703
  ```
704
704
 
705
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:908](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L908)
705
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:932](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L932)
706
706
 
707
707
  Delete the element at an index.
708
708
 
@@ -747,7 +747,7 @@ Time O(N), Space O(1)
747
747
  deleteWhere(predicate): boolean;
748
748
  ```
749
749
 
750
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1278](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1278)
750
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1357](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1357)
751
751
 
752
752
  Delete the first element that satisfies a predicate.
753
753
 
@@ -771,6 +771,30 @@ Time O(N), Space O(1)
771
771
 
772
772
  ***
773
773
 
774
+ ### entries()
775
+
776
+ ```ts
777
+ entries(): IterableIterator<[number, E]>;
778
+ ```
779
+
780
+ Defined in: [data-structures/base/iterable-element-base.ts:208](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L208)
781
+
782
+ Return an iterator of `[index, value]` pairs (Array-compatible).
783
+
784
+ #### Returns
785
+
786
+ `IterableIterator`\<\[`number`, `E`\]\>
787
+
788
+ #### Remarks
789
+
790
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
791
+
792
+ #### Inherited from
793
+
794
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`entries`](LinearLinkedBase.md#entries)
795
+
796
+ ***
797
+
774
798
  ### every()
775
799
 
776
800
  ```ts
@@ -866,7 +890,7 @@ Time O(n), Space O(1)
866
890
  filter(callback, thisArg?): this;
867
891
  ```
868
892
 
869
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1411](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1411)
893
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1496](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1496)
870
894
 
871
895
  Filter values into a new list of the same class.
872
896
 
@@ -1041,6 +1065,80 @@ Time O(n), Space O(1)
1041
1065
 
1042
1066
  ***
1043
1067
 
1068
+ ### findLast()
1069
+
1070
+ ```ts
1071
+ findLast(elementNodeOrPredicate): E | undefined;
1072
+ ```
1073
+
1074
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1258](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1258)
1075
+
1076
+ Find the first value matching a predicate scanning backward (tail → head).
1077
+
1078
+ #### Parameters
1079
+
1080
+ ##### elementNodeOrPredicate
1081
+
1082
+ \| `E`
1083
+ \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
1084
+ \| ((`node`) => `boolean`)
1085
+
1086
+ Element, node, or predicate to match.
1087
+
1088
+ #### Returns
1089
+
1090
+ `E` \| `undefined`
1091
+
1092
+ Matching value or undefined.
1093
+
1094
+ *
1095
+
1096
+ #### Remarks
1097
+
1098
+ Time O(N), Space O(1)
1099
+
1100
+ #### Example
1101
+
1102
+ ```ts
1103
+ // Find value scanning from tail
1104
+ const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
1105
+ // findLast scans from tail to head, returns first match
1106
+ const found = list.findLast(node => node.value < 4);
1107
+ console.log(found); // 3;
1108
+ ```
1109
+
1110
+ ***
1111
+
1112
+ ### findLastIndex()
1113
+
1114
+ ```ts
1115
+ findLastIndex(predicate): number;
1116
+ ```
1117
+
1118
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1276](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1276)
1119
+
1120
+ Find the index of the last value matching a predicate (scans tail → head).
1121
+
1122
+ #### Parameters
1123
+
1124
+ ##### predicate
1125
+
1126
+ (`value`, `index`, `list`) => `boolean`
1127
+
1128
+ Function called with (value, index, list).
1129
+
1130
+ #### Returns
1131
+
1132
+ `number`
1133
+
1134
+ Matching index, or -1 if not found.
1135
+
1136
+ #### Remarks
1137
+
1138
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1).
1139
+
1140
+ ***
1141
+
1044
1142
  ### forEach()
1045
1143
 
1046
1144
  ```ts
@@ -1081,15 +1179,13 @@ Time O(n), Space O(1).
1081
1179
 
1082
1180
  ***
1083
1181
 
1084
- ### getBackward()
1182
+ ### ~~getBackward()~~
1085
1183
 
1086
1184
  ```ts
1087
1185
  getBackward(elementNodeOrPredicate): E | undefined;
1088
1186
  ```
1089
1187
 
1090
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1199](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1199)
1091
-
1092
- Find the first value matching a predicate scanning backward.
1188
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1238](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1238)
1093
1189
 
1094
1190
  #### Parameters
1095
1191
 
@@ -1099,29 +1195,13 @@ Find the first value matching a predicate scanning backward.
1099
1195
  \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
1100
1196
  \| ((`node`) => `boolean`)
1101
1197
 
1102
- Element, node, or predicate to match.
1103
-
1104
1198
  #### Returns
1105
1199
 
1106
1200
  `E` \| `undefined`
1107
1201
 
1108
- Matched value or undefined.
1109
-
1110
- *
1111
-
1112
- #### Remarks
1113
-
1114
- Time O(N), Space O(1)
1115
-
1116
- #### Example
1202
+ #### Deprecated
1117
1203
 
1118
- ```ts
1119
- // Find value scanning from tail
1120
- const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
1121
- // getBackward scans from tail to head, returns first match
1122
- const found = list.getBackward(node => node.value < 4);
1123
- console.log(found); // 3;
1124
- ```
1204
+ Use `findLast` instead. Will be removed in a future major version.
1125
1205
 
1126
1206
  ***
1127
1207
 
@@ -1131,7 +1211,7 @@ Time O(N), Space O(1)
1131
1211
  getNode(elementNodeOrPredicate?): DoublyLinkedListNode<E> | undefined;
1132
1212
  ```
1133
1213
 
1134
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:697](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L697)
1214
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:715](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L715)
1135
1215
 
1136
1216
  Find a node by value, reference, or predicate.
1137
1217
 
@@ -1163,7 +1243,7 @@ Time O(N), Space O(1)
1163
1243
  getNodeAt(index): DoublyLinkedListNode<E> | undefined;
1164
1244
  ```
1165
1245
 
1166
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:683](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L683)
1246
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:701](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L701)
1167
1247
 
1168
1248
  Get the node reference at a given index.
1169
1249
 
@@ -1235,13 +1315,47 @@ Time O(n) in the worst case. Space O(1).
1235
1315
 
1236
1316
  ***
1237
1317
 
1318
+ ### includes()
1319
+
1320
+ ```ts
1321
+ includes(element): boolean;
1322
+ ```
1323
+
1324
+ Defined in: [data-structures/base/iterable-element-base.ts:200](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L200)
1325
+
1326
+ Check whether a value exists (Array-compatible alias for `has`).
1327
+
1328
+ #### Parameters
1329
+
1330
+ ##### element
1331
+
1332
+ `E`
1333
+
1334
+ Element to search for (uses `===`).
1335
+
1336
+ #### Returns
1337
+
1338
+ `boolean`
1339
+
1340
+ `true` if found.
1341
+
1342
+ #### Remarks
1343
+
1344
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1).
1345
+
1346
+ #### Inherited from
1347
+
1348
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`includes`](LinearLinkedBase.md#includes)
1349
+
1350
+ ***
1351
+
1238
1352
  ### indexOf()
1239
1353
 
1240
1354
  ```ts
1241
1355
  indexOf(searchElement, fromIndex?): number;
1242
1356
  ```
1243
1357
 
1244
- Defined in: [data-structures/base/linear-base.ts:422](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L422)
1358
+ Defined in: [data-structures/base/linear-base.ts:433](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L433)
1245
1359
 
1246
1360
  Linked-list optimized `indexOf` (forwards scan).
1247
1361
 
@@ -1281,7 +1395,7 @@ Time O(n), Space O(1)
1281
1395
  isEmpty(): boolean;
1282
1396
  ```
1283
1397
 
1284
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1032](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1032)
1398
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1062](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1062)
1285
1399
 
1286
1400
  Check whether the list is empty.
1287
1401
 
@@ -1376,13 +1490,37 @@ Time O(n), Space O(n)
1376
1490
 
1377
1491
  ***
1378
1492
 
1493
+ ### keys()
1494
+
1495
+ ```ts
1496
+ keys(): IterableIterator<number>;
1497
+ ```
1498
+
1499
+ Defined in: [data-structures/base/iterable-element-base.ts:219](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L219)
1500
+
1501
+ Return an iterator of numeric indices (Array-compatible).
1502
+
1503
+ #### Returns
1504
+
1505
+ `IterableIterator`\<`number`\>
1506
+
1507
+ #### Remarks
1508
+
1509
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
1510
+
1511
+ #### Inherited from
1512
+
1513
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`keys`](LinearLinkedBase.md#keys)
1514
+
1515
+ ***
1516
+
1379
1517
  ### lastIndexOf()
1380
1518
 
1381
1519
  ```ts
1382
1520
  lastIndexOf(searchElement, fromIndex?): number;
1383
1521
  ```
1384
1522
 
1385
- Defined in: [data-structures/base/linear-base.ts:448](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L448)
1523
+ Defined in: [data-structures/base/linear-base.ts:459](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L459)
1386
1524
 
1387
1525
  Linked-list optimized `lastIndexOf` (reverse scan).
1388
1526
 
@@ -1425,7 +1563,7 @@ map<EM, RM>(
1425
1563
  thisArg?): DoublyLinkedList<EM, RM>;
1426
1564
  ```
1427
1565
 
1428
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1500](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1500)
1566
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1588](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1588)
1429
1567
 
1430
1568
  Map values into a new list (possibly different element type).
1431
1569
 
@@ -1501,7 +1639,7 @@ Time O(N), Space O(N)
1501
1639
  mapSame(callback, thisArg?): this;
1502
1640
  ```
1503
1641
 
1504
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1426](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1426)
1642
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1511](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1511)
1505
1643
 
1506
1644
  Map values into a new list of the same class.
1507
1645
 
@@ -1541,7 +1679,7 @@ Time O(N), Space O(N)
1541
1679
  pop(): E | undefined;
1542
1680
  ```
1543
1681
 
1544
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:402](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L402)
1682
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:408](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L408)
1545
1683
 
1546
1684
  Remove and return the tail element.
1547
1685
 
@@ -1584,7 +1722,7 @@ Time O(1), Space O(1)
1584
1722
  print(): void;
1585
1723
  ```
1586
1724
 
1587
- Defined in: [data-structures/base/iterable-element-base.ts:269](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L269)
1725
+ Defined in: [data-structures/base/iterable-element-base.ts:301](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L301)
1588
1726
 
1589
1727
  Prints `toVisual()` to the console. Intended for quick debugging.
1590
1728
 
@@ -1610,7 +1748,7 @@ Time O(n) due to materialization, Space O(n) for the intermediate representation
1610
1748
  push(elementOrNode): boolean;
1611
1749
  ```
1612
1750
 
1613
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:327](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L327)
1751
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:330](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L330)
1614
1752
 
1615
1753
  Append an element/node to the tail.
1616
1754
 
@@ -1665,7 +1803,7 @@ Time O(1), Space O(1)
1665
1803
  pushMany(elements): boolean[];
1666
1804
  ```
1667
1805
 
1668
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:553](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L553)
1806
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:565](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L565)
1669
1807
 
1670
1808
  Append a sequence of elements/nodes.
1671
1809
 
@@ -1733,7 +1871,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
1733
1871
  reduce(callbackfn): E;
1734
1872
  ```
1735
1873
 
1736
- Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L194)
1874
+ Defined in: [data-structures/base/iterable-element-base.ts:226](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L226)
1737
1875
 
1738
1876
  ##### Parameters
1739
1877
 
@@ -1755,7 +1893,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
1755
1893
  reduce(callbackfn, initialValue): E;
1756
1894
  ```
1757
1895
 
1758
- Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L195)
1896
+ Defined in: [data-structures/base/iterable-element-base.ts:227](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L227)
1759
1897
 
1760
1898
  ##### Parameters
1761
1899
 
@@ -1781,7 +1919,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
1781
1919
  reduce<U>(callbackfn, initialValue): U;
1782
1920
  ```
1783
1921
 
1784
- Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L196)
1922
+ Defined in: [data-structures/base/iterable-element-base.ts:228](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L228)
1785
1923
 
1786
1924
  ##### Type Parameters
1787
1925
 
@@ -1815,7 +1953,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
1815
1953
  reduceRight<U>(callbackfn, initialValue): U;
1816
1954
  ```
1817
1955
 
1818
- Defined in: [data-structures/base/linear-base.ts:574](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L574)
1956
+ Defined in: [data-structures/base/linear-base.ts:585](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L585)
1819
1957
 
1820
1958
  Right-to-left reduction using reverse iterator.
1821
1959
 
@@ -1861,7 +1999,7 @@ Time O(n), Space O(1)
1861
1999
  reverse(): this;
1862
2000
  ```
1863
2001
 
1864
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1261](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1261)
2002
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1340](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1340)
1865
2003
 
1866
2004
  Reverse the list in place.
1867
2005
 
@@ -1898,7 +2036,7 @@ Time O(N), Space O(1)
1898
2036
  search(elementNodeOrPredicate): E | undefined;
1899
2037
  ```
1900
2038
 
1901
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1138](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1138)
2039
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1174](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1174)
1902
2040
 
1903
2041
  Find the first value matching a predicate scanning forward.
1904
2042
 
@@ -1941,7 +2079,7 @@ Time O(N), Space O(1)
1941
2079
  setAt(index, value): boolean;
1942
2080
  ```
1943
2081
 
1944
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:853](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L853)
2082
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:874](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L874)
1945
2083
 
1946
2084
  Set the element value at an index.
1947
2085
 
@@ -1981,7 +2119,7 @@ Time O(N), Space O(1)
1981
2119
  setEquality(equals): this;
1982
2120
  ```
1983
2121
 
1984
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1299](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1299)
2122
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1378](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1378)
1985
2123
 
1986
2124
  Set the equality comparator used to compare values.
1987
2125
 
@@ -2011,7 +2149,7 @@ Time O(1), Space O(1)
2011
2149
  shift(): E | undefined;
2012
2150
  ```
2013
2151
 
2014
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:466](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L466)
2152
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:475](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L475)
2015
2153
 
2016
2154
  Remove and return the head element.
2017
2155
 
@@ -2044,7 +2182,7 @@ Time O(1), Space O(1)
2044
2182
  slice(start?, end?): this;
2045
2183
  ```
2046
2184
 
2047
- Defined in: [data-structures/base/linear-base.ts:494](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L494)
2185
+ Defined in: [data-structures/base/linear-base.ts:505](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L505)
2048
2186
 
2049
2187
  Slice via forward iteration (no random access required).
2050
2188
 
@@ -2161,7 +2299,7 @@ splice(
2161
2299
  items): this;
2162
2300
  ```
2163
2301
 
2164
- Defined in: [data-structures/base/linear-base.ts:522](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L522)
2302
+ Defined in: [data-structures/base/linear-base.ts:533](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L533)
2165
2303
 
2166
2304
  Splice by walking node iterators from the start index.
2167
2305
 
@@ -2207,7 +2345,7 @@ Time O(n + m), Space O(min(n, m)) where `m = items.length`
2207
2345
  toArray(): E[];
2208
2346
  ```
2209
2347
 
2210
- Defined in: [data-structures/base/iterable-element-base.ts:246](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L246)
2348
+ Defined in: [data-structures/base/iterable-element-base.ts:278](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L278)
2211
2349
 
2212
2350
  Materializes the elements into a new array.
2213
2351
 
@@ -2227,6 +2365,32 @@ Time O(n), Space O(n).
2227
2365
 
2228
2366
  ***
2229
2367
 
2368
+ ### toReversed()
2369
+
2370
+ ```ts
2371
+ toReversed(): this;
2372
+ ```
2373
+
2374
+ Defined in: [data-structures/base/linear-base.ts:335](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L335)
2375
+
2376
+ Return a new instance of the same type with elements in reverse order (non-mutating).
2377
+
2378
+ #### Returns
2379
+
2380
+ `this`
2381
+
2382
+ A new reversed instance.
2383
+
2384
+ #### Remarks
2385
+
2386
+ Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
2387
+
2388
+ #### Inherited from
2389
+
2390
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`toReversed`](LinearLinkedBase.md#toreversed)
2391
+
2392
+ ***
2393
+
2230
2394
  ### toReversedArray()
2231
2395
 
2232
2396
  ```ts
@@ -2259,7 +2423,7 @@ Time O(n), Space O(n)
2259
2423
  toVisual(): E[];
2260
2424
  ```
2261
2425
 
2262
- Defined in: [data-structures/base/iterable-element-base.ts:258](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L258)
2426
+ Defined in: [data-structures/base/iterable-element-base.ts:290](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L290)
2263
2427
 
2264
2428
  Returns a representation of the structure suitable for quick visualization.
2265
2429
  Defaults to an array of elements; subclasses may override to provide richer visuals.
@@ -2286,7 +2450,7 @@ Time O(n), Space O(n).
2286
2450
  unshift(elementOrNode): boolean;
2287
2451
  ```
2288
2452
 
2289
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:531](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L531)
2453
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:543](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L543)
2290
2454
 
2291
2455
  Prepend an element/node to the head.
2292
2456
 
@@ -2327,7 +2491,7 @@ Time O(1), Space O(1)
2327
2491
  unshiftMany(elements): boolean[];
2328
2492
  ```
2329
2493
 
2330
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:569](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L569)
2494
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:581](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L581)
2331
2495
 
2332
2496
  Prepend a sequence of elements/nodes.
2333
2497
 
@@ -2464,7 +2628,7 @@ Time O(1), Space O(1).
2464
2628
  protected _createInstance(options?): this;
2465
2629
  ```
2466
2630
 
2467
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1562](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1562)
2631
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1650](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1650)
2468
2632
 
2469
2633
  (Protected) Create an empty instance of the same concrete class.
2470
2634
 
@@ -2498,7 +2662,7 @@ Time O(1), Space O(1)
2498
2662
  protected _createLike<EM, RM>(elements?, options?): DoublyLinkedList<EM, RM>;
2499
2663
  ```
2500
2664
 
2501
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1580](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1580)
2665
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1668](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1668)
2502
2666
 
2503
2667
  (Protected) Create a like-kind instance and seed it from an iterable.
2504
2668
 
@@ -2546,7 +2710,7 @@ Time O(N), Space O(N)
2546
2710
  protected _ensureNode(elementOrNode): DoublyLinkedListNode<E>;
2547
2711
  ```
2548
2712
 
2549
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1518](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1518)
2713
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1606](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1606)
2550
2714
 
2551
2715
  (Protected) Create or return a node for the given input (node or raw element).
2552
2716
 
@@ -2576,7 +2740,7 @@ Time O(1), Space O(1)
2576
2740
  protected _ensurePredicate(elementNodeOrPredicate): (node) => boolean;
2577
2741
  ```
2578
2742
 
2579
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1530](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1530)
2743
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1618](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1618)
2580
2744
 
2581
2745
  (Protected) Normalize input into a predicate over nodes.
2582
2746
 
@@ -2608,7 +2772,7 @@ Time O(1), Space O(1)
2608
2772
  protected _getIterator(): IterableIterator<E>;
2609
2773
  ```
2610
2774
 
2611
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1591](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1591)
2775
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1679](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1679)
2612
2776
 
2613
2777
  Internal iterator factory used by the default iterator.
2614
2778
 
@@ -2634,7 +2798,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
2634
2798
  protected _getNodeIterator(): IterableIterator<DoublyLinkedListNode<E>>;
2635
2799
  ```
2636
2800
 
2637
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1607](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1607)
2801
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1695](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1695)
2638
2802
 
2639
2803
  Iterate linked nodes from head to tail.
2640
2804
 
@@ -2660,7 +2824,7 @@ Time O(n), Space O(1)
2660
2824
  protected _getPrevNode(node): DoublyLinkedListNode<E> | undefined;
2661
2825
  ```
2662
2826
 
2663
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1551](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1551)
2827
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1639](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1639)
2664
2828
 
2665
2829
  (Protected) Get the previous node of a given node.
2666
2830
 
@@ -2694,7 +2858,7 @@ Time O(1), Space O(1)
2694
2858
  protected _getReverseIterator(): IterableIterator<E>;
2695
2859
  ```
2696
2860
 
2697
- Defined in: [data-structures/linked-list/doubly-linked-list.ts:1599](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1599)
2861
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1687](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L1687)
2698
2862
 
2699
2863
  Reverse-direction iterator over elements.
2700
2864