data-structure-typed 2.4.5 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) 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 +3 -1
  7. package/README.md +78 -31
  8. package/dist/cjs/binary-tree.cjs +23698 -0
  9. package/dist/cjs/graph.cjs +5236 -0
  10. package/dist/cjs/hash.cjs +1262 -0
  11. package/dist/cjs/heap.cjs +1540 -0
  12. package/dist/cjs/index.cjs +24509 -2899
  13. package/dist/cjs/linked-list.cjs +4370 -0
  14. package/dist/cjs/matrix.cjs +1042 -0
  15. package/dist/cjs/priority-queue.cjs +1314 -0
  16. package/dist/cjs/queue.cjs +4090 -0
  17. package/dist/cjs/stack.cjs +861 -0
  18. package/dist/cjs/trie.cjs +1173 -0
  19. package/dist/cjs-legacy/binary-tree.cjs +23730 -0
  20. package/dist/cjs-legacy/graph.cjs +5234 -0
  21. package/dist/cjs-legacy/hash.cjs +1262 -0
  22. package/dist/cjs-legacy/heap.cjs +1537 -0
  23. package/dist/cjs-legacy/index.cjs +32555 -10936
  24. package/dist/cjs-legacy/linked-list.cjs +4376 -0
  25. package/dist/cjs-legacy/matrix.cjs +1045 -0
  26. package/dist/cjs-legacy/priority-queue.cjs +1312 -0
  27. package/dist/cjs-legacy/queue.cjs +4088 -0
  28. package/dist/cjs-legacy/stack.cjs +861 -0
  29. package/dist/cjs-legacy/trie.cjs +1172 -0
  30. package/dist/esm/binary-tree.mjs +23683 -0
  31. package/dist/esm/graph.mjs +5223 -0
  32. package/dist/esm/hash.mjs +1259 -0
  33. package/dist/esm/heap.mjs +1534 -0
  34. package/dist/esm/index.mjs +24507 -2898
  35. package/dist/esm/linked-list.mjs +4363 -0
  36. package/dist/esm/matrix.mjs +1038 -0
  37. package/dist/esm/priority-queue.mjs +1310 -0
  38. package/dist/esm/queue.mjs +4086 -0
  39. package/dist/esm/stack.mjs +859 -0
  40. package/dist/esm/trie.mjs +1170 -0
  41. package/dist/esm-legacy/binary-tree.mjs +23715 -0
  42. package/dist/esm-legacy/graph.mjs +5221 -0
  43. package/dist/esm-legacy/hash.mjs +1259 -0
  44. package/dist/esm-legacy/heap.mjs +1531 -0
  45. package/dist/esm-legacy/index.mjs +32553 -10935
  46. package/dist/esm-legacy/linked-list.mjs +4369 -0
  47. package/dist/esm-legacy/matrix.mjs +1041 -0
  48. package/dist/esm-legacy/priority-queue.mjs +1308 -0
  49. package/dist/esm-legacy/queue.mjs +4084 -0
  50. package/dist/esm-legacy/stack.mjs +859 -0
  51. package/dist/esm-legacy/trie.mjs +1169 -0
  52. package/dist/types/data-structures/base/index.d.ts +1 -0
  53. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  54. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  55. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  56. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +368 -51
  57. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +473 -147
  58. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +931 -80
  59. package/dist/types/data-structures/binary-tree/bst.d.ts +792 -29
  60. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +592 -32
  61. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +320 -135
  62. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3662 -6
  63. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3487 -201
  64. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2778 -65
  65. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3414 -6
  66. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  67. package/dist/types/data-structures/graph/directed-graph.d.ts +419 -47
  68. package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
  69. package/dist/types/data-structures/graph/undirected-graph.d.ts +384 -59
  70. package/dist/types/data-structures/hash/hash-map.d.ts +462 -89
  71. package/dist/types/data-structures/heap/heap.d.ts +567 -99
  72. package/dist/types/data-structures/heap/max-heap.d.ts +46 -0
  73. package/dist/types/data-structures/heap/min-heap.d.ts +59 -0
  74. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +631 -49
  75. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +581 -68
  76. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +775 -12
  77. package/dist/types/data-structures/matrix/matrix.d.ts +491 -0
  78. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +57 -0
  79. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +60 -0
  80. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +60 -0
  81. package/dist/types/data-structures/queue/deque.d.ts +578 -71
  82. package/dist/types/data-structures/queue/queue.d.ts +451 -42
  83. package/dist/types/data-structures/stack/stack.d.ts +374 -32
  84. package/dist/types/data-structures/trie/trie.d.ts +458 -48
  85. package/dist/types/interfaces/graph.d.ts +1 -1
  86. package/dist/types/types/common.d.ts +2 -2
  87. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
  88. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  89. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
  90. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  91. package/dist/types/types/utils/validate-type.d.ts +4 -4
  92. package/dist/umd/data-structure-typed.js +32432 -10808
  93. package/dist/umd/data-structure-typed.min.js +10 -4
  94. package/docs-site-docusaurus/README.md +41 -0
  95. package/docs-site-docusaurus/docs/api/README.md +52 -0
  96. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +6130 -0
  97. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +282 -0
  98. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +2266 -0
  99. package/docs-site-docusaurus/docs/api/classes/BST.md +5831 -0
  100. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +333 -0
  101. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +455 -0
  102. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +4647 -0
  103. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +331 -0
  104. package/docs-site-docusaurus/docs/api/classes/Deque.md +2767 -0
  105. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +2999 -0
  106. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +2685 -0
  107. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +221 -0
  108. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +253 -0
  109. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +21 -0
  110. package/docs-site-docusaurus/docs/api/classes/HashMap.md +1333 -0
  111. package/docs-site-docusaurus/docs/api/classes/Heap.md +1881 -0
  112. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +800 -0
  113. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +644 -0
  114. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +1632 -0
  115. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +1853 -0
  116. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +1108 -0
  117. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +156 -0
  118. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +2824 -0
  119. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +2929 -0
  120. package/docs-site-docusaurus/docs/api/classes/Matrix.md +1026 -0
  121. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +1866 -0
  122. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +1883 -0
  123. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +1879 -0
  124. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +1882 -0
  125. package/docs-site-docusaurus/docs/api/classes/Navigator.md +109 -0
  126. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +1839 -0
  127. package/docs-site-docusaurus/docs/api/classes/Queue.md +2244 -0
  128. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +6374 -0
  129. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +372 -0
  130. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +2897 -0
  131. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +169 -0
  132. package/docs-site-docusaurus/docs/api/classes/SkipList.md +1229 -0
  133. package/docs-site-docusaurus/docs/api/classes/Stack.md +1573 -0
  134. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +1257 -0
  135. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +1475 -0
  136. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +1117 -0
  137. package/docs-site-docusaurus/docs/api/classes/Trie.md +1708 -0
  138. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +199 -0
  139. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +2979 -0
  140. package/docs-site-docusaurus/docs/guide/_category_.json +6 -0
  141. package/docs-site-docusaurus/docs/guide/architecture.md +613 -0
  142. package/docs-site-docusaurus/docs/guide/concepts.md +420 -0
  143. package/docs-site-docusaurus/docs/guide/guides.md +611 -0
  144. package/docs-site-docusaurus/docs/guide/installation.md +60 -0
  145. package/docs-site-docusaurus/docs/guide/integrations.md +823 -0
  146. package/docs-site-docusaurus/docs/guide/overview.md +638 -0
  147. package/docs-site-docusaurus/docs/guide/performance.md +833 -0
  148. package/docs-site-docusaurus/docs/guide/quick-start.md +73 -0
  149. package/docs-site-docusaurus/docusaurus.config.ts +159 -0
  150. package/docs-site-docusaurus/fix-mdx-generics.mjs +75 -0
  151. package/docs-site-docusaurus/package-lock.json +18667 -0
  152. package/docs-site-docusaurus/package.json +50 -0
  153. package/docs-site-docusaurus/prefix-class-to-methods.mjs +48 -0
  154. package/docs-site-docusaurus/sidebars.ts +23 -0
  155. package/docs-site-docusaurus/sort-protected.mjs +87 -0
  156. package/docs-site-docusaurus/src/css/custom.css +96 -0
  157. package/docs-site-docusaurus/src/pages/index.module.css +13 -0
  158. package/docs-site-docusaurus/src/pages/index.tsx +71 -0
  159. package/docs-site-docusaurus/src/pages/markdown-page.md +7 -0
  160. package/docs-site-docusaurus/src/theme/TOCItems/index.tsx +34 -0
  161. package/docs-site-docusaurus/static/.nojekyll +0 -0
  162. package/docs-site-docusaurus/static/img/docusaurus-social-card.jpg +0 -0
  163. package/docs-site-docusaurus/static/img/docusaurus.png +0 -0
  164. package/docs-site-docusaurus/static/img/favicon.ico +0 -0
  165. package/docs-site-docusaurus/static/img/favicon.png +0 -0
  166. package/docs-site-docusaurus/static/img/logo-180.png +0 -0
  167. package/docs-site-docusaurus/static/img/logo.jpg +0 -0
  168. package/docs-site-docusaurus/static/img/logo.png +0 -0
  169. package/docs-site-docusaurus/static/img/logo.svg +1 -0
  170. package/docs-site-docusaurus/static/img/og-image.png +0 -0
  171. package/docs-site-docusaurus/static/img/undraw_docusaurus_mountain.svg +171 -0
  172. package/docs-site-docusaurus/static/img/undraw_docusaurus_react.svg +170 -0
  173. package/docs-site-docusaurus/static/img/undraw_docusaurus_tree.svg +40 -0
  174. package/docs-site-docusaurus/static/robots.txt +4 -0
  175. package/docs-site-docusaurus/typedoc.json +23 -0
  176. package/package.json +109 -12
  177. package/src/data-structures/base/index.ts +1 -0
  178. package/src/data-structures/base/iterable-element-base.ts +4 -5
  179. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  180. package/src/data-structures/base/linear-base.ts +3 -3
  181. package/src/data-structures/binary-tree/avl-tree.ts +386 -51
  182. package/src/data-structures/binary-tree/binary-indexed-tree.ts +596 -247
  183. package/src/data-structures/binary-tree/binary-tree.ts +956 -81
  184. package/src/data-structures/binary-tree/bst.ts +840 -35
  185. package/src/data-structures/binary-tree/red-black-tree.ts +689 -97
  186. package/src/data-structures/binary-tree/segment-tree.ts +498 -249
  187. package/src/data-structures/binary-tree/tree-map.ts +3784 -7
  188. package/src/data-structures/binary-tree/tree-multi-map.ts +3614 -211
  189. package/src/data-structures/binary-tree/tree-multi-set.ts +2874 -65
  190. package/src/data-structures/binary-tree/tree-set.ts +3531 -10
  191. package/src/data-structures/graph/abstract-graph.ts +4 -4
  192. package/src/data-structures/graph/directed-graph.ts +429 -47
  193. package/src/data-structures/graph/map-graph.ts +59 -1
  194. package/src/data-structures/graph/undirected-graph.ts +393 -59
  195. package/src/data-structures/hash/hash-map.ts +476 -92
  196. package/src/data-structures/heap/heap.ts +581 -99
  197. package/src/data-structures/heap/max-heap.ts +46 -0
  198. package/src/data-structures/heap/min-heap.ts +59 -0
  199. package/src/data-structures/linked-list/doubly-linked-list.ts +646 -47
  200. package/src/data-structures/linked-list/singly-linked-list.ts +596 -68
  201. package/src/data-structures/linked-list/skip-linked-list.ts +1067 -90
  202. package/src/data-structures/matrix/matrix.ts +584 -12
  203. package/src/data-structures/priority-queue/max-priority-queue.ts +57 -0
  204. package/src/data-structures/priority-queue/min-priority-queue.ts +60 -0
  205. package/src/data-structures/priority-queue/priority-queue.ts +60 -0
  206. package/src/data-structures/queue/deque.ts +592 -70
  207. package/src/data-structures/queue/queue.ts +463 -42
  208. package/src/data-structures/stack/stack.ts +384 -32
  209. package/src/data-structures/trie/trie.ts +470 -48
  210. package/src/interfaces/graph.ts +1 -1
  211. package/src/types/common.ts +2 -2
  212. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
  213. package/src/types/data-structures/heap/heap.ts +1 -0
  214. package/src/types/data-structures/linked-list/skip-linked-list.ts +2 -1
  215. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  216. package/src/types/utils/validate-type.ts +4 -4
  217. package/vercel.json +6 -0
  218. package/dist/leetcode/avl-tree-counter.mjs +0 -2957
  219. package/dist/leetcode/avl-tree-multi-map.mjs +0 -2889
  220. package/dist/leetcode/avl-tree.mjs +0 -2720
  221. package/dist/leetcode/binary-tree.mjs +0 -1594
  222. package/dist/leetcode/bst.mjs +0 -2398
  223. package/dist/leetcode/deque.mjs +0 -683
  224. package/dist/leetcode/directed-graph.mjs +0 -1733
  225. package/dist/leetcode/doubly-linked-list.mjs +0 -709
  226. package/dist/leetcode/hash-map.mjs +0 -493
  227. package/dist/leetcode/heap.mjs +0 -542
  228. package/dist/leetcode/max-heap.mjs +0 -375
  229. package/dist/leetcode/max-priority-queue.mjs +0 -383
  230. package/dist/leetcode/min-heap.mjs +0 -363
  231. package/dist/leetcode/min-priority-queue.mjs +0 -371
  232. package/dist/leetcode/priority-queue.mjs +0 -363
  233. package/dist/leetcode/queue.mjs +0 -943
  234. package/dist/leetcode/red-black-tree.mjs +0 -2765
  235. package/dist/leetcode/singly-linked-list.mjs +0 -754
  236. package/dist/leetcode/stack.mjs +0 -217
  237. package/dist/leetcode/tree-counter.mjs +0 -3039
  238. package/dist/leetcode/tree-multi-map.mjs +0 -2913
  239. package/dist/leetcode/trie.mjs +0 -413
  240. package/dist/leetcode/undirected-graph.mjs +0 -1650
