data-structure-typed 2.5.0 → 2.5.2

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 (246) hide show
  1. package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +12984 -0
  2. package/.vitepress/cache/deps_temp_51f5f1b0/package.json +3 -0
  3. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +4505 -0
  4. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +9731 -0
  5. package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +347 -0
  6. package/CHANGELOG.md +5 -1
  7. package/README.md +124 -29
  8. package/dist/cjs/binary-tree.cjs +26282 -0
  9. package/dist/cjs/graph.cjs +5422 -0
  10. package/dist/cjs/hash.cjs +1310 -0
  11. package/dist/cjs/heap.cjs +1602 -0
  12. package/dist/cjs/index.cjs +31257 -14673
  13. package/dist/cjs/linked-list.cjs +4576 -0
  14. package/dist/cjs/matrix.cjs +1080 -0
  15. package/dist/cjs/priority-queue.cjs +1376 -0
  16. package/dist/cjs/queue.cjs +4264 -0
  17. package/dist/cjs/stack.cjs +907 -0
  18. package/dist/cjs/trie.cjs +1223 -0
  19. package/dist/cjs-legacy/binary-tree.cjs +26319 -0
  20. package/dist/cjs-legacy/graph.cjs +5420 -0
  21. package/dist/cjs-legacy/hash.cjs +1310 -0
  22. package/dist/cjs-legacy/heap.cjs +1599 -0
  23. package/dist/cjs-legacy/index.cjs +31268 -14679
  24. package/dist/cjs-legacy/linked-list.cjs +4582 -0
  25. package/dist/cjs-legacy/matrix.cjs +1083 -0
  26. package/dist/cjs-legacy/priority-queue.cjs +1374 -0
  27. package/dist/cjs-legacy/queue.cjs +4262 -0
  28. package/dist/cjs-legacy/stack.cjs +907 -0
  29. package/dist/cjs-legacy/trie.cjs +1222 -0
  30. package/dist/esm/binary-tree.mjs +26267 -0
  31. package/dist/esm/graph.mjs +5409 -0
  32. package/dist/esm/hash.mjs +1307 -0
  33. package/dist/esm/heap.mjs +1596 -0
  34. package/dist/esm/index.mjs +31254 -14674
  35. package/dist/esm/linked-list.mjs +4569 -0
  36. package/dist/esm/matrix.mjs +1076 -0
  37. package/dist/esm/priority-queue.mjs +1372 -0
  38. package/dist/esm/queue.mjs +4260 -0
  39. package/dist/esm/stack.mjs +905 -0
  40. package/dist/esm/trie.mjs +1220 -0
  41. package/dist/esm-legacy/binary-tree.mjs +26304 -0
  42. package/dist/esm-legacy/graph.mjs +5407 -0
  43. package/dist/esm-legacy/hash.mjs +1307 -0
  44. package/dist/esm-legacy/heap.mjs +1593 -0
  45. package/dist/esm-legacy/index.mjs +31265 -14680
  46. package/dist/esm-legacy/linked-list.mjs +4575 -0
  47. package/dist/esm-legacy/matrix.mjs +1079 -0
  48. package/dist/esm-legacy/priority-queue.mjs +1370 -0
  49. package/dist/esm-legacy/queue.mjs +4258 -0
  50. package/dist/esm-legacy/stack.mjs +905 -0
  51. package/dist/esm-legacy/trie.mjs +1219 -0
  52. package/dist/types/common/error.d.ts +9 -0
  53. package/dist/types/common/index.d.ts +1 -1
  54. package/dist/types/data-structures/base/index.d.ts +1 -0
  55. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  56. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  57. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
  58. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
  59. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
  60. package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
  61. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
  62. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
  63. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
  64. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
  65. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
  66. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
  67. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  68. package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
  69. package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
  70. package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
  71. package/dist/types/data-structures/heap/heap.d.ts +336 -0
  72. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
  73. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
  74. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
  75. package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
  76. package/dist/types/data-structures/queue/deque.d.ts +364 -4
  77. package/dist/types/data-structures/queue/queue.d.ts +288 -0
  78. package/dist/types/data-structures/stack/stack.d.ts +240 -0
  79. package/dist/types/data-structures/trie/trie.d.ts +292 -4
  80. package/dist/types/interfaces/graph.d.ts +1 -1
  81. package/dist/types/types/common.d.ts +2 -2
  82. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  83. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  84. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  85. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  86. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  87. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  88. package/dist/types/types/utils/validate-type.d.ts +4 -4
  89. package/dist/umd/data-structure-typed.js +31196 -14608
  90. package/dist/umd/data-structure-typed.min.js +11 -5
  91. package/docs-site-docusaurus/README.md +41 -0
  92. package/docs-site-docusaurus/docs/api/README.md +52 -0
  93. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +6644 -0
  94. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +282 -0
  95. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +2266 -0
  96. package/docs-site-docusaurus/docs/api/classes/BST.md +6293 -0
  97. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +333 -0
  98. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +455 -0
  99. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +4647 -0
  100. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +331 -0
  101. package/docs-site-docusaurus/docs/api/classes/Deque.md +2767 -0
  102. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +2999 -0
  103. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +2685 -0
  104. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +221 -0
  105. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +253 -0
  106. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +21 -0
  107. package/docs-site-docusaurus/docs/api/classes/HashMap.md +1333 -0
  108. package/docs-site-docusaurus/docs/api/classes/Heap.md +1881 -0
  109. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +800 -0
  110. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +644 -0
  111. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +1632 -0
  112. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +1853 -0
  113. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +1108 -0
  114. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +156 -0
  115. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +2824 -0
  116. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +2929 -0
  117. package/docs-site-docusaurus/docs/api/classes/Matrix.md +1026 -0
  118. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +1866 -0
  119. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +1883 -0
  120. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +1879 -0
  121. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +1882 -0
  122. package/docs-site-docusaurus/docs/api/classes/Navigator.md +109 -0
  123. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +1839 -0
  124. package/docs-site-docusaurus/docs/api/classes/Queue.md +2244 -0
  125. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +6888 -0
  126. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +372 -0
  127. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +2897 -0
  128. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +169 -0
  129. package/docs-site-docusaurus/docs/api/classes/SkipList.md +1229 -0
  130. package/docs-site-docusaurus/docs/api/classes/Stack.md +1573 -0
  131. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +1389 -0
  132. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +1591 -0
  133. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +1246 -0
  134. package/docs-site-docusaurus/docs/api/classes/Trie.md +1708 -0
  135. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +199 -0
  136. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +2979 -0
  137. package/docs-site-docusaurus/docs/guide/_category_.json +6 -0
  138. package/docs-site-docusaurus/docs/guide/architecture.md +615 -0
  139. package/docs-site-docusaurus/docs/guide/concepts.md +451 -0
  140. package/docs-site-docusaurus/docs/guide/faq.md +180 -0
  141. package/docs-site-docusaurus/docs/guide/guides.md +597 -0
  142. package/docs-site-docusaurus/docs/guide/installation.md +62 -0
  143. package/docs-site-docusaurus/docs/guide/integrations.md +825 -0
  144. package/docs-site-docusaurus/docs/guide/overview.md +645 -0
  145. package/docs-site-docusaurus/docs/guide/performance.md +835 -0
  146. package/docs-site-docusaurus/docs/guide/quick-start.md +104 -0
  147. package/docs-site-docusaurus/docs/guide/use-cases/_category_.json +6 -0
  148. package/docs-site-docusaurus/docs/guide/use-cases/array-sort-alternative.md +158 -0
  149. package/docs-site-docusaurus/docs/guide/use-cases/heap-vs-sorting.md +92 -0
  150. package/docs-site-docusaurus/docs/guide/use-cases/map-vs-treemap.md +151 -0
  151. package/docs-site-docusaurus/docs/guide/use-cases/priority-queue-typescript.md +113 -0
  152. package/docs-site-docusaurus/docs/guide/use-cases/treemap-javascript.md +151 -0
  153. package/docs-site-docusaurus/docusaurus.config.ts +159 -0
  154. package/docs-site-docusaurus/fix-mdx-generics.mjs +75 -0
  155. package/docs-site-docusaurus/package-lock.json +18667 -0
  156. package/docs-site-docusaurus/package.json +50 -0
  157. package/docs-site-docusaurus/prefix-class-to-methods.mjs +48 -0
  158. package/docs-site-docusaurus/sidebars.ts +23 -0
  159. package/docs-site-docusaurus/sort-protected.mjs +87 -0
  160. package/docs-site-docusaurus/src/css/custom.css +96 -0
  161. package/docs-site-docusaurus/src/pages/index.module.css +13 -0
  162. package/docs-site-docusaurus/src/pages/index.tsx +120 -0
  163. package/docs-site-docusaurus/src/pages/markdown-page.md +7 -0
  164. package/docs-site-docusaurus/src/theme/TOCItems/index.tsx +34 -0
  165. package/docs-site-docusaurus/static/.nojekyll +0 -0
  166. package/docs-site-docusaurus/static/img/docusaurus-social-card.jpg +0 -0
  167. package/docs-site-docusaurus/static/img/docusaurus.png +0 -0
  168. package/docs-site-docusaurus/static/img/favicon.ico +0 -0
  169. package/docs-site-docusaurus/static/img/favicon.png +0 -0
  170. package/docs-site-docusaurus/static/img/logo-180.png +0 -0
  171. package/docs-site-docusaurus/static/img/logo.jpg +0 -0
  172. package/docs-site-docusaurus/static/img/logo.png +0 -0
  173. package/docs-site-docusaurus/static/img/logo.svg +1 -0
  174. package/docs-site-docusaurus/static/img/og-image.png +0 -0
  175. package/docs-site-docusaurus/static/img/undraw_docusaurus_mountain.svg +171 -0
  176. package/docs-site-docusaurus/static/img/undraw_docusaurus_react.svg +170 -0
  177. package/docs-site-docusaurus/static/img/undraw_docusaurus_tree.svg +40 -0
  178. package/docs-site-docusaurus/static/llms.txt +37 -0
  179. package/docs-site-docusaurus/static/robots.txt +4 -0
  180. package/docs-site-docusaurus/typedoc.json +23 -0
  181. package/llms.txt +37 -0
  182. package/package.json +159 -55
  183. package/src/common/error.ts +19 -1
  184. package/src/common/index.ts +1 -1
  185. package/src/data-structures/base/index.ts +1 -0
  186. package/src/data-structures/base/iterable-element-base.ts +3 -2
  187. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  188. package/src/data-structures/base/linear-base.ts +3 -3
  189. package/src/data-structures/binary-tree/avl-tree.ts +287 -0
  190. package/src/data-structures/binary-tree/binary-indexed-tree.ts +327 -5
  191. package/src/data-structures/binary-tree/binary-tree.ts +581 -6
  192. package/src/data-structures/binary-tree/bst.ts +922 -7
  193. package/src/data-structures/binary-tree/red-black-tree.ts +453 -0
  194. package/src/data-structures/binary-tree/segment-tree.ts +139 -2
  195. package/src/data-structures/binary-tree/tree-map.ts +3300 -495
  196. package/src/data-structures/binary-tree/tree-multi-map.ts +3384 -563
  197. package/src/data-structures/binary-tree/tree-multi-set.ts +2757 -493
  198. package/src/data-structures/binary-tree/tree-set.ts +3122 -440
  199. package/src/data-structures/graph/abstract-graph.ts +6 -6
  200. package/src/data-structures/graph/directed-graph.ts +230 -0
  201. package/src/data-structures/graph/undirected-graph.ts +207 -0
  202. package/src/data-structures/hash/hash-map.ts +270 -19
  203. package/src/data-structures/heap/heap.ts +326 -4
  204. package/src/data-structures/heap/max-heap.ts +2 -2
  205. package/src/data-structures/linked-list/doubly-linked-list.ts +394 -3
  206. package/src/data-structures/linked-list/singly-linked-list.ts +348 -3
  207. package/src/data-structures/linked-list/skip-linked-list.ts +421 -7
  208. package/src/data-structures/matrix/matrix.ts +194 -10
  209. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  210. package/src/data-structures/queue/deque.ts +350 -5
  211. package/src/data-structures/queue/queue.ts +276 -0
  212. package/src/data-structures/stack/stack.ts +230 -0
  213. package/src/data-structures/trie/trie.ts +283 -7
  214. package/src/interfaces/graph.ts +1 -1
  215. package/src/types/common.ts +2 -2
  216. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  217. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  218. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  219. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
  220. package/src/types/data-structures/heap/heap.ts +1 -0
  221. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  222. package/src/types/utils/validate-type.ts +4 -4
  223. package/vercel.json +6 -0
  224. package/dist/leetcode/avl-tree-counter.mjs +0 -2957
  225. package/dist/leetcode/avl-tree-multi-map.mjs +0 -2889
  226. package/dist/leetcode/avl-tree.mjs +0 -2720
  227. package/dist/leetcode/binary-tree.mjs +0 -1594
  228. package/dist/leetcode/bst.mjs +0 -2398
  229. package/dist/leetcode/deque.mjs +0 -683
  230. package/dist/leetcode/directed-graph.mjs +0 -1733
  231. package/dist/leetcode/doubly-linked-list.mjs +0 -709
  232. package/dist/leetcode/hash-map.mjs +0 -493
  233. package/dist/leetcode/heap.mjs +0 -542
  234. package/dist/leetcode/max-heap.mjs +0 -375
  235. package/dist/leetcode/max-priority-queue.mjs +0 -383
  236. package/dist/leetcode/min-heap.mjs +0 -363
  237. package/dist/leetcode/min-priority-queue.mjs +0 -371
  238. package/dist/leetcode/priority-queue.mjs +0 -363
  239. package/dist/leetcode/queue.mjs +0 -943
  240. package/dist/leetcode/red-black-tree.mjs +0 -2765
  241. package/dist/leetcode/singly-linked-list.mjs +0 -754
  242. package/dist/leetcode/stack.mjs +0 -217
  243. package/dist/leetcode/tree-counter.mjs +0 -3039
  244. package/dist/leetcode/tree-multi-map.mjs +0 -2913
  245. package/dist/leetcode/trie.mjs +0 -413
  246. package/dist/leetcode/undirected-graph.mjs +0 -1650
