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