@@ -18,71 +18,6 @@ import { LinearBase } from '../base/linear-base';
18
18
  * 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).
19
19
  * 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
20
20
  * @example
21
- * // basic Deque creation and push/pop operations
22
- * // Create a simple Deque with initial values
23
- * const deque = new Deque([1, 2, 3, 4, 5]);
24
- *
25
- * // Verify the deque maintains insertion order
26
- * console.log([...deque]); // [1, 2, 3, 4, 5];
27
- *
28
- * // Check length
29
- * console.log(deque.length); // 5;
30
- *
31
- * // Push to the end
32
- * deque.push(6);
33
- * console.log(deque.length); // 6;
34
- *
35
- * // Pop from the end
36
- * const last = deque.pop();
37
- * console.log(last); // 6;
38
- * @example
39
- * // Deque shift and unshift operations
40
- * const deque = new Deque<number>([20, 30, 40]);
41
- *
42
- * // Unshift adds to the front
43
- * deque.unshift(10);
44
- * console.log([...deque]); // [10, 20, 30, 40];
45
- *
46
- * // Shift removes from the front (O(1) complexity!)
47
- * const first = deque.shift();
48
- * console.log(first); // 10;
49
- *
50
- * // Verify remaining elements
51
- * console.log([...deque]); // [20, 30, 40];
52
- * console.log(deque.length); // 3;
53
- * @example
54
- * // Deque peek at both ends
55
- * const deque = new Deque<number>([10, 20, 30, 40, 50]);
56
- *
57
- * // Get first element without removing
58
- * const first = deque.at(0);
59
- * console.log(first); // 10;
60
- *
61
- * // Get last element without removing
62
- * const last = deque.at(deque.length - 1);
63
- * console.log(last); // 50;
64
- *
65
- * // Length unchanged
66
- * console.log(deque.length); // 5;
67
- * @example
68
- * // Deque for...of iteration and reverse
69
- * const deque = new Deque<string>(['A', 'B', 'C', 'D']);
70
- *
71
- * // Iterate forward
72
- * const forward: string[] = [];
73
- * for (const item of deque) {
74
- * forward.push(item);
75
- * }
76
- * console.log(forward); // ['A', 'B', 'C', 'D'];
77
- *
78
- * // Reverse the deque
79
- * deque.reverse();
80
- * const backward: string[] = [];
81
- * for (const item of deque) {
82
- * backward.push(item);
83
- * }
84
- * console.log(backward); // ['D', 'C', 'B', 'A'];
85
- * @example
86
21
  * // Deque as sliding window for stream processing