@@ -0,0 +1,2685 @@
1
+ [**data-structure-typed**](../README.md)
2
+
3
+ ***
4
+
5
+ [data-structure-typed](../README.md) / DoublyLinkedList
6
+
7
+ # Class: DoublyLinkedList\<E, R\>
8
+
9
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:150](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L150)
10
+
11
+ Doubly linked list with O(1) push/pop/unshift/shift and linear scans.
12
+
13
+ ## Remarks
14
+
15
+ Time O(1), Space O(1)
16
+
17
+ ## Examples
18
+
19
+ ```ts
20
+ // Browser history
21
+ const browserHistory = new DoublyLinkedList<string>();
22
+
23
+ browserHistory.push('home page');
24
+ browserHistory.push('search page');
25
+ browserHistory.push('details page');
26
+
27
+ console.log(browserHistory.last); // 'details page';
28
+ console.log(browserHistory.pop()); // 'details page';
29
+ console.log(browserHistory.last); // 'search page';
30
+ ```
31
+
32
+ ```ts
33
+ // DoublyLinkedList for LRU cache implementation
34
+ interface CacheEntry {
35
+ key: string;
36
+ value: string;
37
+ }
38
+
39
+ // Simulate LRU cache using DoublyLinkedList
40
+ // DoublyLinkedList is perfect because:
41
+ // - O(1) delete from any position
42
+ // - O(1) push to end
43
+ // - Bidirectional traversal for LRU policy
44
+
45
+ const cacheList = new DoublyLinkedList<CacheEntry>();
46
+ const maxSize = 3;
47
+
48
+ // Add cache entries
49
+ cacheList.push({ key: 'user:1', value: 'Alice' });
50
+ cacheList.push({ key: 'user:2', value: 'Bob' });
51
+ cacheList.push({ key: 'user:3', value: 'Charlie' });
52
+
53
+ // Try to add a new entry when cache is full
54
+ if (cacheList.length >= maxSize) {
55
+ // Remove the oldest (first) entry
56
+ const evicted = cacheList.shift();
57
+ console.log(evicted?.key); // 'user:1';
58
+ }
59
+
60
+ // Add new entry
61
+ cacheList.push({ key: 'user:4', value: 'Diana' });
62
+
63
+ // Verify current cache state
64
+ console.log(cacheList.length); // 3;
65
+ const cachedKeys = [...cacheList].map(entry => entry.key);
66
+ console.log(cachedKeys); // ['user:2', 'user:3', 'user:4'];
67
+
68
+ // Access entry (in real LRU, this would move it to end)
69
+ const foundEntry = [...cacheList].find(entry => entry.key === 'user:2');
70
+ console.log(foundEntry?.value); // 'Bob';
71
+ ```
72
+
73
+ ```ts
74
+ // Find first matching element
75
+ const list = new DoublyLinkedList<number>([5, 10, 15, 20]);
76
+ console.log(list.find(n => n >= 12)); // 15;
77
+ ```
78
+
79
+ ```ts
80
+ // Iterate over elements
81
+ const list = new DoublyLinkedList<number>([1, 2, 3]);
82
+ const sum: number[] = [];
83
+ list.forEach(n => sum.push(n));
84
+ console.log(sum); // [1, 2, 3];
85
+ ```
86
+
87
+ ## Extends
88
+
89
+ - [`LinearLinkedBase`](LinearLinkedBase.md)\<`E`, `R`, [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>\>
90
+
91
+ ## Type Parameters
92
+
93
+ ### E
94
+
95
+ `E` = `any`
96
+
97
+ ### R
98
+
99
+ `R` = `any`
100
+
101
+ 1. Node Structure: Each node contains three parts: a data field, a pointer (or reference) to the previous node, and a pointer to the next node. This structure allows traversal of the linked list in both directions.
102
+ 2. Bidirectional Traversal: Unlike singly linked lists, doubly linked lists can be easily traversed forwards or backwards. This makes insertions and deletions in the list more flexible and efficient.
103
+ 3. No Centralized Index: Unlike arrays, elements in a linked list are not stored contiguously, so there is no centralized index. Accessing elements in a linked list typically requires traversing from the head or tail node.
104
+ 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.
105
+ 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).
106
+
107
+ ## Constructors
108
+
109
+ ### Constructor
110
+
111
+ ```ts
112
+ new DoublyLinkedList<E, R>(elements?, options?): DoublyLinkedList<E, R>;
113
+ ```
114
+
115
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:161](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L161)
116
+
117
+ Create a DoublyLinkedList and optionally bulk-insert elements.
118
+
119
+ #### Parameters
120
+
121
+ ##### elements?
122
+
123
+ \| `Iterable`\<`E`, `any`, `any`\>
124
+ \| `Iterable`\<`R`, `any`, `any`\>
125
+ \| `Iterable`\<[`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>, `any`, `any`\>
126
+
127
+ Iterable of elements or nodes (or raw records if toElementFn is provided).
128
+
129
+ ##### options?
130
+
131
+ `DoublyLinkedListOptions`\<`E`, `R`\>
132
+
133
+ Options such as maxLen and toElementFn.
134
+
135
+ #### Returns
136
+
137
+ `DoublyLinkedList`\<`E`, `R`\>
138
+
139
+ New DoublyLinkedList instance.
140
+
141
+ #### Remarks
142
+
143
+ Time O(N), Space O(N)
144
+
145
+ #### Overrides
146
+
147
+ ```ts
148
+ LinearLinkedBase<E, R, DoublyLinkedListNode<E>>.constructor
149
+ ```
150
+
151
+ ## Properties
152
+
153
+ ### first
154
+
155
+ #### Get Signature
156
+
157
+ ```ts
158
+ get first(): E | undefined;
159
+ ```
160
+
161
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:219](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L219)
162
+
163
+ Get the first element value.
164
+
165
+ ##### Remarks
166
+
167
+ Time O(1), Space O(1)
168
+
169
+ ##### Returns
170
+
171
+ `E` \| `undefined`
172
+
173
+ First element or undefined.
174
+
175
+ ***
176
+
177
+ ### head
178
+
179
+ #### Get Signature
180
+
181
+ ```ts
182
+ get head(): DoublyLinkedListNode<E> | undefined;
183
+ ```
184
+
185
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:185](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L185)
186
+
187
+ Get the head node.
188
+
189
+ ##### Remarks
190
+
191
+ Time O(1), Space O(1)
192
+
193
+ ##### Returns
194
+
195
+ [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\> \| `undefined`
196
+
197
+ Head node or undefined.
198
+
199
+ ***
200
+
201
+ ### last
202
+
203
+ #### Get Signature
204
+
205
+ ```ts
206
+ get last(): E | undefined;
207
+ ```
208
+
209
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:229](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L229)
210
+
211
+ Get the last element value.
212
+
213
+ ##### Remarks
214
+
215
+ Time O(1), Space O(1)
216
+
217
+ ##### Returns
218
+
219
+ `E` \| `undefined`
220
+
221
+ Last element or undefined.
222
+
223
+ ***
224
+
225
+ ### length
226
+
227
+ #### Get Signature
228
+
229
+ ```ts
230
+ get length(): number;
231
+ ```
232
+
233
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:209](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L209)
234
+
235
+ Get the number of elements.
236
+
237
+ ##### Remarks
238
+
239
+ Time O(1), Space O(1)
240
+
241
+ ##### Returns
242
+
243
+ `number`
244
+
245
+ Current length.
246
+
247
+ #### Overrides
248
+
249
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`length`](LinearLinkedBase.md#length)
250
+
251
+ ***
252
+
253
+ ### maxLen
254
+
255
+ #### Get Signature
256
+
257
+ ```ts
258
+ get maxLen(): number;
259
+ ```
260
+
261
+ Defined in: [data-structures/base/linear-base.ts:100](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L100)
262
+
263
+ Upper bound for length (if positive), or `-1` when unbounded.
264
+
265
+ ##### Remarks
266
+
267
+ Time O(1), Space O(1)
268
+
269
+ ##### Returns
270
+
271
+ `number`
272
+
273
+ Maximum allowed length.
274
+
275
+ #### Inherited from
276
+
277
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`maxLen`](LinearLinkedBase.md#maxlen)
278
+
279
+ ***
280
+
281
+ ### tail
282
+
283
+ #### Get Signature
284
+
285
+ ```ts
286
+ get tail(): DoublyLinkedListNode<E> | undefined;
287
+ ```
288
+
289
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:197](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L197)
290
+
291
+ Get the tail node.
292
+
293
+ ##### Remarks
294
+
295
+ Time O(1), Space O(1)
296
+
297
+ ##### Returns
298
+
299
+ [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\> \| `undefined`
300
+
301
+ Tail node or undefined.
302
+
303
+ ***
304
+
305
+ ### toElementFn
306
+
307
+ #### Get Signature
308
+
309
+ ```ts
310
+ get toElementFn(): ((rawElement) => E) | undefined;
311
+ ```
312
+
313
+ Defined in: [data-structures/base/iterable-element-base.ts:48](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L48)
314
+
315
+ Exposes the current `toElementFn`, if configured.
316
+
317
+ ##### Remarks
318
+
319
+ Time O(1), Space O(1).
320
+
321
+ ##### Returns
322
+
323
+ ((`rawElement`) => `E`) \| `undefined`
324
+
325
+ The converter function or `undefined` when not set.
326
+
327
+ #### Inherited from
328
+
329
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`toElementFn`](LinearLinkedBase.md#toelementfn)
330
+
331
+ ## Methods
332
+
333
+ ### \[iterator\]()
334
+
335
+ ```ts
336
+ iterator: IterableIterator<E>;
337
+ ```
338
+
339
+ Defined in: [data-structures/base/iterable-element-base.ts:61](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L61)
340
+
341
+ Returns an iterator over the structure's elements.
342
+
343
+ #### Parameters
344
+
345
+ ##### args
346
+
347
+ ...`unknown`[]
348
+
349
+ Optional iterator arguments forwarded to the internal iterator.
350
+
351
+ #### Returns
352
+
353
+ `IterableIterator`\<`E`\>
354
+
355
+ An `IterableIterator<E>` that yields the elements in traversal order.
356
+
357
+ #### Remarks
358
+
359
+ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with O(1) extra space.
360
+
361
+ #### Inherited from
362
+
363
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`[iterator]`](LinearLinkedBase.md#iterator)
364
+
365
+ ***
366
+
367
+ ### addAfter()
368
+
369
+ ```ts
370
+ addAfter(existingElementOrNode, newElementOrNode): boolean;
371
+ ```
372
+
373
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:801](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L801)
374
+
375
+ Insert a new element/node after an existing one.
376
+
377
+ #### Parameters
378
+
379
+ ##### existingElementOrNode
380
+
381
+ `E` \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
382
+
383
+ Existing element or node.
384
+
385
+ ##### newElementOrNode
386
+
387
+ `E` \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
388
+
389
+ Element or node to insert.
390
+
391
+ #### Returns
392
+
393
+ `boolean`
394
+
395
+ True if inserted.
396
+
397
+ #### Remarks
398
+
399
+ Time O(N), Space O(1)
400
+
401
+ #### Overrides
402
+
403
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`addAfter`](LinearLinkedBase.md#addafter)
404
+
405
+ ***
406
+
407
+ ### addAt()
408
+
409
+ ```ts
410
+ addAt(index, newElementOrNode): boolean;
411
+ ```
412
+
413
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:750](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L750)
414
+
415
+ Insert a new element/node at an index, shifting following nodes.
416
+
417
+ #### Parameters
418
+
419
+ ##### index
420
+
421
+ `number`
422
+
423
+ Zero-based index.
424
+
425
+ ##### newElementOrNode
426
+
427
+ `E` \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
428
+
429
+ Element or node to insert.
430
+
431
+ #### Returns
432
+
433
+ `boolean`
434
+
435
+ True if inserted.
436
+
437
+ *
438
+
439
+ #### Remarks
440
+
441
+ Time O(N), Space O(1)
442
+
443
+ #### Example
444
+
445
+ ```ts
446
+ // Insert at position
447
+ const list = new DoublyLinkedList<number>([1, 3]);
448
+ list.addAt(1, 2);
449
+ console.log(list.toArray()); // [1, 2, 3];
450
+ ```
451
+
452
+ #### Overrides
453
+
454
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`addAt`](LinearLinkedBase.md#addat)
455
+
456
+ ***
457
+
458
+ ### addBefore()
459
+
460
+ ```ts
461
+ addBefore(existingElementOrNode, newElementOrNode): boolean;
462
+ ```
463
+
464
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:774](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L774)
465
+
466
+ Insert a new element/node before an existing one.
467
+
468
+ #### Parameters
469
+
470
+ ##### existingElementOrNode
471
+
472
+ `E` \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
473
+
474
+ Existing element or node.
475
+
476
+ ##### newElementOrNode
477
+
478
+ `E` \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
479
+
480
+ Element or node to insert.
481
+
482
+ #### Returns
483
+
484
+ `boolean`
485
+
486
+ True if inserted.
487
+
488
+ #### Remarks
489
+
490
+ Time O(N), Space O(1)
491
+
492
+ #### Overrides
493
+
494
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`addBefore`](LinearLinkedBase.md#addbefore)
495
+
496
+ ***
497
+
498
+ ### at()
499
+
500
+ ```ts
501
+ at(index): E | undefined;
502
+ ```
503
+
504
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:609](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L609)
505
+
506
+ Get the element at a given index.
507
+
508
+ #### Parameters
509
+
510
+ ##### index
511
+
512
+ `number`
513
+
514
+ Zero-based index.
515
+
516
+ #### Returns
517
+
518
+ `E` \| `undefined`
519
+
520
+ Element or undefined.
521
+
522
+ *
523
+
524
+ #### Remarks
525
+
526
+ Time O(N), Space O(1)
527
+
528
+ #### Example
529
+
530
+ ```ts
531
+ // Access by index
532
+ const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
533
+ console.log(list.at(1)); // 'b';
534
+ console.log(list.at(2)); // 'c';
535
+ ```
536
+
537
+ #### Overrides
538
+
539
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`at`](LinearLinkedBase.md#at)
540
+
541
+ ***
542
+
543
+ ### clear()
544
+
545
+ ```ts
546
+ clear(): void;
547
+ ```
548
+
549
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1040](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1040)
550
+
551
+ Remove all nodes and reset length.
552
+
553
+ #### Returns
554
+
555
+ `void`
556
+
557
+ void
558
+
559
+ *
560
+
561
+ #### Remarks
562
+
563
+ Time O(N), Space O(1)
564
+
565
+ #### Example
566
+
567
+ ```ts
568
+ // Remove all
569
+ const list = new DoublyLinkedList<number>([1, 2]);
570
+ list.clear();
571
+ console.log(list.isEmpty()); // true;
572
+ ```
573
+
574
+ #### Overrides
575
+
576
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`clear`](LinearLinkedBase.md#clear)
577
+
578
+ ***
579
+
580
+ ### clone()
581
+
582
+ ```ts
583
+ clone(): this;
584
+ ```
585
+
586
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1273](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1273)
587
+
588
+ Deep clone this list (values are copied by reference).
589
+
590
+ #### Returns
591
+
592
+ `this`
593
+
594
+ A new list with the same element sequence.
595
+
596
+ *
597
+
598
+ #### Remarks
599
+
600
+ Time O(N), Space O(N)
601
+
602
+ #### Example
603
+
604
+ ```ts
605
+ // Deep copy
606
+ const list = new DoublyLinkedList<number>([1, 2, 3]);
607
+ const copy = list.clone();
608
+ copy.pop();
609
+ console.log(list.length); // 3;
610
+ ```
611
+
612
+ #### Overrides
613
+
614
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`clone`](LinearLinkedBase.md#clone)
615
+
616
+ ***
617
+
618
+ ### concat()
619
+
620
+ ```ts
621
+ concat(...items): this;
622
+ ```
623
+
624
+ Defined in: [data-structures/base/linear-base.ts:473](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L473)
625
+
626
+ Concatenate lists/elements preserving order.
627
+
628
+ #### Parameters
629
+
630
+ ##### items
631
+
632
+ ...(
633
+ \| `E`
634
+ \| [`LinearBase`](LinearBase.md)\<`E`, `R`, [`LinkedListNode`](LinkedListNode.md)\<`E`\>\>)[]
635
+
636
+ Elements or `LinearBase` instances.
637
+
638
+ #### Returns
639
+
640
+ `this`
641
+
642
+ New list with combined elements (`this` type).
643
+
644
+ #### Remarks
645
+
646
+ Time O(sum(length)), Space O(sum(length))
647
+
648
+ #### Inherited from
649
+
650
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`concat`](LinearLinkedBase.md#concat)
651
+
652
+ ***
653
+
654
+ ### delete()
655
+
656
+ ```ts
657
+ delete(elementOrNode?): boolean;
658
+ ```
659
+
660
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:934](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L934)
661
+
662
+ Delete the first match by value/node.
663
+
664
+ #### Parameters
665
+
666
+ ##### elementOrNode?
667
+
668
+ `E` \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
669
+
670
+ Element or node to remove.
671
+
672
+ #### Returns
673
+
674
+ `boolean`
675
+
676
+ True if removed.
677
+
678
+ *
679
+
680
+ #### Remarks
681
+
682
+ Time O(N), Space O(1)
683
+
684
+ #### Example
685
+
686
+ ```ts
687
+ // Remove first occurrence
688
+ const list = new DoublyLinkedList<number>([1, 2, 3, 2]);
689
+ list.delete(2);
690
+ console.log(list.toArray()); // [1, 3, 2];
691
+ ```
692
+
693
+ #### Overrides
694
+
695
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`delete`](LinearLinkedBase.md#delete)
696
+
697
+ ***
698
+
699
+ ### deleteAt()
700
+
701
+ ```ts
702
+ deleteAt(index): E | undefined;
703
+ ```
704
+
705
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:876](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L876)
706
+
707
+ Delete the element at an index.
708
+
709
+ #### Parameters
710
+
711
+ ##### index
712
+
713
+ `number`
714
+
715
+ Zero-based index.
716
+
717
+ #### Returns
718
+
719
+ `E` \| `undefined`
720
+
721
+ Removed element or undefined.
722
+
723
+ *
724
+
725
+ #### Remarks
726
+
727
+ Time O(N), Space O(1)
728
+
729
+ #### Example
730
+
731
+ ```ts
732
+ // Remove by index
733
+ const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
734
+ list.deleteAt(1);
735
+ console.log(list.toArray()); // ['a', 'c'];
736
+ ```
737
+
738
+ #### Overrides
739
+
740
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`deleteAt`](LinearLinkedBase.md#deleteat)
741
+
742
+ ***
743
+
744
+ ### every()
745
+
746
+ ```ts
747
+ every(predicate, thisArg?): boolean;
748
+ ```
749
+
750
+ Defined in: [data-structures/base/iterable-element-base.ts:87](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L87)
751
+
752
+ Tests whether all elements satisfy the predicate.
753
+
754
+ #### Parameters
755
+
756
+ ##### predicate
757
+
758
+ `ElementCallback`\<`E`, `R`, `boolean`\>
759
+
760
+ Function invoked for each element with signature `(value, index, self)`.
761
+
762
+ ##### thisArg?
763
+
764
+ `unknown`
765
+
766
+ Optional `this` binding for the predicate.
767
+
768
+ #### Returns
769
+
770
+ `boolean`
771
+
772
+ `true` if every element passes; otherwise `false`.
773
+
774
+ #### Remarks
775
+
776
+ Time O(n) in the worst case; may exit early when the first failure is found. Space O(1).
777
+
778
+ #### Inherited from
779
+
780
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`every`](LinearLinkedBase.md#every)
781
+
782
+ ***
783
+
784
+ ### fill()
785
+
786
+ ```ts
787
+ fill(
788
+ value,
789
+ start?,
790
+ end?): this;
791
+ ```
792
+
793
+ Defined in: [data-structures/base/linear-base.ts:292](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L292)
794
+
795
+ Fill a range with a value.
796
+
797
+ #### Parameters
798
+
799
+ ##### value
800
+
801
+ `E`
802
+
803
+ Value to set.
804
+
805
+ ##### start?
806
+
807
+ `number` = `0`
808
+
809
+ Inclusive start.
810
+
811
+ ##### end?
812
+
813
+ `number` = `...`
814
+
815
+ Exclusive end.
816
+
817
+ #### Returns
818
+
819
+ `this`
820
+
821
+ This list.
822
+
823
+ #### Remarks
824
+
825
+ Time O(n), Space O(1)
826
+
827
+ #### Inherited from
828
+
829
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`fill`](LinearLinkedBase.md#fill)
830
+
831
+ ***
832
+
833
+ ### filter()
834
+
835
+ ```ts
836
+ filter(callback, thisArg?): this;
837
+ ```
838
+
839
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1327](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1327)
840
+
841
+ Filter values into a new list of the same class.
842
+
843
+ #### Parameters
844
+
845
+ ##### callback
846
+
847
+ `ElementCallback`\<`E`, `R`, `boolean`\>
848
+
849
+ Predicate (value, index, list) → boolean to keep value.
850
+
851
+ ##### thisArg?
852
+
853
+ `unknown`
854
+
855
+ Value for `this` inside the callback.
856
+
857
+ #### Returns
858
+
859
+ `this`
860
+
861
+ A new list with kept values.
862
+
863
+ *
864
+
865
+ #### Remarks
866
+
867
+ Time O(N), Space O(N)
868
+
869
+ #### Example
870
+
871
+ ```ts
872
+ // Filter elements
873
+ const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
874
+ const evens = list.filter(n => n % 2 === 0);
875
+ console.log([...evens]); // [2, 4];
876
+ ```
877
+
878
+ #### Overrides
879
+
880
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`filter`](LinearLinkedBase.md#filter)
881
+
882
+ ***
883
+
884
+ ### find()
885
+
886
+ #### Call Signature
887
+
888
+ ```ts
889
+ find<S>(predicate, thisArg?): S | undefined;
890
+ ```
891
+
892
+ Defined in: [data-structures/base/iterable-element-base.ts:163](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L163)
893
+
894
+ Finds the first element that satisfies the predicate and returns it.
895
+
896
+ Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.
897
+
898
+ ##### Type Parameters
899
+
900
+ ###### S
901
+
902
+ `S`
903
+
904
+ ##### Parameters
905
+
906
+ ###### predicate
907
+
908
+ `ElementCallback`\<`E`, `R`, `S`\>
909
+
910
+ Type-guard predicate: `(value, index, self) => value is S`.
911
+
912
+ ###### thisArg?
913
+
914
+ `unknown`
915
+
916
+ Optional `this` binding for the predicate.
917
+
918
+ ##### Returns
919
+
920
+ `S` \| `undefined`
921
+
922
+ The matched element typed as `S`, or `undefined` if not found.
923
+
924
+ ##### Remarks
925
+
926
+ Time O(n) in the worst case; may exit early on the first match. Space O(1).
927
+
928
+ ##### Inherited from
929
+
930
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`find`](LinearLinkedBase.md#find)
931
+
932
+ #### Call Signature
933
+
934
+ ```ts
935
+ find(predicate, thisArg?): E | undefined;
936
+ ```
937
+
938
+ Defined in: [data-structures/base/iterable-element-base.ts:164](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L164)
939
+
940
+ Finds the first element that satisfies the predicate and returns it.
941
+
942
+ Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.
943
+
944
+ ##### Parameters
945
+
946
+ ###### predicate
947
+
948
+ `ElementCallback`\<`E`, `R`, `unknown`\>
949
+
950
+ Type-guard predicate: `(value, index, self) => value is S`.
951
+
952
+ ###### thisArg?
953
+
954
+ `unknown`
955
+
956
+ Optional `this` binding for the predicate.
957
+
958
+ ##### Returns
959
+
960
+ `E` \| `undefined`
961
+
962
+ The matched element typed as `S`, or `undefined` if not found.
963
+
964
+ ##### Remarks
965
+
966
+ Time O(n) in the worst case; may exit early on the first match. Space O(1).
967
+
968
+ ##### Inherited from
969
+
970
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`find`](LinearLinkedBase.md#find)
971
+
972
+ ***
973
+
974
+ ### findIndex()
975
+
976
+ ```ts
977
+ findIndex(predicate, thisArg?): number;
978
+ ```
979
+
980
+ Defined in: [data-structures/base/linear-base.ts:151](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L151)
981
+
982
+ Find the first index matching a predicate.
983
+
984
+ #### Parameters
985
+
986
+ ##### predicate
987
+
988
+ `ElementCallback`\<`E`, `R`, `boolean`\>
989
+
990
+ `(element, index, self) => boolean`.
991
+
992
+ ##### thisArg?
993
+
994
+ `unknown`
995
+
996
+ Optional `this` for callback.
997
+
998
+ #### Returns
999
+
1000
+ `number`
1001
+
1002
+ Index or `-1`.
1003
+
1004
+ #### Remarks
1005
+
1006
+ Time O(n), Space O(1)
1007
+
1008
+ #### Inherited from
1009
+
1010
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`findIndex`](LinearLinkedBase.md#findindex)
1011
+
1012
+ ***
1013
+
1014
+ ### forEach()
1015
+
1016
+ ```ts
1017
+ forEach(callbackfn, thisArg?): void;
1018
+ ```
1019
+
1020
+ Defined in: [data-structures/base/iterable-element-base.ts:133](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L133)
1021
+
1022
+ Invokes a callback for each element in iteration order.
1023
+
1024
+ #### Parameters
1025
+
1026
+ ##### callbackfn
1027
+
1028
+ `ElementCallback`\<`E`, `R`, `void`\>
1029
+
1030
+ Function invoked per element with signature `(value, index, self)`.
1031
+
1032
+ ##### thisArg?
1033
+
1034
+ `unknown`
1035
+
1036
+ Optional `this` binding for the callback.
1037
+
1038
+ #### Returns
1039
+
1040
+ `void`
1041
+
1042
+ `void`.
1043
+
1044
+ #### Remarks
1045
+
1046
+ Time O(n), Space O(1).
1047
+
1048
+ #### Inherited from
1049
+
1050
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`forEach`](LinearLinkedBase.md#foreach)
1051
+
1052
+ ***
1053
+
1054
+ ### getBackward()
1055
+
1056
+ ```ts
1057
+ getBackward(elementNodeOrPredicate): E | undefined;
1058
+ ```
1059
+
1060
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1147](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1147)
1061
+
1062
+ Find the first value matching a predicate scanning backward.
1063
+
1064
+ #### Parameters
1065
+
1066
+ ##### elementNodeOrPredicate
1067
+
1068
+ \| `E`
1069
+ \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
1070
+ \| ((`node`) => `boolean`)
1071
+
1072
+ Element, node, or predicate to match.
1073
+
1074
+ #### Returns
1075
+
1076
+ `E` \| `undefined`
1077
+
1078
+ Matched value or undefined.
1079
+
1080
+ *
1081
+
1082
+ #### Remarks
1083
+
1084
+ Time O(N), Space O(1)
1085
+
1086
+ #### Example
1087
+
1088
+ ```ts
1089
+ // Find value scanning from tail
1090
+ const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
1091
+ // getBackward scans from tail to head, returns first match
1092
+ const found = list.getBackward(node => node.value < 4);
1093
+ console.log(found); // 3;
1094
+ ```
1095
+
1096
+ ***
1097
+
1098
+ ### getNode()
1099
+
1100
+ ```ts
1101
+ getNode(elementNodeOrPredicate?): DoublyLinkedListNode<E> | undefined;
1102
+ ```
1103
+
1104
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:673](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L673)
1105
+
1106
+ Find a node by value, reference, or predicate.
1107
+
1108
+ #### Parameters
1109
+
1110
+ ##### elementNodeOrPredicate?
1111
+
1112
+ \| `E`
1113
+ \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
1114
+ \| ((`node`) => `boolean`)
1115
+
1116
+ Element, node, or predicate to match.
1117
+
1118
+ #### Returns
1119
+
1120
+ [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\> \| `undefined`
1121
+
1122
+ Matching node or undefined.
1123
+
1124
+ #### Remarks
1125
+
1126
+ Time O(N), Space O(1)
1127
+
1128
+ ***
1129
+
1130
+ ### getNodeAt()
1131
+
1132
+ ```ts
1133
+ getNodeAt(index): DoublyLinkedListNode<E> | undefined;
1134
+ ```
1135
+
1136
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:659](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L659)
1137
+
1138
+ Get the node reference at a given index.
1139
+
1140
+ #### Parameters
1141
+
1142
+ ##### index
1143
+
1144
+ `number`
1145
+
1146
+ Zero-based index.
1147
+
1148
+ #### Returns
1149
+
1150
+ [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\> \| `undefined`
1151
+
1152
+ Node or undefined.
1153
+
1154
+ *
1155
+
1156
+ #### Remarks
1157
+
1158
+ Time O(N), Space O(1)
1159
+
1160
+ #### Example
1161
+
1162
+ ```ts
1163
+ // Get node at index
1164
+ const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
1165
+ console.log(list.getNodeAt(1)?.value); // 'b';
1166
+ ```
1167
+
1168
+ #### Overrides
1169
+
1170
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`getNodeAt`](LinearLinkedBase.md#getnodeat)
1171
+
1172
+ ***
1173
+
1174
+ ### has()
1175
+
1176
+ ```ts
1177
+ has(element): boolean;
1178
+ ```
1179
+
1180
+ Defined in: [data-structures/base/iterable-element-base.ts:189](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L189)
1181
+
1182
+ Checks whether a strictly-equal element exists in the structure.
1183
+
1184
+ #### Parameters
1185
+
1186
+ ##### element
1187
+
1188
+ `E`
1189
+
1190
+ The element to test with `===` equality.
1191
+
1192
+ #### Returns
1193
+
1194
+ `boolean`
1195
+
1196
+ `true` if an equal element is found; otherwise `false`.
1197
+
1198
+ #### Remarks
1199
+
1200
+ Time O(n) in the worst case. Space O(1).
1201
+
1202
+ #### Inherited from
1203
+
1204
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`has`](LinearLinkedBase.md#has)
1205
+
1206
+ ***
1207
+
1208
+ ### indexOf()
1209
+
1210
+ ```ts
1211
+ indexOf(searchElement, fromIndex?): number;
1212
+ ```
1213
+
1214
+ Defined in: [data-structures/base/linear-base.ts:422](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L422)
1215
+
1216
+ Linked-list optimized `indexOf` (forwards scan).
1217
+
1218
+ #### Parameters
1219
+
1220
+ ##### searchElement
1221
+
1222
+ `E`
1223
+
1224
+ Value to match.
1225
+
1226
+ ##### fromIndex?
1227
+
1228
+ `number` = `0`
1229
+
1230
+ Start position.
1231
+
1232
+ #### Returns
1233
+
1234
+ `number`
1235
+
1236
+ Index or `-1`.
1237
+
1238
+ #### Remarks
1239
+
1240
+ Time O(n), Space O(1)
1241
+
1242
+ #### Inherited from
1243
+
1244
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`indexOf`](LinearLinkedBase.md#indexof)
1245
+
1246
+ ***
1247
+
1248
+ ### isEmpty()
1249
+
1250
+ ```ts
1251
+ isEmpty(): boolean;
1252
+ ```
1253
+
1254
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:992](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L992)
1255
+
1256
+ Check whether the list is empty.
1257
+
1258
+ #### Returns
1259
+
1260
+ `boolean`
1261
+
1262
+ True if length is 0.
1263
+
1264
+ *
1265
+
1266
+ #### Remarks
1267
+
1268
+ Time O(1), Space O(1)
1269
+
1270
+ #### Example
1271
+
1272
+ ```ts
1273
+ // Check empty
1274
+ console.log(new DoublyLinkedList().isEmpty()); // true;
1275
+ ```
1276
+
1277
+ #### Overrides
1278
+
1279
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`isEmpty`](LinearLinkedBase.md#isempty)
1280
+
1281
+ ***
1282
+
1283
+ ### isNode()
1284
+
1285
+ ```ts
1286
+ isNode(elementNodeOrPredicate): elementNodeOrPredicate is DoublyLinkedListNode<E>;
1287
+ ```
1288
+
1289
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:260](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L260)
1290
+
1291
+ Type guard: check whether the input is a DoublyLinkedListNode.
1292
+
1293
+ #### Parameters
1294
+
1295
+ ##### elementNodeOrPredicate
1296
+
1297
+ \| `E`
1298
+ \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
1299
+ \| ((`node`) => `boolean`)
1300
+
1301
+ Element, node, or predicate.
1302
+
1303
+ #### Returns
1304
+
1305
+ `elementNodeOrPredicate is DoublyLinkedListNode<E>`
1306
+
1307
+ True if the value is a DoublyLinkedListNode.
1308
+
1309
+ #### Remarks
1310
+
1311
+ Time O(1), Space O(1)
1312
+
1313
+ ***
1314
+
1315
+ ### join()
1316
+
1317
+ ```ts
1318
+ join(separator?): string;
1319
+ ```
1320
+
1321
+ Defined in: [data-structures/base/linear-base.ts:228](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L228)
1322
+
1323
+ Join all elements into a string.
1324
+
1325
+ #### Parameters
1326
+
1327
+ ##### separator?
1328
+
1329
+ `string` = `','`
1330
+
1331
+ Separator string.
1332
+
1333
+ #### Returns
1334
+
1335
+ `string`
1336
+
1337
+ Concatenated string.
1338
+
1339
+ #### Remarks
1340
+
1341
+ Time O(n), Space O(n)
1342
+
1343
+ #### Inherited from
1344
+
1345
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`join`](LinearLinkedBase.md#join)
1346
+
1347
+ ***
1348
+
1349
+ ### lastIndexOf()
1350
+
1351
+ ```ts
1352
+ lastIndexOf(searchElement, fromIndex?): number;
1353
+ ```
1354
+
1355
+ Defined in: [data-structures/base/linear-base.ts:448](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L448)
1356
+
1357
+ Linked-list optimized `lastIndexOf` (reverse scan).
1358
+
1359
+ #### Parameters
1360
+
1361
+ ##### searchElement
1362
+
1363
+ `E`
1364
+
1365
+ Value to match.
1366
+
1367
+ ##### fromIndex?
1368
+
1369
+ `number` = `...`
1370
+
1371
+ Start position.
1372
+
1373
+ #### Returns
1374
+
1375
+ `number`
1376
+
1377
+ Index or `-1`.
1378
+
1379
+ #### Remarks
1380
+
1381
+ Time O(n), Space O(1)
1382
+
1383
+ #### Inherited from
1384
+
1385
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`lastIndexOf`](LinearLinkedBase.md#lastindexof)
1386
+
1387
+ ***
1388
+
1389
+ ### map()
1390
+
1391
+ ```ts
1392
+ map<EM, RM>(
1393
+ callback,
1394
+ options?,
1395
+ thisArg?): DoublyLinkedList<EM, RM>;
1396
+ ```
1397
+
1398
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1412](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1412)
1399
+
1400
+ Map values into a new list (possibly different element type).
1401
+
1402
+ #### Type Parameters
1403
+
1404
+ ##### EM
1405
+
1406
+ `EM`
1407
+
1408
+ ##### RM
1409
+
1410
+ `RM`
1411
+
1412
+ #### Parameters
1413
+
1414
+ ##### callback
1415
+
1416
+ `ElementCallback`\<`E`, `R`, `EM`\>
1417
+
1418
+ Mapping function (value, index, list) → newElement.
1419
+
1420
+ ##### options?
1421
+
1422
+ `DoublyLinkedListOptions`\<`EM`, `RM`\>
1423
+
1424
+ Options for the output list (e.g., maxLen, toElementFn).
1425
+
1426
+ ##### thisArg?
1427
+
1428
+ `unknown`
1429
+
1430
+ Value for `this` inside the callback.
1431
+
1432
+ #### Returns
1433
+
1434
+ `DoublyLinkedList`\<`EM`, `RM`\>
1435
+
1436
+ A new DoublyLinkedList with mapped values.
1437
+
1438
+ *
1439
+
1440
+ #### Remarks
1441
+
1442
+ Time O(N), Space O(N)
1443
+
1444
+ #### Example
1445
+
1446
+ ```ts
1447
+ // DoublyLinkedList for...of iteration and map operation
1448
+ const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
1449
+
1450
+ // Iterate through list
1451
+ const doubled = list.map(value => value * 2);
1452
+ console.log(doubled.length); // 5;
1453
+
1454
+ // Use for...of loop
1455
+ const result: number[] = [];
1456
+ for (const item of list) {
1457
+ result.push(item);
1458
+ }
1459
+ console.log(result); // [1, 2, 3, 4, 5];
1460
+ ```
1461
+
1462
+ #### Overrides
1463
+
1464
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`map`](LinearLinkedBase.md#map)
1465
+
1466
+ ***
1467
+
1468
+ ### mapSame()
1469
+
1470
+ ```ts
1471
+ mapSame(callback, thisArg?): this;
1472
+ ```
1473
+
1474
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1342](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1342)
1475
+
1476
+ Map values into a new list of the same class.
1477
+
1478
+ #### Parameters
1479
+
1480
+ ##### callback
1481
+
1482
+ `ElementCallback`\<`E`, `R`, `E`\>
1483
+
1484
+ Mapping function (value, index, list) → newValue.
1485
+
1486
+ ##### thisArg?
1487
+
1488
+ `unknown`
1489
+
1490
+ Value for `this` inside the callback.
1491
+
1492
+ #### Returns
1493
+
1494
+ `this`
1495
+
1496
+ A new list with mapped values.
1497
+
1498
+ #### Remarks
1499
+
1500
+ Time O(N), Space O(N)
1501
+
1502
+ #### Overrides
1503
+
1504
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`mapSame`](LinearLinkedBase.md#mapsame)
1505
+
1506
+ ***
1507
+
1508
+ ### pop()
1509
+
1510
+ ```ts
1511
+ pop(): E | undefined;
1512
+ ```
1513
+
1514
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:394](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L394)
1515
+
1516
+ Remove and return the tail element.
1517
+
1518
+ #### Returns
1519
+
1520
+ `E` \| `undefined`
1521
+
1522
+ Removed element or undefined.
1523
+
1524
+ *
1525
+
1526
+ #### Remarks
1527
+
1528
+ Time O(1), Space O(1)
1529
+
1530
+ #### Example
1531
+
1532
+ ```ts
1533
+ // DoublyLinkedList pop and shift operations
1534
+ const list = new DoublyLinkedList<number>([10, 20, 30, 40, 50]);
1535
+
1536
+ // Pop removes from the end
1537
+ const last = list.pop();
1538
+ console.log(last); // 50;
1539
+
1540
+ // Shift removes from the beginning
1541
+ const first = list.shift();
1542
+ console.log(first); // 10;
1543
+
1544
+ // Verify remaining elements
1545
+ console.log([...list]); // [20, 30, 40];
1546
+ console.log(list.length); // 3;
1547
+ ```
1548
+
1549
+ ***
1550
+
1551
+ ### print()
1552
+
1553
+ ```ts
1554
+ print(): void;
1555
+ ```
1556
+
1557
+ Defined in: [data-structures/base/iterable-element-base.ts:269](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L269)
1558
+
1559
+ Prints `toVisual()` to the console. Intended for quick debugging.
1560
+
1561
+ #### Returns
1562
+
1563
+ `void`
1564
+
1565
+ `void`.
1566
+
1567
+ #### Remarks
1568
+
1569
+ Time O(n) due to materialization, Space O(n) for the intermediate representation.
1570
+
1571
+ #### Inherited from
1572
+
1573
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`print`](LinearLinkedBase.md#print)
1574
+
1575
+ ***
1576
+
1577
+ ### push()
1578
+
1579
+ ```ts
1580
+ push(elementOrNode): boolean;
1581
+ ```
1582
+
1583
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:323](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L323)
1584
+
1585
+ Append an element/node to the tail.
1586
+
1587
+ #### Parameters
1588
+
1589
+ ##### elementOrNode
1590
+
1591
+ `E` \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
1592
+
1593
+ Element or node to append.
1594
+
1595
+ #### Returns
1596
+
1597
+ `boolean`
1598
+
1599
+ True when appended.
1600
+
1601
+ *
1602
+
1603
+ #### Remarks
1604
+
1605
+ Time O(1), Space O(1)
1606
+
1607
+ #### Example
1608
+
1609
+ ```ts
1610
+ // basic DoublyLinkedList creation and push operation
1611
+ // Create a simple DoublyLinkedList with initial values
1612
+ const list = new DoublyLinkedList([1, 2, 3, 4, 5]);
1613
+
1614
+ // Verify the list maintains insertion order
1615
+ console.log([...list]); // [1, 2, 3, 4, 5];
1616
+
1617
+ // Check length
1618
+ console.log(list.length); // 5;
1619
+
1620
+ // Push a new element to the end
1621
+ list.push(6);
1622
+ console.log(list.length); // 6;
1623
+ console.log([...list]); // [1, 2, 3, 4, 5, 6];
1624
+ ```
1625
+
1626
+ #### Overrides
1627
+
1628
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`push`](LinearLinkedBase.md#push)
1629
+
1630
+ ***
1631
+
1632
+ ### pushMany()
1633
+
1634
+ ```ts
1635
+ pushMany(elements): boolean[];
1636
+ ```
1637
+
1638
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:537](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L537)
1639
+
1640
+ Append a sequence of elements/nodes.
1641
+
1642
+ #### Parameters
1643
+
1644
+ ##### elements
1645
+
1646
+ \| `Iterable`\<`E`, `any`, `any`\>
1647
+ \| `Iterable`\<`R`, `any`, `any`\>
1648
+ \| `Iterable`\<[`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>, `any`, `any`\>
1649
+
1650
+ Iterable of elements or nodes (or raw records if toElementFn is provided).
1651
+
1652
+ #### Returns
1653
+
1654
+ `boolean`[]
1655
+
1656
+ Array of per-element success flags.
1657
+
1658
+ #### Remarks
1659
+
1660
+ Time O(N), Space O(1)
1661
+
1662
+ #### Overrides
1663
+
1664
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`pushMany`](LinearLinkedBase.md#pushmany)
1665
+
1666
+ ***
1667
+
1668
+ ### reduce()
1669
+
1670
+ Reduces all elements to a single accumulated value.
1671
+
1672
+ #### Param
1673
+
1674
+ Reducer of signature `(acc, value, index, self) => nextAcc`. The first element is used as the initial accumulator.
1675
+
1676
+ #### Param
1677
+
1678
+ Reducer of signature `(acc, value, index, self) => nextAcc`.
1679
+
1680
+ #### Param
1681
+
1682
+ The initial accumulator value of type `E`.
1683
+
1684
+ #### Template
1685
+
1686
+ The accumulator type when it differs from `E`.
1687
+
1688
+ #### Param
1689
+
1690
+ Reducer of signature `(acc: U, value, index, self) => U`.
1691
+
1692
+ #### Param
1693
+
1694
+ The initial accumulator value of type `U`.
1695
+
1696
+ #### Remarks
1697
+
1698
+ Time O(n), Space O(1). Throws if called on an empty structure without `initialValue`.
1699
+
1700
+ #### Call Signature
1701
+
1702
+ ```ts
1703
+ reduce(callbackfn): E;
1704
+ ```
1705
+
1706
+ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L194)
1707
+
1708
+ ##### Parameters
1709
+
1710
+ ###### callbackfn
1711
+
1712
+ `ReduceElementCallback`\<`E`, `R`\>
1713
+
1714
+ ##### Returns
1715
+
1716
+ `E`
1717
+
1718
+ ##### Inherited from
1719
+
1720
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`reduce`](LinearLinkedBase.md#reduce)
1721
+
1722
+ #### Call Signature
1723
+
1724
+ ```ts
1725
+ reduce(callbackfn, initialValue): E;
1726
+ ```
1727
+
1728
+ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L195)
1729
+
1730
+ ##### Parameters
1731
+
1732
+ ###### callbackfn
1733
+
1734
+ `ReduceElementCallback`\<`E`, `R`\>
1735
+
1736
+ ###### initialValue
1737
+
1738
+ `E`
1739
+
1740
+ ##### Returns
1741
+
1742
+ `E`
1743
+
1744
+ ##### Inherited from
1745
+
1746
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`reduce`](LinearLinkedBase.md#reduce)
1747
+
1748
+ #### Call Signature
1749
+
1750
+ ```ts
1751
+ reduce<U>(callbackfn, initialValue): U;
1752
+ ```
1753
+
1754
+ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L196)
1755
+
1756
+ ##### Type Parameters
1757
+
1758
+ ###### U
1759
+
1760
+ `U`
1761
+
1762
+ ##### Parameters
1763
+
1764
+ ###### callbackfn
1765
+
1766
+ `ReduceElementCallback`\<`E`, `R`, `U`\>
1767
+
1768
+ ###### initialValue
1769
+
1770
+ `U`
1771
+
1772
+ ##### Returns
1773
+
1774
+ `U`
1775
+
1776
+ ##### Inherited from
1777
+
1778
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`reduce`](LinearLinkedBase.md#reduce)
1779
+
1780
+ ***
1781
+
1782
+ ### reduceRight()
1783
+
1784
+ ```ts
1785
+ reduceRight<U>(callbackfn, initialValue): U;
1786
+ ```
1787
+
1788
+ Defined in: [data-structures/base/linear-base.ts:574](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L574)
1789
+
1790
+ Right-to-left reduction using reverse iterator.
1791
+
1792
+ #### Type Parameters
1793
+
1794
+ ##### U
1795
+
1796
+ `U`
1797
+
1798
+ #### Parameters
1799
+
1800
+ ##### callbackfn
1801
+
1802
+ `ReduceLinearCallback`\<`E`, `U`\>
1803
+
1804
+ `(acc, element, index, self) => acc`.
1805
+
1806
+ ##### initialValue
1807
+
1808
+ `U`
1809
+
1810
+ Initial accumulator.
1811
+
1812
+ #### Returns
1813
+
1814
+ `U`
1815
+
1816
+ Final accumulator.
1817
+
1818
+ #### Remarks
1819
+
1820
+ Time O(n), Space O(1)
1821
+
1822
+ #### Inherited from
1823
+
1824
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`reduceRight`](LinearLinkedBase.md#reduceright)
1825
+
1826
+ ***
1827
+
1828
+ ### reverse()
1829
+
1830
+ ```ts
1831
+ reverse(): this;
1832
+ ```
1833
+
1834
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1205](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1205)
1835
+
1836
+ Reverse the list in place.
1837
+
1838
+ #### Returns
1839
+
1840
+ `this`
1841
+
1842
+ This list.
1843
+
1844
+ *
1845
+
1846
+ #### Remarks
1847
+
1848
+ Time O(N), Space O(1)
1849
+
1850
+ #### Example
1851
+
1852
+ ```ts
1853
+ // Reverse in-place
1854
+ const list = new DoublyLinkedList<number>([1, 2, 3]);
1855
+ list.reverse();
1856
+ console.log([...list]); // [3, 2, 1];
1857
+ ```
1858
+
1859
+ #### Overrides
1860
+
1861
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`reverse`](LinearLinkedBase.md#reverse)
1862
+
1863
+ ***
1864
+
1865
+ ### search()
1866
+
1867
+ ```ts
1868
+ search(elementNodeOrPredicate): E | undefined;
1869
+ ```
1870
+
1871
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1090](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1090)
1872
+
1873
+ Find the first value matching a predicate scanning forward.
1874
+
1875
+ #### Parameters
1876
+
1877
+ ##### elementNodeOrPredicate
1878
+
1879
+ \| `E`
1880
+ \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
1881
+ \| ((`node`) => `boolean`)
1882
+
1883
+ Element, node, or predicate to match.
1884
+
1885
+ #### Returns
1886
+
1887
+ `E` \| `undefined`
1888
+
1889
+ Matched value or undefined.
1890
+
1891
+ *
1892
+
1893
+ #### Remarks
1894
+
1895
+ Time O(N), Space O(1)
1896
+
1897
+ #### Example
1898
+
1899
+ ```ts
1900
+ // Search with predicate
1901
+ const list = new DoublyLinkedList<number>([10, 20, 30]);
1902
+ const found = list.search(node => node.value > 15);
1903
+ console.log(found); // 20;
1904
+ ```
1905
+
1906
+ ***
1907
+
1908
+ ### setAt()
1909
+
1910
+ ```ts
1911
+ setAt(index, value): boolean;
1912
+ ```
1913
+
1914
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:825](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L825)
1915
+
1916
+ Set the element value at an index.
1917
+
1918
+ #### Parameters
1919
+
1920
+ ##### index
1921
+
1922
+ `number`
1923
+
1924
+ Zero-based index.
1925
+
1926
+ ##### value
1927
+
1928
+ `E`
1929
+
1930
+ New value.
1931
+
1932
+ #### Returns
1933
+
1934
+ `boolean`
1935
+
1936
+ True if updated.
1937
+
1938
+ #### Remarks
1939
+
1940
+ Time O(N), Space O(1)
1941
+
1942
+ #### Overrides
1943
+
1944
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`setAt`](LinearLinkedBase.md#setat)
1945
+
1946
+ ***
1947
+
1948
+ ### setEquality()
1949
+
1950
+ ```ts
1951
+ setEquality(equals): this;
1952
+ ```
1953
+
1954
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1223](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1223)
1955
+
1956
+ Set the equality comparator used to compare values.
1957
+
1958
+ #### Parameters
1959
+
1960
+ ##### equals
1961
+
1962
+ (`a`, `b`) => `boolean`
1963
+
1964
+ Equality predicate (a, b) → boolean.
1965
+
1966
+ #### Returns
1967
+
1968
+ `this`
1969
+
1970
+ This list.
1971
+
1972
+ #### Remarks
1973
+
1974
+ Time O(1), Space O(1)
1975
+
1976
+ ***
1977
+
1978
+ ### shift()
1979
+
1980
+ ```ts
1981
+ shift(): E | undefined;
1982
+ ```
1983
+
1984
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:454](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L454)
1985
+
1986
+ Remove and return the head element.
1987
+
1988
+ #### Returns
1989
+
1990
+ `E` \| `undefined`
1991
+
1992
+ Removed element or undefined.
1993
+
1994
+ *
1995
+
1996
+ #### Remarks
1997
+
1998
+ Time O(1), Space O(1)
1999
+
2000
+ #### Example
2001
+
2002
+ ```ts
2003
+ // Remove from the front
2004
+ const list = new DoublyLinkedList<number>([10, 20, 30]);
2005
+ console.log(list.shift()); // 10;
2006
+ console.log(list.first); // 20;
2007
+ ```
2008
+
2009
+ ***
2010
+
2011
+ ### slice()
2012
+
2013
+ ```ts
2014
+ slice(start?, end?): this;
2015
+ ```
2016
+
2017
+ Defined in: [data-structures/base/linear-base.ts:494](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L494)
2018
+
2019
+ Slice via forward iteration (no random access required).
2020
+
2021
+ #### Parameters
2022
+
2023
+ ##### start?
2024
+
2025
+ `number` = `0`
2026
+
2027
+ Inclusive start (supports negative index).
2028
+
2029
+ ##### end?
2030
+
2031
+ `number` = `...`
2032
+
2033
+ Exclusive end (supports negative index).
2034
+
2035
+ #### Returns
2036
+
2037
+ `this`
2038
+
2039
+ New list (`this` type).
2040
+
2041
+ #### Remarks
2042
+
2043
+ Time O(n), Space O(n)
2044
+
2045
+ #### Inherited from
2046
+
2047
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`slice`](LinearLinkedBase.md#slice)
2048
+
2049
+ ***
2050
+
2051
+ ### some()
2052
+
2053
+ ```ts
2054
+ some(predicate, thisArg?): boolean;
2055
+ ```
2056
+
2057
+ Defined in: [data-structures/base/iterable-element-base.ts:110](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L110)
2058
+
2059
+ Tests whether at least one element satisfies the predicate.
2060
+
2061
+ #### Parameters
2062
+
2063
+ ##### predicate
2064
+
2065
+ `ElementCallback`\<`E`, `R`, `boolean`\>
2066
+
2067
+ Function invoked for each element with signature `(value, index, self)`.
2068
+
2069
+ ##### thisArg?
2070
+
2071
+ `unknown`
2072
+
2073
+ Optional `this` binding for the predicate.
2074
+
2075
+ #### Returns
2076
+
2077
+ `boolean`
2078
+
2079
+ `true` if any element passes; otherwise `false`.
2080
+
2081
+ #### Remarks
2082
+
2083
+ Time O(n) in the worst case; may exit early on first success. Space O(1).
2084
+
2085
+ #### Inherited from
2086
+
2087
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`some`](LinearLinkedBase.md#some)
2088
+
2089
+ ***
2090
+
2091
+ ### sort()
2092
+
2093
+ ```ts
2094
+ sort(compareFn?): this;
2095
+ ```
2096
+
2097
+ Defined in: [data-structures/base/linear-base.ts:185](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L185)
2098
+
2099
+ In-place stable order via array sort semantics.
2100
+
2101
+ #### Parameters
2102
+
2103
+ ##### compareFn?
2104
+
2105
+ (`a`, `b`) => `number`
2106
+
2107
+ Comparator `(a, b) => number`.
2108
+
2109
+ #### Returns
2110
+
2111
+ `this`
2112
+
2113
+ This container.
2114
+
2115
+ #### Remarks
2116
+
2117
+ Time O(n log n), Space O(n) (materializes to array temporarily)
2118
+
2119
+ #### Inherited from
2120
+
2121
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`sort`](LinearLinkedBase.md#sort)
2122
+
2123
+ ***
2124
+
2125
+ ### splice()
2126
+
2127
+ ```ts
2128
+ splice(
2129
+ start,
2130
+ deleteCount?, ...
2131
+ items): this;
2132
+ ```
2133
+
2134
+ Defined in: [data-structures/base/linear-base.ts:522](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L522)
2135
+
2136
+ Splice by walking node iterators from the start index.
2137
+
2138
+ #### Parameters
2139
+
2140
+ ##### start
2141
+
2142
+ `number`
2143
+
2144
+ Start index.
2145
+
2146
+ ##### deleteCount?
2147
+
2148
+ `number` = `0`
2149
+
2150
+ How many elements to remove.
2151
+
2152
+ ##### items
2153
+
2154
+ ...`E`[]
2155
+
2156
+ Elements to insert after the splice point.
2157
+
2158
+ #### Returns
2159
+
2160
+ `this`
2161
+
2162
+ Removed elements as a new list (`this` type).
2163
+
2164
+ #### Remarks
2165
+
2166
+ Time O(n + m), Space O(min(n, m)) where `m = items.length`
2167
+
2168
+ #### Inherited from
2169
+
2170
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`splice`](LinearLinkedBase.md#splice)
2171
+
2172
+ ***
2173
+
2174
+ ### toArray()
2175
+
2176
+ ```ts
2177
+ toArray(): E[];
2178
+ ```
2179
+
2180
+ Defined in: [data-structures/base/iterable-element-base.ts:246](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L246)
2181
+
2182
+ Materializes the elements into a new array.
2183
+
2184
+ #### Returns
2185
+
2186
+ `E`[]
2187
+
2188
+ A shallow array copy of the iteration order.
2189
+
2190
+ #### Remarks
2191
+
2192
+ Time O(n), Space O(n).
2193
+
2194
+ #### Inherited from
2195
+
2196
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`toArray`](LinearLinkedBase.md#toarray)
2197
+
2198
+ ***
2199
+
2200
+ ### toReversedArray()
2201
+
2202
+ ```ts
2203
+ toReversedArray(): E[];
2204
+ ```
2205
+
2206
+ Defined in: [data-structures/base/linear-base.ts:237](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/linear-base.ts#L237)
2207
+
2208
+ Snapshot elements into a reversed array.
2209
+
2210
+ #### Returns
2211
+
2212
+ `E`[]
2213
+
2214
+ New reversed array.
2215
+
2216
+ #### Remarks
2217
+
2218
+ Time O(n), Space O(n)
2219
+
2220
+ #### Inherited from
2221
+
2222
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`toReversedArray`](LinearLinkedBase.md#toreversedarray)
2223
+
2224
+ ***
2225
+
2226
+ ### toVisual()
2227
+
2228
+ ```ts
2229
+ toVisual(): E[];
2230
+ ```
2231
+
2232
+ Defined in: [data-structures/base/iterable-element-base.ts:258](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L258)
2233
+
2234
+ Returns a representation of the structure suitable for quick visualization.
2235
+ Defaults to an array of elements; subclasses may override to provide richer visuals.
2236
+
2237
+ #### Returns
2238
+
2239
+ `E`[]
2240
+
2241
+ A visual representation (array by default).
2242
+
2243
+ #### Remarks
2244
+
2245
+ Time O(n), Space O(n).
2246
+
2247
+ #### Inherited from
2248
+
2249
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`toVisual`](LinearLinkedBase.md#tovisual)
2250
+
2251
+ ***
2252
+
2253
+ ### unshift()
2254
+
2255
+ ```ts
2256
+ unshift(elementOrNode): boolean;
2257
+ ```
2258
+
2259
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:515](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L515)
2260
+
2261
+ Prepend an element/node to the head.
2262
+
2263
+ #### Parameters
2264
+
2265
+ ##### elementOrNode
2266
+
2267
+ `E` \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
2268
+
2269
+ Element or node to prepend.
2270
+
2271
+ #### Returns
2272
+
2273
+ `boolean`
2274
+
2275
+ True when prepended.
2276
+
2277
+ *
2278
+
2279
+ #### Remarks
2280
+
2281
+ Time O(1), Space O(1)
2282
+
2283
+ #### Example
2284
+
2285
+ ```ts
2286
+ // Add to the front
2287
+ const list = new DoublyLinkedList<number>([2, 3]);
2288
+ list.unshift(1);
2289
+ console.log([...list]); // [1, 2, 3];
2290
+ ```
2291
+
2292
+ ***
2293
+
2294
+ ### unshiftMany()
2295
+
2296
+ ```ts
2297
+ unshiftMany(elements): boolean[];
2298
+ ```
2299
+
2300
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:553](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L553)
2301
+
2302
+ Prepend a sequence of elements/nodes.
2303
+
2304
+ #### Parameters
2305
+
2306
+ ##### elements
2307
+
2308
+ \| `Iterable`\<`E`, `any`, `any`\>
2309
+ \| `Iterable`\<`R`, `any`, `any`\>
2310
+ \| `Iterable`\<[`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>, `any`, `any`\>
2311
+
2312
+ Iterable of elements or nodes (or raw records if toElementFn is provided).
2313
+
2314
+ #### Returns
2315
+
2316
+ `boolean`[]
2317
+
2318
+ Array of per-element success flags.
2319
+
2320
+ #### Remarks
2321
+
2322
+ Time O(N), Space O(1)
2323
+
2324
+ ***
2325
+
2326
+ ### values()
2327
+
2328
+ ```ts
2329
+ values(): IterableIterator<E>;
2330
+ ```
2331
+
2332
+ Defined in: [data-structures/base/iterable-element-base.ts:72](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L72)
2333
+
2334
+ Returns an iterator over the values (alias of the default iterator).
2335
+
2336
+ #### Returns
2337
+
2338
+ `IterableIterator`\<`E`\>
2339
+
2340
+ An `IterableIterator<E>` over all elements.
2341
+
2342
+ #### Remarks
2343
+
2344
+ Creating the iterator is O(1); full iteration is Time O(n), Space O(1).
2345
+
2346
+ #### Inherited from
2347
+
2348
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`values`](LinearLinkedBase.md#values)
2349
+
2350
+ ***
2351
+
2352
+ ### fromArray()
2353
+
2354
+ ```ts
2355
+ static fromArray<E, R>(this, data): any;
2356
+ ```
2357
+
2358
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:243](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L243)
2359
+
2360
+ Create a new list from an array of elements.
2361
+
2362
+ #### Type Parameters
2363
+
2364
+ ##### E
2365
+
2366
+ `E`
2367
+
2368
+ ##### R
2369
+
2370
+ `R` = `any`
2371
+
2372
+ #### Parameters
2373
+
2374
+ ##### this
2375
+
2376
+ `Object`
2377
+
2378
+ The constructor (subclass) to instantiate.
2379
+
2380
+ ##### data
2381
+
2382
+ `E`[]
2383
+
2384
+ Array of elements to insert.
2385
+
2386
+ #### Returns
2387
+
2388
+ `any`
2389
+
2390
+ A new list populated with the array's elements.
2391
+
2392
+ #### Remarks
2393
+
2394
+ Time O(N), Space O(N)
2395
+
2396
+
2397
+ ---
2398
+
2399
+ ## Protected Members
2400
+
2401
+ ### \_toElementFn?
2402
+
2403
+ ```ts
2404
+ protected optional _toElementFn?: (rawElement) => E;
2405
+ ```
2406
+
2407
+ Defined in: [data-structures/base/iterable-element-base.ts:39](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L39)
2408
+
2409
+ The converter used to transform a raw element (`R`) into a public element (`E`).
2410
+
2411
+ #### Parameters
2412
+
2413
+ ##### rawElement
2414
+
2415
+ `R`
2416
+
2417
+ #### Returns
2418
+
2419
+ `E`
2420
+
2421
+ #### Remarks
2422
+
2423
+ Time O(1), Space O(1).
2424
+
2425
+ #### Inherited from
2426
+
2427
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`_toElementFn`](LinearLinkedBase.md#_toelementfn)
2428
+
2429
+ ## Accessors
2430
+
2431
+ ### \_createInstance()
2432
+
2433
+ ```ts
2434
+ protected _createInstance(options?): this;
2435
+ ```
2436
+
2437
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1474](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1474)
2438
+
2439
+ (Protected) Create an empty instance of the same concrete class.
2440
+
2441
+ #### Parameters
2442
+
2443
+ ##### options?
2444
+
2445
+ `LinearBaseOptions`\<`E`, `R`\>
2446
+
2447
+ Options forwarded to the constructor.
2448
+
2449
+ #### Returns
2450
+
2451
+ `this`
2452
+
2453
+ An empty like-kind list instance.
2454
+
2455
+ #### Remarks
2456
+
2457
+ Time O(1), Space O(1)
2458
+
2459
+ #### Overrides
2460
+
2461
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`_createInstance`](LinearLinkedBase.md#_createinstance)
2462
+
2463
+ ***
2464
+
2465
+ ### \_createLike()
2466
+
2467
+ ```ts
2468
+ protected _createLike<EM, RM>(elements?, options?): DoublyLinkedList<EM, RM>;
2469
+ ```
2470
+
2471
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1492](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1492)
2472
+
2473
+ (Protected) Create a like-kind instance and seed it from an iterable.
2474
+
2475
+ #### Type Parameters
2476
+
2477
+ ##### EM
2478
+
2479
+ `EM` = `E`
2480
+
2481
+ ##### RM
2482
+
2483
+ `RM` = `R`
2484
+
2485
+ #### Parameters
2486
+
2487
+ ##### elements?
2488
+
2489
+ \| `Iterable`\<`EM`, `any`, `any`\>
2490
+ \| `Iterable`\<`RM`, `any`, `any`\>
2491
+ \| `Iterable`\<[`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`EM`\>, `any`, `any`\>
2492
+
2493
+ Iterable used to seed the new list.
2494
+
2495
+ ##### options?
2496
+
2497
+ `DoublyLinkedListOptions`\<`EM`, `RM`\>
2498
+
2499
+ Options forwarded to the constructor.
2500
+
2501
+ #### Returns
2502
+
2503
+ `DoublyLinkedList`\<`EM`, `RM`\>
2504
+
2505
+ A like-kind DoublyLinkedList instance.
2506
+
2507
+ #### Remarks
2508
+
2509
+ Time O(N), Space O(N)
2510
+
2511
+ ***
2512
+
2513
+ ### \_ensureNode()
2514
+
2515
+ ```ts
2516
+ protected _ensureNode(elementOrNode): DoublyLinkedListNode<E>;
2517
+ ```
2518
+
2519
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1430](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1430)
2520
+
2521
+ (Protected) Create or return a node for the given input (node or raw element).
2522
+
2523
+ #### Parameters
2524
+
2525
+ ##### elementOrNode
2526
+
2527
+ `E` \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
2528
+
2529
+ Element value or node to normalize.
2530
+
2531
+ #### Returns
2532
+
2533
+ [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
2534
+
2535
+ A DoublyLinkedListNode for the provided input.
2536
+
2537
+ #### Remarks
2538
+
2539
+ Time O(1), Space O(1)
2540
+
2541
+ ***
2542
+
2543
+ ### \_ensurePredicate()
2544
+
2545
+ ```ts
2546
+ protected _ensurePredicate(elementNodeOrPredicate): (node) => boolean;
2547
+ ```
2548
+
2549
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1442](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1442)
2550
+
2551
+ (Protected) Normalize input into a predicate over nodes.
2552
+
2553
+ #### Parameters
2554
+
2555
+ ##### elementNodeOrPredicate
2556
+
2557
+ \| `E`
2558
+ \| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
2559
+ \| ((`node`) => `boolean`)
2560
+
2561
+ Element, node, or node predicate.
2562
+
2563
+ #### Returns
2564
+
2565
+ A predicate function taking a node and returning true/false.
2566
+
2567
+ (`node`) => `boolean`
2568
+
2569
+ #### Remarks
2570
+
2571
+ Time O(1), Space O(1)
2572
+
2573
+ ***
2574
+
2575
+ ### \_getIterator()
2576
+
2577
+ ```ts
2578
+ protected _getIterator(): IterableIterator<E>;
2579
+ ```
2580
+
2581
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1503](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1503)
2582
+
2583
+ Internal iterator factory used by the default iterator.
2584
+
2585
+ #### Returns
2586
+
2587
+ `IterableIterator`\<`E`\>
2588
+
2589
+ An iterator over elements.
2590
+
2591
+ #### Remarks
2592
+
2593
+ Implementations should yield in O(1) per element with O(1) extra space when possible.
2594
+
2595
+ #### Overrides
2596
+
2597
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`_getIterator`](LinearLinkedBase.md#_getiterator)
2598
+
2599
+ ***
2600
+
2601
+ ### \_getNodeIterator()
2602
+
2603
+ ```ts
2604
+ protected _getNodeIterator(): IterableIterator<DoublyLinkedListNode<E>>;
2605
+ ```
2606
+
2607
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1519](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1519)
2608
+
2609
+ Iterate linked nodes from head to tail.
2610
+
2611
+ #### Returns
2612
+
2613
+ `IterableIterator`\<[`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>\>
2614
+
2615
+ Iterator over nodes.
2616
+
2617
+ #### Remarks
2618
+
2619
+ Time O(n), Space O(1)
2620
+
2621
+ #### Overrides
2622
+
2623
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`_getNodeIterator`](LinearLinkedBase.md#_getnodeiterator)
2624
+
2625
+ ***
2626
+
2627
+ ### \_getPrevNode()
2628
+
2629
+ ```ts
2630
+ protected _getPrevNode(node): DoublyLinkedListNode<E> | undefined;
2631
+ ```
2632
+
2633
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1463](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1463)
2634
+
2635
+ (Protected) Get the previous node of a given node.
2636
+
2637
+ #### Parameters
2638
+
2639
+ ##### node
2640
+
2641
+ [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
2642
+
2643
+ A node in the list.
2644
+
2645
+ #### Returns
2646
+
2647
+ [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\> \| `undefined`
2648
+
2649
+ Previous node or undefined.
2650
+
2651
+ #### Remarks
2652
+
2653
+ Time O(1), Space O(1)
2654
+
2655
+ #### Overrides
2656
+
2657
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`_getPrevNode`](LinearLinkedBase.md#_getprevnode)
2658
+
2659
+ ***
2660
+
2661
+ ### \_getReverseIterator()
2662
+
2663
+ ```ts
2664
+ protected _getReverseIterator(): IterableIterator<E>;
2665
+ ```
2666
+
2667
+ Defined in: [data-structures/linked-list/doubly-linked-list.ts:1511](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/linked-list/doubly-linked-list.ts#L1511)
2668
+
2669
+ Reverse-direction iterator over elements.
2670
+
2671
+ #### Returns
2672
+
2673
+ `IterableIterator`\<`E`\>
2674
+
2675
+ Iterator of elements from tail to head.
2676
+
2677
+ #### Remarks
2678
+
2679
+ Time O(n), Space O(1)
2680
+
2681
+ #### Overrides
2682
+
2683
+ [`LinearLinkedBase`](LinearLinkedBase.md).[`_getReverseIterator`](LinearLinkedBase.md#_getreverseiterator)
2684
+
2685
+ ***