87
22
  * interface DataPoint {
88
23
  * timestamp: number;
@@ -133,6 +68,10 @@ import { LinearBase } from '../base/linear-base';
133
68
  * console.log(windowResults[2].windowSize); // 3; // Windows are at max size from 3rd onwards
134
69
  * console.log(windowResults[4].windowSize); // 3; // Last window still has 3 elements
135
70
  * console.log(dataWindow.length); // 3;
71
+ * @example
72
+ * // Convert deque to array
73
+ * const dq = new Deque<number>([10, 20, 30]);
74
+ * console.log(dq.toArray()); // [10, 20, 30];
136
75
  */
137
76
  export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
138
77
  protected _equals: (a: E, b: E) => boolean;
@@ -227,12 +166,93 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
227
166
  * Get the first element without removing it.
228
167
  * @remarks Time O(1), Space O(1)
229
168
  * @returns First element or undefined.
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+ * @example
201
+ * // Deque peek at both ends
202
+ * const deque = new Deque<number>([10, 20, 30, 40, 50]);
203
+ *
204
+ * // Get first element without removing
205
+ * const first = deque.at(0);
206
+ * console.log(first); // 10;
207
+ *
208
+ * // Get last element without removing
209
+ * const last = deque.at(deque.length - 1);
210
+ * console.log(last); // 50;
211
+ *
212
+ * // Length unchanged
213
+ * console.log(deque.length); // 5;
230
214
  */
231
215
  get first(): E | undefined;
232
216
  /**
233
217
  * Get the last element without removing it.
234
218
  * @remarks Time O(1), Space O(1)
235
219
  * @returns Last element or undefined.
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+ * @example
252
+ * // Peek at the back element
253
+ * const dq = new Deque<string>(['a', 'b', 'c']);
254
+ * console.log(dq.last); // 'c';
255
+ * console.log(dq.first); // 'a';
236
256
  */
237
257
  get last(): E | undefined;
238
258
  /**
@@ -251,18 +271,139 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
251
271
  * @remarks Time O(1) amortized, Space O(1)
252
272
  * @param element - Element to append.
253
273
  * @returns True when appended.
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+ * @example
306
+ * // basic Deque creation and push/pop operations
307
+ * // Create a simple Deque with initial values
308
+ * const deque = new Deque([1, 2, 3, 4, 5]);
309
+ *
310
+ * // Verify the deque maintains insertion order
311
+ * console.log([...deque]); // [1, 2, 3, 4, 5];
312
+ *
313
+ * // Check length
314
+ * console.log(deque.length); // 5;
315
+ *
316
+ * // Push to the end
317
+ * deque.push(6);
318
+ * console.log(deque.length); // 6;
319
+ *
320
+ * // Pop from the end
321
+ * const last = deque.pop();
322
+ * console.log(last); // 6;
254
323
  */
255
324
  push(element: E): boolean;
256
325
  /**
257
326
  * Remove and return the last element.
258
327
  * @remarks Time O(1), Space O(1)
259
328
  * @returns Removed element or undefined.
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+ * @example
361
+ * // Remove from the back
362
+ * const dq = new Deque<number>([1, 2, 3]);
363
+ * console.log(dq.pop()); // 3;
364
+ * console.log(dq.length); // 2;
260
365
  */
261
366
  pop(): E | undefined;
262
367
  /**
263
368
  * Remove and return the first element.
264
369
  * @remarks Time O(1) amortized, Space O(1)
265
370
  * @returns Removed element or undefined.
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+ * @example
403
+ * // Remove from the front
404
+ * const dq = new Deque<number>([1, 2, 3]);
405
+ * console.log(dq.shift()); // 1;
406
+ * console.log(dq.length); // 2;
266
407
  */
267
408
  shift(): E | undefined;
268
409
  /**
@@ -270,6 +411,52 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
270
411
  * @remarks Time O(1) amortized, Space O(1)
271
412
  * @param element - Element to prepend.
272
413
  * @returns True when prepended.
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+
445
+ * @example
446
+ * // Deque shift and unshift operations
447
+ * const deque = new Deque<number>([20, 30, 40]);
448
+ *
449
+ * // Unshift adds to the front
450
+ * deque.unshift(10);
451
+ * console.log([...deque]); // [10, 20, 30, 40];
452
+ *
453
+ * // Shift removes from the front (O(1) complexity!)
454
+ * const first = deque.shift();
455
+ * console.log(first); // 10;
456
+ *
457
+ * // Verify remaining elements
458
+ * console.log([...deque]); // [20, 30, 40];
459
+ * console.log(deque.length); // 3;
273
460
  */
274
461
  unshift(element: E): boolean;
275
462
  /**
@@ -290,12 +477,79 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
290
477
  * Check whether the deque is empty.
291
478
  * @remarks Time O(1), Space O(1)
292
479
  * @returns True if length is 0.
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+ * @example
510
+ * // Check if empty
511
+ * const dq = new Deque();
512
+ * console.log(dq.isEmpty()); // true;
293
513
  */
294
514
  isEmpty(): boolean;
295
515
  /**
296
516
  * Remove all elements and reset structure.
297
517
  * @remarks Time O(1), Space O(1)
298
518
  * @returns void
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+ * @example
549
+ * // Remove all elements
550
+ * const dq = new Deque<number>([1, 2, 3]);
551
+ * dq.clear();
552
+ * console.log(dq.length); // 0;
299
553
  */
300
554
  clear(): void;
301
555
  /**
@@ -303,6 +557,39 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
303
557
  * @remarks Time O(1), Space O(1)
304
558
  * @param pos - Zero-based position from the front.
305
559
  * @returns Element or undefined.
560
+
561
+
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+
573
+
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+
588
+ * @example
589
+ * // Access by index
590
+ * const dq = new Deque<string>(['a', 'b', 'c']);
591
+ * console.log(dq.at(0)); // 'a';
592
+ * console.log(dq.at(2)); // 'c';
306
593
  */
307
594
  at(pos: number): E | undefined;
308
595
  /**
@@ -359,6 +646,39 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
359
646
  * @remarks Time O(N), Space O(1)
360
647
  * @param element - Element to remove (using the configured equality).
361
648
  * @returns True if an element was removed.
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+
662
+
663
+
664
+
665
+
666
+
667
+
668
+
669
+
670
+
671
+
672
+
673
+
674
+
675
+
676
+
677
+ * @example
678
+ * // Remove element
679
+ * const dq = new Deque<number>([1, 2, 3]);
680
+ * dq.delete(2);
681
+ * console.log(dq.length); // 2;
362
682
  */
363
683
  delete(element: E): boolean;
364
684
  /**
@@ -379,6 +699,55 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
379
699
  * Reverse the deque by reversing buckets and pointers.
380
700
  * @remarks Time O(N), Space O(N)
381
701
  * @returns This deque.
702
+
703
+
704
+
705
+
706
+
707
+
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+
721
+
722
+
723
+
724
+
725
+
726
+
727
+
728
+
729
+
730
+
731
+
732
+
733
+ * @example
734
+ * // Deque for...of iteration and reverse
735
+ * const deque = new Deque<string>(['A', 'B', 'C', 'D']);
736
+ *
737
+ * // Iterate forward
738
+ * const forward: string[] = [];
739
+ * for (const item of deque) {
740
+ * forward.push(item);
741
+ * }
742
+ * console.log(forward); // ['A', 'B', 'C', 'D'];
743
+ *
744
+ * // Reverse the deque
745
+ * deque.reverse();
746
+ * const backward: string[] = [];
747
+ * for (const item of deque) {
748
+ * backward.push(item);
749
+ * }
750
+ * console.log(backward); // ['D', 'C', 'B', 'A'];
382
751
  */
383
752
  reverse(): this;
384
753
  /**
@@ -407,6 +776,41 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
407
776
  * Compact the deque by removing unused buckets.
408
777
  * @remarks Time O(N), Space O(1)
409
778
  * @returns True if compaction was performed (bucket count reduced).
779
+
780
+
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+
790
+
791
+
792
+
793
+
794
+
795
+
796
+
797
+
798
+
799
+
800
+
801
+
802
+
803
+
804
+
805
+
806
+
807
+ * @example
808
+ * // Reclaim memory
809
+ * const dq = new Deque<number>([1, 2, 3, 4, 5]);
810
+ * dq.shift();
811
+ * dq.shift();
812
+ * dq.compact();
813
+ * console.log(dq.length); // 3;
410
814
  */
411
815
  compact(): boolean;
412
816
  shrinkToFit(): void;
@@ -414,6 +818,42 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
414
818
  * Deep clone this deque, preserving options.
415
819
  * @remarks Time O(N), Space O(N)
416
820
  * @returns A new deque with the same content and options.
821
+
822
+
823
+
824
+
825
+
826
+
827
+
828
+
829
+
830
+
831
+
832
+
833
+
834
+
835
+
836
+
837
+
838
+
839
+
840
+
841
+
842
+
843
+
844
+
845
+
846
+
847
+
848
+
849
+
850
+ * @example
851
+ * // Create independent copy
852
+ * const dq = new Deque<number>([1, 2, 3]);
853
+ * const copy = dq.clone();
854
+ * copy.pop();
855
+ * console.log(dq.length); // 3;
856
+ * console.log(copy.length); // 2;
417
857
  */
418
858
  clone(): this;
419
859
  /**
@@ -422,8 +862,42 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
422
862
  * @param predicate - Predicate (value, index, deque) → boolean to keep element.
423
863
  * @param [thisArg] - Value for `this` inside the predicate.
424
864
  * @returns A new deque with kept elements.
425
- */
426
- filter(predicate: ElementCallback<E, R, boolean>, thisArg?: any): this;
865
+
866
+
867
+
868
+
869
+
870
+
871
+
872
+
873
+
874
+
875
+
876
+
877
+
878
+
879
+
880
+
881
+
882
+
883
+
884
+
885
+
886
+
887
+
888
+
889
+
890
+
891
+
892
+
893
+
894
+ * @example
895
+ * // Filter elements
896
+ * const dq = new Deque<number>([1, 2, 3, 4]);
897
+ * const result = dq.filter(x => x > 2);
898
+ * console.log(result.length); // 2;
899
+ */
900
+ filter(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
427
901
  /**
428
902
  * Map elements into a new deque of the same element type.
429
903
  * @remarks Time O(N), Space O(N)
@@ -431,7 +905,7 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
431
905
  * @param [thisArg] - Value for `this` inside the callback.
432
906
  * @returns A new deque with mapped values.
433
907
  */
434
- mapSame(callback: ElementCallback<E, R, E>, thisArg?: any): this;
908
+ mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this;
435
909
  /**
436
910
  * Map elements into a new deque (possibly different element type).
437
911
  * @remarks Time O(N), Space O(N)
@@ -441,8 +915,41 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
441
915
  * @param [options] - Options for the output deque (e.g., bucketSize, toElementFn, maxLen).
442
916
  * @param [thisArg] - Value for `this` inside the callback.
443
917
  * @returns A new Deque with mapped elements.
444
- */
445
- map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: IterableElementBaseOptions<EM, RM>, thisArg?: any): Deque<EM, RM>;
918
+
919
+
920
+
921
+
922
+
923
+
924
+
925
+
926
+
927
+
928
+
929
+
930
+
931
+
932
+
933
+
934
+
935
+
936
+
937
+
938
+
939
+
940
+
941
+
942
+
943
+
944
+
945
+
946
+ * @example
947
+ * // Transform elements
948
+ * const dq = new Deque<number>([1, 2, 3]);
949
+ * const result = dq.map(x => x * 10);
950
+ * console.log(result.toArray()); // [10, 20, 30];
951
+ */
952
+ map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: IterableElementBaseOptions<EM, RM>, thisArg?: unknown): Deque<EM, RM>;
446
953
  /**
447
954
  * (Protected) Set the internal bucket size.
448
955
  * @remarks Time O(1), Space O(1)
@@ -489,7 +996,7 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
489
996
  * @param [options] - Options forwarded to the constructor.
490
997
  * @returns A like-kind Deque instance.
491
998
  */
492
- protected _createLike<T = E, RR = R>(elements?: IterableWithSizeOrLength<T> | IterableWithSizeOrLength<RR>, options?: DequeOptions<T, RR>): any;
999
+ protected _createLike<T = E, RR = R>(elements?: IterableWithSizeOrLength<T> | IterableWithSizeOrLength<RR>, options?: DequeOptions<T, RR>): Deque<T, RR>;
493
1000
  /**
494
1001
  * (Protected) Iterate elements from back to front.
495
1002
  * @remarks Time O(N), Space O(1)