deque-typed 2.1.0 → 2.1.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 (281) hide show
  1. package/dist/cjs/index.cjs +1223 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/esm/index.mjs +1219 -0
  4. package/dist/esm/index.mjs.map +1 -0
  5. package/dist/types/data-structures/base/index.d.ts +2 -1
  6. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +182 -2
  7. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +135 -2
  8. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +291 -2
  9. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +174 -1
  10. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +754 -29
  11. package/dist/types/data-structures/binary-tree/bst.d.ts +413 -12
  12. package/dist/types/data-structures/binary-tree/index.d.ts +3 -2
  13. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +208 -3
  14. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +160 -1
  15. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +190 -2
  16. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +270 -2
  17. package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -14
  18. package/dist/types/data-structures/graph/directed-graph.d.ts +207 -1
  19. package/dist/types/data-structures/graph/index.d.ts +2 -1
  20. package/dist/types/data-structures/graph/map-graph.d.ts +78 -1
  21. package/dist/types/data-structures/graph/undirected-graph.d.ts +188 -1
  22. package/dist/types/data-structures/hash/hash-map.d.ts +345 -19
  23. package/dist/types/data-structures/hash/index.d.ts +0 -1
  24. package/dist/types/data-structures/heap/heap.d.ts +503 -5
  25. package/dist/types/data-structures/heap/index.d.ts +2 -0
  26. package/dist/types/data-structures/heap/max-heap.d.ts +32 -1
  27. package/dist/types/data-structures/heap/min-heap.d.ts +33 -1
  28. package/dist/types/data-structures/index.d.ts +7 -7
  29. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +769 -2
  30. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +451 -2
  31. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -4
  32. package/dist/types/data-structures/matrix/index.d.ts +1 -1
  33. package/dist/types/data-structures/matrix/matrix.d.ts +168 -7
  34. package/dist/types/data-structures/matrix/navigator.d.ts +54 -13
  35. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -1
  36. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -1
  37. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -2
  38. package/dist/types/data-structures/queue/deque.d.ts +431 -4
  39. package/dist/types/data-structures/queue/queue.d.ts +308 -4
  40. package/dist/types/data-structures/stack/stack.d.ts +306 -2
  41. package/dist/types/data-structures/tree/tree.d.ts +62 -1
  42. package/dist/types/data-structures/trie/trie.d.ts +350 -4
  43. package/dist/types/index.d.ts +11 -2
  44. package/dist/{interfaces → types/interfaces}/binary-tree.d.ts +3 -3
  45. package/dist/types/types/data-structures/base/index.d.ts +1 -0
  46. package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  47. package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
  48. package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
  49. package/dist/types/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
  50. package/dist/types/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
  51. package/dist/types/types/data-structures/binary-tree/bst.d.ts +12 -0
  52. package/dist/{data-structures → types/types/data-structures}/binary-tree/index.d.ts +2 -3
  53. package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
  54. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
  55. package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  56. package/dist/types/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
  57. package/dist/types/types/data-structures/graph/abstract-graph.d.ts +14 -0
  58. package/dist/types/types/data-structures/graph/directed-graph.d.ts +1 -0
  59. package/dist/{data-structures → types/types/data-structures}/graph/index.d.ts +1 -2
  60. package/dist/types/types/data-structures/graph/map-graph.d.ts +1 -0
  61. package/dist/types/types/data-structures/graph/undirected-graph.d.ts +1 -0
  62. package/dist/types/types/data-structures/hash/hash-map.d.ts +19 -0
  63. package/dist/types/types/data-structures/hash/index.d.ts +2 -0
  64. package/dist/types/types/data-structures/heap/heap.d.ts +5 -0
  65. package/dist/types/types/data-structures/heap/index.d.ts +1 -0
  66. package/dist/types/types/data-structures/heap/max-heap.d.ts +1 -0
  67. package/dist/types/types/data-structures/heap/min-heap.d.ts +1 -0
  68. package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -0
  69. package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +2 -0
  70. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +4 -0
  71. package/dist/types/types/data-structures/matrix/matrix.d.ts +7 -0
  72. package/dist/types/types/data-structures/matrix/navigator.d.ts +14 -0
  73. package/dist/types/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
  74. package/dist/types/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
  75. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +2 -0
  76. package/dist/types/types/data-structures/queue/deque.d.ts +4 -0
  77. package/dist/types/types/data-structures/queue/queue.d.ts +4 -0
  78. package/dist/types/types/data-structures/stack/stack.d.ts +2 -0
  79. package/dist/types/types/data-structures/tree/tree.d.ts +1 -0
  80. package/dist/types/types/data-structures/trie/trie.d.ts +4 -0
  81. package/dist/types/types/index.d.ts +3 -0
  82. package/dist/types/types/utils/index.d.ts +2 -0
  83. package/dist/types/types/utils/utils.d.ts +22 -0
  84. package/dist/types/utils/index.d.ts +1 -1
  85. package/dist/types/utils/utils.d.ts +209 -22
  86. package/dist/umd/deque-typed.js +1232 -0
  87. package/dist/umd/deque-typed.js.map +1 -0
  88. package/dist/umd/deque-typed.min.js +9 -0
  89. package/dist/umd/deque-typed.min.js.map +1 -0
  90. package/package.json +25 -5
  91. package/src/data-structures/binary-tree/avl-tree-counter.ts +8 -11
  92. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +6 -11
  93. package/src/data-structures/binary-tree/avl-tree.ts +6 -8
  94. package/src/data-structures/binary-tree/binary-tree.ts +13 -15
  95. package/src/data-structures/binary-tree/bst.ts +6 -11
  96. package/src/data-structures/binary-tree/red-black-tree.ts +6 -11
  97. package/src/data-structures/binary-tree/tree-counter.ts +8 -13
  98. package/src/data-structures/binary-tree/tree-multi-map.ts +6 -11
  99. package/src/data-structures/heap/heap.ts +5 -5
  100. package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
  101. package/src/interfaces/binary-tree.ts +3 -3
  102. package/tsconfig.base.json +23 -0
  103. package/tsconfig.json +8 -34
  104. package/tsconfig.test.json +8 -0
  105. package/tsconfig.types.json +15 -0
  106. package/tsup.config.js +28 -0
  107. package/tsup.node.config.js +37 -0
  108. package/dist/common/index.js +0 -28
  109. package/dist/constants/index.js +0 -8
  110. package/dist/data-structures/base/index.d.ts +0 -2
  111. package/dist/data-structures/base/index.js +0 -18
  112. package/dist/data-structures/base/iterable-element-base.js +0 -243
  113. package/dist/data-structures/base/iterable-entry-base.js +0 -183
  114. package/dist/data-structures/base/linear-base.js +0 -415
  115. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +0 -182
  116. package/dist/data-structures/binary-tree/avl-tree-counter.js +0 -374
  117. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -135
  118. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +0 -250
  119. package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -291
  120. package/dist/data-structures/binary-tree/avl-tree.js +0 -611
  121. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
  122. package/dist/data-structures/binary-tree/binary-indexed-tree.js +0 -294
  123. package/dist/data-structures/binary-tree/binary-tree.d.ts +0 -754
  124. package/dist/data-structures/binary-tree/binary-tree.js +0 -1925
  125. package/dist/data-structures/binary-tree/bst.d.ts +0 -413
  126. package/dist/data-structures/binary-tree/bst.js +0 -903
  127. package/dist/data-structures/binary-tree/index.js +0 -26
  128. package/dist/data-structures/binary-tree/red-black-tree.d.ts +0 -208
  129. package/dist/data-structures/binary-tree/red-black-tree.js +0 -546
  130. package/dist/data-structures/binary-tree/segment-tree.d.ts +0 -160
  131. package/dist/data-structures/binary-tree/segment-tree.js +0 -297
  132. package/dist/data-structures/binary-tree/tree-counter.d.ts +0 -190
  133. package/dist/data-structures/binary-tree/tree-counter.js +0 -413
  134. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +0 -270
  135. package/dist/data-structures/binary-tree/tree-multi-map.js +0 -384
  136. package/dist/data-structures/graph/abstract-graph.d.ts +0 -340
  137. package/dist/data-structures/graph/abstract-graph.js +0 -896
  138. package/dist/data-structures/graph/directed-graph.d.ts +0 -207
  139. package/dist/data-structures/graph/directed-graph.js +0 -525
  140. package/dist/data-structures/graph/index.js +0 -20
  141. package/dist/data-structures/graph/map-graph.d.ts +0 -78
  142. package/dist/data-structures/graph/map-graph.js +0 -107
  143. package/dist/data-structures/graph/undirected-graph.d.ts +0 -188
  144. package/dist/data-structures/graph/undirected-graph.js +0 -424
  145. package/dist/data-structures/hash/hash-map.d.ts +0 -345
  146. package/dist/data-structures/hash/hash-map.js +0 -692
  147. package/dist/data-structures/hash/index.d.ts +0 -1
  148. package/dist/data-structures/hash/index.js +0 -17
  149. package/dist/data-structures/heap/heap.d.ts +0 -503
  150. package/dist/data-structures/heap/heap.js +0 -901
  151. package/dist/data-structures/heap/index.d.ts +0 -3
  152. package/dist/data-structures/heap/index.js +0 -19
  153. package/dist/data-structures/heap/max-heap.d.ts +0 -32
  154. package/dist/data-structures/heap/max-heap.js +0 -40
  155. package/dist/data-structures/heap/min-heap.d.ts +0 -33
  156. package/dist/data-structures/heap/min-heap.js +0 -31
  157. package/dist/data-structures/index.js +0 -28
  158. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -769
  159. package/dist/data-structures/linked-list/doubly-linked-list.js +0 -1111
  160. package/dist/data-structures/linked-list/index.js +0 -19
  161. package/dist/data-structures/linked-list/singly-linked-list.d.ts +0 -451
  162. package/dist/data-structures/linked-list/singly-linked-list.js +0 -850
  163. package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -27
  164. package/dist/data-structures/linked-list/skip-linked-list.js +0 -144
  165. package/dist/data-structures/matrix/index.js +0 -18
  166. package/dist/data-structures/matrix/matrix.d.ts +0 -168
  167. package/dist/data-structures/matrix/matrix.js +0 -448
  168. package/dist/data-structures/matrix/navigator.d.ts +0 -55
  169. package/dist/data-structures/matrix/navigator.js +0 -111
  170. package/dist/data-structures/priority-queue/index.js +0 -19
  171. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +0 -27
  172. package/dist/data-structures/priority-queue/max-priority-queue.js +0 -34
  173. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +0 -26
  174. package/dist/data-structures/priority-queue/min-priority-queue.js +0 -24
  175. package/dist/data-structures/priority-queue/priority-queue.d.ts +0 -15
  176. package/dist/data-structures/priority-queue/priority-queue.js +0 -20
  177. package/dist/data-structures/queue/deque.d.ts +0 -431
  178. package/dist/data-structures/queue/deque.js +0 -879
  179. package/dist/data-structures/queue/index.js +0 -18
  180. package/dist/data-structures/queue/queue.d.ts +0 -308
  181. package/dist/data-structures/queue/queue.js +0 -473
  182. package/dist/data-structures/stack/index.js +0 -17
  183. package/dist/data-structures/stack/stack.d.ts +0 -306
  184. package/dist/data-structures/stack/stack.js +0 -401
  185. package/dist/data-structures/tree/index.js +0 -17
  186. package/dist/data-structures/tree/tree.d.ts +0 -62
  187. package/dist/data-structures/tree/tree.js +0 -107
  188. package/dist/data-structures/trie/index.js +0 -17
  189. package/dist/data-structures/trie/trie.d.ts +0 -350
  190. package/dist/data-structures/trie/trie.js +0 -610
  191. package/dist/index.d.ts +0 -12
  192. package/dist/index.js +0 -28
  193. package/dist/interfaces/binary-tree.js +0 -2
  194. package/dist/interfaces/doubly-linked-list.js +0 -2
  195. package/dist/interfaces/graph.js +0 -2
  196. package/dist/interfaces/heap.js +0 -2
  197. package/dist/interfaces/index.js +0 -24
  198. package/dist/interfaces/navigator.js +0 -2
  199. package/dist/interfaces/priority-queue.js +0 -2
  200. package/dist/interfaces/segment-tree.js +0 -2
  201. package/dist/interfaces/singly-linked-list.js +0 -2
  202. package/dist/types/common.js +0 -2
  203. package/dist/types/data-structures/base/base.js +0 -2
  204. package/dist/types/data-structures/base/index.js +0 -17
  205. package/dist/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
  206. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
  207. package/dist/types/data-structures/binary-tree/avl-tree.js +0 -2
  208. package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
  209. package/dist/types/data-structures/binary-tree/binary-tree.js +0 -2
  210. package/dist/types/data-structures/binary-tree/bst.js +0 -2
  211. package/dist/types/data-structures/binary-tree/index.js +0 -25
  212. package/dist/types/data-structures/binary-tree/red-black-tree.js +0 -2
  213. package/dist/types/data-structures/binary-tree/segment-tree.js +0 -2
  214. package/dist/types/data-structures/binary-tree/tree-counter.js +0 -2
  215. package/dist/types/data-structures/binary-tree/tree-multi-map.js +0 -2
  216. package/dist/types/data-structures/graph/abstract-graph.js +0 -2
  217. package/dist/types/data-structures/graph/directed-graph.js +0 -2
  218. package/dist/types/data-structures/graph/index.js +0 -19
  219. package/dist/types/data-structures/graph/map-graph.js +0 -2
  220. package/dist/types/data-structures/graph/undirected-graph.js +0 -2
  221. package/dist/types/data-structures/hash/hash-map.js +0 -2
  222. package/dist/types/data-structures/hash/index.js +0 -17
  223. package/dist/types/data-structures/heap/heap.js +0 -2
  224. package/dist/types/data-structures/heap/index.js +0 -17
  225. package/dist/types/data-structures/heap/max-heap.js +0 -2
  226. package/dist/types/data-structures/heap/min-heap.js +0 -2
  227. package/dist/types/data-structures/index.js +0 -28
  228. package/dist/types/data-structures/linked-list/doubly-linked-list.js +0 -2
  229. package/dist/types/data-structures/linked-list/index.js +0 -19
  230. package/dist/types/data-structures/linked-list/singly-linked-list.js +0 -2
  231. package/dist/types/data-structures/linked-list/skip-linked-list.js +0 -2
  232. package/dist/types/data-structures/matrix/index.js +0 -18
  233. package/dist/types/data-structures/matrix/matrix.js +0 -2
  234. package/dist/types/data-structures/matrix/navigator.js +0 -2
  235. package/dist/types/data-structures/priority-queue/index.js +0 -19
  236. package/dist/types/data-structures/priority-queue/max-priority-queue.js +0 -2
  237. package/dist/types/data-structures/priority-queue/min-priority-queue.js +0 -2
  238. package/dist/types/data-structures/priority-queue/priority-queue.js +0 -2
  239. package/dist/types/data-structures/queue/deque.js +0 -2
  240. package/dist/types/data-structures/queue/index.js +0 -18
  241. package/dist/types/data-structures/queue/queue.js +0 -2
  242. package/dist/types/data-structures/stack/index.js +0 -17
  243. package/dist/types/data-structures/stack/stack.js +0 -2
  244. package/dist/types/data-structures/tree/index.js +0 -17
  245. package/dist/types/data-structures/tree/tree.js +0 -2
  246. package/dist/types/data-structures/trie/index.js +0 -17
  247. package/dist/types/data-structures/trie/trie.js +0 -2
  248. package/dist/types/index.js +0 -19
  249. package/dist/types/utils/index.js +0 -18
  250. package/dist/types/utils/utils.js +0 -2
  251. package/dist/types/utils/validate-type.js +0 -2
  252. package/dist/utils/index.d.ts +0 -2
  253. package/dist/utils/index.js +0 -18
  254. package/dist/utils/number.js +0 -24
  255. package/dist/utils/utils.d.ts +0 -209
  256. package/dist/utils/utils.js +0 -353
  257. package/dist/{common → types/common}/index.d.ts +0 -0
  258. package/dist/{constants → types/constants}/index.d.ts +0 -0
  259. package/dist/{data-structures → types/data-structures}/base/iterable-element-base.d.ts +0 -0
  260. package/dist/{data-structures → types/data-structures}/base/iterable-entry-base.d.ts +0 -0
  261. package/dist/{data-structures → types/data-structures}/base/linear-base.d.ts +0 -0
  262. package/dist/{interfaces → types/interfaces}/doubly-linked-list.d.ts +0 -0
  263. package/dist/{interfaces → types/interfaces}/graph.d.ts +0 -0
  264. package/dist/{interfaces → types/interfaces}/heap.d.ts +0 -0
  265. package/dist/{interfaces → types/interfaces}/index.d.ts +0 -0
  266. package/dist/{interfaces → types/interfaces}/navigator.d.ts +0 -0
  267. package/dist/{interfaces → types/interfaces}/priority-queue.d.ts +0 -0
  268. package/dist/{interfaces → types/interfaces}/segment-tree.d.ts +0 -0
  269. package/dist/{interfaces → types/interfaces}/singly-linked-list.d.ts +0 -0
  270. package/dist/types/{common.d.ts → types/common.d.ts} +0 -0
  271. package/dist/types/{data-structures → types/data-structures}/base/base.d.ts +0 -0
  272. package/dist/{data-structures → types/types/data-structures}/index.d.ts +7 -7
  273. package/dist/{data-structures → types/types/data-structures}/linked-list/index.d.ts +0 -0
  274. package/dist/{data-structures → types/types/data-structures}/matrix/index.d.ts +1 -1
  275. /package/dist/{data-structures → types/types/data-structures}/priority-queue/index.d.ts +0 -0
  276. /package/dist/{data-structures → types/types/data-structures}/queue/index.d.ts +0 -0
  277. /package/dist/{data-structures → types/types/data-structures}/stack/index.d.ts +0 -0
  278. /package/dist/{data-structures → types/types/data-structures}/tree/index.d.ts +0 -0
  279. /package/dist/{data-structures → types/types/data-structures}/trie/index.d.ts +0 -0
  280. /package/dist/types/{utils → types/utils}/validate-type.d.ts +0 -0
  281. /package/dist/{utils → types/utils}/number.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/utils.ts","../../src/data-structures/base/iterable-element-base.ts","../../src/data-structures/base/linear-base.ts","../../src/data-structures/queue/deque.ts","../../src/common/index.ts"],"names":["DFSOperation"],"mappings":";;;;;;;;AA+EO,IAAM,6BAAa,MAAA,CAAA,CAAC,KAAA,EAAe,GAAA,EAAa,GAAA,EAAa,UAAU,sBAAA,KAAiC;AAC7G,EAAA,IAAI,QAAQ,GAAA,IAAO,KAAA,GAAQ,KAAK,MA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ACA,UAAA,GAAsB,IAAA,EACtB,cAAuB,IAAA,EAC9B;AAJO,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AACA,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,WAAA,GAAA,WAAA;AAEP,IAAA,IAAI,EAAE,YAAA,CAAa,GAAG,CAAA,IAAK,YAAA,CAAa,IAAI,CAAA,CAAA,EAAI,MAAM,IAAI,UAAA,CAAW,+BAA+B,CAAA;AACpG,IAAA,IAAI,GAAA,GAAM,IAAA,EAAM,MAAM,IAAI,WAAW,wCAAwC,CAAA;AAAA,EAC/E;AAAA;AAAA,EAGA,SAAA,CAAU,KAAQ,UAAA,EAA6C;AAC7D,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,UAAA,GAAa,UAAA,CAAW,GAAA,EAAK,IAAA,CAAK,GAAG,CAAA,IAAK,CAAA,GAAI,UAAA,CAAW,GAAA,EAAK,IAAA,CAAK,GAAG,CAAA,GAAI,CAAA;AAChG,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,WAAA,GAAc,UAAA,CAAW,GAAA,EAAK,IAAA,CAAK,IAAI,CAAA,IAAK,CAAA,GAAI,UAAA,CAAW,GAAA,EAAK,IAAA,CAAK,IAAI,CAAA,GAAI,CAAA;AACpG,IAAA,OAAO,QAAA,IAAY,SAAA;AAAA,EACrB;AACF,CAAA;AAjBsB,MAAA,CAAA,MAAA,EAAA,OAAA,CAAA;AAAf,IAAM,KAAA,GAAN","file":"index.cjs","sourcesContent":["/**\n * data-structure-typed\n *\n * @author Pablo Zeng\n * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>\n * @license MIT License\n */\nimport type { Comparable, ComparablePrimitive, Trampoline, TrampolineThunk } from '../types';\n\n/**\n * The function generates a random UUID (Universally Unique Identifier) in TypeScript.\n * @returns A randomly generated UUID (Universally Unique Identifier) in the format\n * 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' where each 'x' is replaced with a random hexadecimal\n * character.\n */\nexport const uuidV4 = function () {\n return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {\n const r = (Math.random() * 16) | 0,\n v = c == 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n};\n\n/**\n * The `arrayRemove` function removes elements from an array based on a specified predicate function\n * and returns the removed elements.\n * @param {T[]} array - An array of elements that you want to filter based on the provided predicate\n * function.\n * @param predicate - The `predicate` parameter is a function that takes three arguments:\n * @returns The `arrayRemove` function returns an array containing the elements that satisfy the given\n * `predicate` function.\n */\nexport const arrayRemove = function <T>(array: T[], predicate: (item: T, index: number, array: T[]) => boolean): T[] {\n let i = -1,\n len = array ? array.length : 0;\n const result = [];\n\n while (++i < len) {\n const value = array[i];\n if (predicate(value, i, array)) {\n result.push(value);\n Array.prototype.splice.call(array, i--, 1);\n len--;\n }\n }\n\n return result;\n};\n\n/**\n * The function `getMSB` returns the most significant bit of a given number.\n * @param {number} value - The `value` parameter is a number for which we want to find the position of\n * the Most Significant Bit (MSB). The function `getMSB` takes this number as input and calculates the\n * position of the MSB in its binary representation.\n * @returns The function `getMSB` returns the most significant bit (MSB) of the input `value`. If the\n * input value is less than or equal to 0, it returns 0. Otherwise, it calculates the position of the\n * MSB using the `Math.clz32` function and bitwise left shifts 1 to that position.\n */\nexport const getMSB = (value: number): number => {\n if (value <= 0) {\n return 0;\n }\n return 1 << (31 - Math.clz32(value));\n};\n\n/**\n * The `rangeCheck` function in TypeScript is used to validate if an index is within a specified range\n * and throws a `RangeError` with a custom message if it is out of bounds.\n * @param {number} index - The `index` parameter represents the value that you want to check if it\n * falls within a specified range.\n * @param {number} min - The `min` parameter represents the minimum value that the `index` should be\n * compared against in the `rangeCheck` function.\n * @param {number} max - The `max` parameter in the `rangeCheck` function represents the maximum value\n * that the `index` parameter is allowed to have. If the `index` is greater than this `max` value, a\n * `RangeError` will be thrown.\n * @param [message=Index out of bounds.] - The `message` parameter is a string that represents the\n * error message to be thrown if the index is out of bounds. By default, if no message is provided when\n * calling the `rangeCheck` function, the message \"Index out of bounds.\" will be used.\n */\nexport const rangeCheck = (index: number, min: number, max: number, message = 'Index out of bounds.'): void => {\n if (index < min || index > max) throw new RangeError(message);\n};\n\n/**\n * The function `throwRangeError` throws a RangeError with a custom message if called.\n * @param [message=The value is off-limits.] - The `message` parameter is a string that represents the\n * error message to be displayed when a `RangeError` is thrown. If no message is provided, the default\n * message is 'The value is off-limits.'.\n */\nexport const throwRangeError = (message = 'The value is off-limits.'): void => {\n throw new RangeError(message);\n};\n\n/**\n * The function `isWeakKey` checks if the input is an object or a function in TypeScript.\n * @param {unknown} input - The `input` parameter in the `isWeakKey` function is of type `unknown`,\n * which means it can be any type. The function checks if the `input` is an object (excluding `null`)\n * or a function, and returns a boolean indicating whether the `input` is a weak\n * @returns The function `isWeakKey` returns a boolean value indicating whether the input is an object\n * or a function.\n */\nexport const isWeakKey = (input: unknown): input is object => {\n const inputType = typeof input;\n return (inputType === 'object' && input !== null) || inputType === 'function';\n};\n\n/**\n * The function `calcMinUnitsRequired` calculates the minimum number of units required to accommodate a\n * given total quantity based on a specified unit size.\n * @param {number} totalQuantity - The `totalQuantity` parameter represents the total quantity of items\n * that need to be processed or handled.\n * @param {number} unitSize - The `unitSize` parameter represents the size of each unit or package. It\n * is used in the `calcMinUnitsRequired` function to calculate the minimum number of units required to\n * accommodate a total quantity of items.\n */\nexport const calcMinUnitsRequired = (totalQuantity: number, unitSize: number) =>\n Math.floor((totalQuantity + unitSize - 1) / unitSize);\n\n/**\n * The `roundFixed` function in TypeScript rounds a number to a specified number of decimal places.\n * @param {number} num - The `num` parameter is a number that you want to round to a certain number of\n * decimal places.\n * @param {number} [digit=10] - The `digit` parameter in the `roundFixed` function specifies the number\n * of decimal places to round the number to. By default, it is set to 10 if not provided explicitly.\n * @returns The function `roundFixed` returns a number that is rounded to the specified number of\n * decimal places (default is 10 decimal places).\n */\nexport const roundFixed = (num: number, digit: number = 10) => {\n const multiplier = Math.pow(10, digit);\n return Math.round(num * multiplier) / multiplier;\n};\n\n/**\n * The function `isPrimitiveComparable` checks if a value is a primitive type that can be compared.\n * @param {unknown} value - The `value` parameter in the `isPrimitiveComparable` function is of type\n * `unknown`, which means it can be any type. The function checks if the `value` is a primitive type\n * that can be compared, such as number, bigint, string, or boolean.\n * @returns The function `isPrimitiveComparable` returns a boolean value indicating whether the input\n * `value` is a primitive value that can be compared using standard comparison operators (<, >, <=,\n * >=).\n */\nfunction isPrimitiveComparable(value: unknown): value is ComparablePrimitive {\n const valueType = typeof value;\n if (valueType === 'number') return true;\n // if (valueType === 'number') return !Number.isNaN(value);\n return valueType === 'bigint' || valueType === 'string' || valueType === 'boolean';\n}\n\n/**\n * The function `tryObjectToPrimitive` attempts to convert an object to a comparable primitive value by\n * first checking the `valueOf` method and then the `toString` method.\n * @param {object} obj - The `obj` parameter in the `tryObjectToPrimitive` function is an object that\n * you want to convert to a primitive value. The function attempts to convert the object to a primitive\n * value by first checking if the object has a `valueOf` method. If the `valueOf` method exists, it\n * @returns The function `tryObjectToPrimitive` returns a value of type `ComparablePrimitive` if a\n * primitive comparable value is found within the object, or a string value if the object has a custom\n * `toString` method that does not return `'[object Object]'`. If neither condition is met, the\n * function returns `null`.\n */\nfunction tryObjectToPrimitive(obj: object): ComparablePrimitive | null {\n if (typeof obj.valueOf === 'function') {\n const valueOfResult = obj.valueOf();\n if (valueOfResult !== obj) {\n if (isPrimitiveComparable(valueOfResult)) return valueOfResult;\n if (typeof valueOfResult === 'object' && valueOfResult !== null) return tryObjectToPrimitive(valueOfResult);\n }\n }\n if (typeof obj.toString === 'function') {\n const stringResult = obj.toString();\n if (stringResult !== '[object Object]') return stringResult;\n }\n return null;\n}\n\n/**\n * The function `isComparable` in TypeScript checks if a value is comparable, handling primitive values\n * and objects with optional force comparison.\n * @param {unknown} value - The `value` parameter in the `isComparable` function represents the value\n * that you want to check if it is comparable. It can be of any type (`unknown`), and the function will\n * determine if it is comparable based on certain conditions.\n * @param [isForceObjectComparable=false] - The `isForceObjectComparable` parameter in the\n * `isComparable` function is a boolean flag that determines whether to treat non-primitive values as\n * comparable objects. When set to `true`, it forces the function to consider non-primitive values as\n * comparable objects, regardless of their type.\n * @returns The function `isComparable` returns a boolean value indicating whether the `value` is\n * considered comparable or not.\n */\nexport function isComparable(value: unknown, isForceObjectComparable = false): value is Comparable {\n if (value === null || value === undefined) return false;\n if (isPrimitiveComparable(value)) return true;\n\n if (typeof value !== 'object') return false;\n if (value instanceof Date) return true;\n // if (value instanceof Date) return !Number.isNaN(value.getTime());\n if (isForceObjectComparable) return true;\n const comparableValue = tryObjectToPrimitive(value);\n if (comparableValue === null || comparableValue === undefined) return false;\n return isPrimitiveComparable(comparableValue);\n}\n\n/**\n * Creates a trampoline thunk object.\n *\n * A \"thunk\" is a deferred computation — instead of performing a recursive call immediately,\n * it wraps the next step of the computation in a function. This allows recursive processes\n * to be executed iteratively, preventing stack overflows.\n *\n * @template T - The type of the final computation result.\n * @param computation - A function that, when executed, returns the next trampoline step.\n * @returns A TrampolineThunk object containing the deferred computation.\n */\nexport const makeTrampolineThunk = <T>(computation: () => Trampoline<T>): TrampolineThunk<T> => ({\n isThunk: true, // Marker indicating this is a thunk\n fn: computation // The deferred computation function\n});\n\n/**\n * Type guard to check whether a given value is a TrampolineThunk.\n *\n * This function is used to distinguish between a final computation result (value)\n * and a deferred computation (thunk).\n *\n * @template T - The type of the value being checked.\n * @param value - The value to test.\n * @returns True if the value is a valid TrampolineThunk, false otherwise.\n */\nexport const isTrampolineThunk = <T>(value: Trampoline<T>): value is TrampolineThunk<T> =>\n typeof value === 'object' && // Must be an object\n value !== null && // Must not be null\n 'isThunk' in value && // Must have the 'isThunk' property\n value.isThunk; // The flag must be true\n\n/**\n * Executes a trampoline computation until a final (non-thunk) result is obtained.\n *\n * The trampoline function repeatedly invokes the deferred computations (thunks)\n * in an iterative loop. This avoids deep recursive calls and prevents stack overflow,\n * which is particularly useful for implementing recursion in a stack-safe manner.\n *\n * @template T - The type of the final result.\n * @param initial - The initial Trampoline value or thunk to start execution from.\n * @returns The final result of the computation (a non-thunk value).\n */\nexport function trampoline<T>(initial: Trampoline<T>): T {\n let current = initial; // Start with the initial trampoline value\n while (isTrampolineThunk(current)) {\n // Keep unwrapping while we have thunks\n current = current.fn(); // Execute the deferred function to get the next step\n }\n return current; // Once no thunks remain, return the final result\n}\n\n/**\n * Wraps a recursive function inside a trampoline executor.\n *\n * This function transforms a potentially recursive function (that returns a Trampoline<Result>)\n * into a *stack-safe* function that executes iteratively using the `trampoline` runner.\n *\n * In other words, it allows you to write functions that look recursive,\n * but actually run in constant stack space.\n *\n * @template Args - The tuple type representing the argument list of the original function.\n * @template Result - The final return type after all trampoline steps are resolved.\n *\n * @param fn - A function that performs a single step of computation\n * and returns a Trampoline (either a final value or a deferred thunk).\n *\n * @returns A new function with the same arguments, but which automatically\n * runs the trampoline process and returns the *final result* instead\n * of a Trampoline.\n *\n * @example\n * // Example: Computing factorial in a stack-safe way\n * const factorial = makeTrampoline(function fact(n: number, acc: number = 1): Trampoline<number> {\n * return n === 0\n * ? acc\n * : makeTrampolineThunk(() => fact(n - 1, acc * n));\n * });\n *\n * console.log(factorial(100000)); // Works without stack overflow\n */\nexport function makeTrampoline<Args extends any[], Result>(\n fn: (...args: Args) => Trampoline<Result> // A function that returns a trampoline step\n): (...args: Args) => Result {\n // Return a wrapped function that automatically runs the trampoline execution loop\n return (...args: Args) => trampoline(fn(...args));\n}\n\n/**\n * Executes an asynchronous trampoline computation until a final (non-thunk) result is obtained.\n *\n * This function repeatedly invokes asynchronous deferred computations (thunks)\n * in an iterative loop. Each thunk may return either a Trampoline<T> or a Promise<Trampoline<T>>.\n *\n * It ensures that asynchronous recursive functions can run without growing the call stack,\n * making it suitable for stack-safe async recursion.\n *\n * @template T - The type of the final result.\n * @param initial - The initial Trampoline or Promise of Trampoline to start execution from.\n * @returns A Promise that resolves to the final result (a non-thunk value).\n */\nexport async function asyncTrampoline<T>(initial: Trampoline<T> | Promise<Trampoline<T>>): Promise<T> {\n let current = await initial; // Wait for the initial step to resolve if it's a Promise\n\n // Keep executing thunks until we reach a non-thunk (final) value\n while (isTrampolineThunk(current)) {\n current = await current.fn(); // Execute the thunk function (may be async)\n }\n\n // Once the final value is reached, return it\n return current;\n}\n\n/**\n * Wraps an asynchronous recursive function inside an async trampoline executor.\n *\n * This helper transforms a recursive async function that returns a Trampoline<Result>\n * (or Promise<Trampoline<Result>>) into a *stack-safe* async function that executes\n * iteratively via the `asyncTrampoline` runner.\n *\n * @template Args - The tuple type representing the argument list of the original function.\n * @template Result - The final return type after all async trampoline steps are resolved.\n *\n * @param fn - An async or sync function that performs a single step of computation\n * and returns a Trampoline (either a final value or a deferred thunk).\n *\n * @returns An async function with the same arguments, but which automatically\n * runs the trampoline process and resolves to the *final result*.\n *\n * @example\n * // Example: Async factorial using trampoline\n * const asyncFactorial = makeAsyncTrampoline(async function fact(\n * n: number,\n * acc: number = 1\n * ): Promise<Trampoline<number>> {\n * return n === 0\n * ? acc\n * : makeTrampolineThunk(() => fact(n - 1, acc * n));\n * });\n *\n * asyncFactorial(100000).then(console.log); // Works without stack overflow\n */\nexport function makeAsyncTrampoline<Args extends any[], Result>(\n fn: (...args: Args) => Trampoline<Result> | Promise<Trampoline<Result>>\n): (...args: Args) => Promise<Result> {\n // Return a wrapped async function that runs through the async trampoline loop\n return async (...args: Args): Promise<Result> => {\n return asyncTrampoline(fn(...args));\n };\n}\n","import type { ElementCallback, IterableElementBaseOptions, ReduceElementCallback } from '../../types';\n\n/**\n * Base class that makes a data structure iterable and provides common\n * element-wise utilities (e.g., map/filter/reduce/find).\n *\n * @template E The public element type yielded by the structure.\n * @template R The underlying \"raw\" element type used internally or by converters.\n *\n * @remarks\n * This class implements the JavaScript iteration protocol (via `Symbol.iterator`)\n * and offers array-like helpers with predictable time/space complexity.\n */\nexport abstract class IterableElementBase<E, R> implements Iterable<E> {\n /**\n * Create a new iterable base.\n *\n * @param options Optional behavior overrides. When provided, a `toElementFn`\n * is used to convert a raw element (`R`) into a public element (`E`).\n *\n * @remarks\n * Time O(1), Space O(1).\n */\n protected constructor(options?: IterableElementBaseOptions<E, R>) {\n if (options) {\n const { toElementFn } = options;\n if (typeof toElementFn === 'function') this._toElementFn = toElementFn;\n else if (toElementFn) throw new TypeError('toElementFn must be a function type');\n }\n }\n\n /**\n * The converter used to transform a raw element (`R`) into a public element (`E`).\n *\n * @remarks\n * Time O(1), Space O(1).\n */\n protected _toElementFn?: (rawElement: R) => E;\n\n /**\n * Exposes the current `toElementFn`, if configured.\n *\n * @returns The converter function or `undefined` when not set.\n * @remarks\n * Time O(1), Space O(1).\n */\n get toElementFn(): ((rawElement: R) => E) | undefined {\n return this._toElementFn;\n }\n\n /**\n * Returns an iterator over the structure's elements.\n *\n * @param args Optional iterator arguments forwarded to the internal iterator.\n * @returns An `IterableIterator<E>` that yields the elements in traversal order.\n *\n * @remarks\n * Producing the iterator is O(1); consuming the entire iterator is Time O(n) with O(1) extra space.\n */\n *[Symbol.iterator](...args: unknown[]): IterableIterator<E> {\n yield* this._getIterator(...args);\n }\n\n /**\n * Returns an iterator over the values (alias of the default iterator).\n *\n * @returns An `IterableIterator<E>` over all elements.\n * @remarks\n * Creating the iterator is O(1); full iteration is Time O(n), Space O(1).\n */\n *values(): IterableIterator<E> {\n for (const item of this) yield item;\n }\n\n /**\n * Tests whether all elements satisfy the predicate.\n *\n * @template TReturn\n * @param predicate Function invoked for each element with signature `(value, index, self)`.\n * @param thisArg Optional `this` binding for the predicate.\n * @returns `true` if every element passes; otherwise `false`.\n *\n * @remarks\n * Time O(n) in the worst case; may exit early when the first failure is found. Space O(1).\n */\n every(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): boolean {\n let index = 0;\n for (const item of this) {\n if (thisArg === undefined) {\n if (!predicate(item, index++, this)) return false;\n } else {\n const fn = predicate as (this: unknown, v: E, i: number, self: this) => boolean;\n if (!fn.call(thisArg, item, index++, this)) return false;\n }\n }\n return true;\n }\n\n /**\n * Tests whether at least one element satisfies the predicate.\n *\n * @param predicate Function invoked for each element with signature `(value, index, self)`.\n * @param thisArg Optional `this` binding for the predicate.\n * @returns `true` if any element passes; otherwise `false`.\n *\n * @remarks\n * Time O(n) in the worst case; may exit early on first success. Space O(1).\n */\n some(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): boolean {\n let index = 0;\n for (const item of this) {\n if (thisArg === undefined) {\n if (predicate(item, index++, this)) return true;\n } else {\n const fn = predicate as (this: unknown, v: E, i: number, self: this) => boolean;\n if (fn.call(thisArg, item, index++, this)) return true;\n }\n }\n return false;\n }\n\n /**\n * Invokes a callback for each element in iteration order.\n *\n * @param callbackfn Function invoked per element with signature `(value, index, self)`.\n * @param thisArg Optional `this` binding for the callback.\n * @returns `void`.\n *\n * @remarks\n * Time O(n), Space O(1).\n */\n forEach(callbackfn: ElementCallback<E, R, void>, thisArg?: unknown): void {\n let index = 0;\n for (const item of this) {\n if (thisArg === undefined) {\n callbackfn(item, index++, this);\n } else {\n const fn = callbackfn as (this: unknown, v: E, i: number, self: this) => void;\n fn.call(thisArg, item, index++, this);\n }\n }\n }\n\n /**\n * Finds the first element that satisfies the predicate and returns it.\n *\n * @overload\n * Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.\n * @template S\n * @param predicate Type-guard predicate: `(value, index, self) => value is S`.\n * @param thisArg Optional `this` binding for the predicate.\n * @returns The matched element typed as `S`, or `undefined` if not found.\n *\n * @overload\n * @param predicate Boolean predicate: `(value, index, self) => boolean`.\n * @param thisArg Optional `this` binding for the predicate.\n * @returns The first matching element as `E`, or `undefined` if not found.\n *\n * @remarks\n * Time O(n) in the worst case; may exit early on the first match. Space O(1).\n */\n find<S extends E>(predicate: ElementCallback<E, R, S>, thisArg?: unknown): S | undefined;\n find(predicate: ElementCallback<E, R, unknown>, thisArg?: unknown): E | undefined;\n\n // Implementation signature\n find(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): E | undefined {\n let index = 0;\n for (const item of this) {\n if (thisArg === undefined) {\n if (predicate(item, index++, this)) return item;\n } else {\n const fn = predicate as (this: unknown, v: E, i: number, self: this) => boolean;\n if (fn.call(thisArg, item, index++, this)) return item;\n }\n }\n return;\n }\n\n /**\n * Checks whether a strictly-equal element exists in the structure.\n *\n * @param element The element to test with `===` equality.\n * @returns `true` if an equal element is found; otherwise `false`.\n *\n * @remarks\n * Time O(n) in the worst case. Space O(1).\n */\n has(element: E): boolean {\n for (const ele of this) if (ele === element) return true;\n return false;\n }\n\n reduce(callbackfn: ReduceElementCallback<E, R>): E;\n reduce(callbackfn: ReduceElementCallback<E, R>, initialValue: E): E;\n reduce<U>(callbackfn: ReduceElementCallback<E, R, U>, initialValue: U): U;\n\n /**\n * Reduces all elements to a single accumulated value.\n *\n * @overload\n * @param callbackfn Reducer of signature `(acc, value, index, self) => nextAcc`. The first element is used as the initial accumulator.\n * @returns The final accumulated value typed as `E`.\n *\n * @overload\n * @param callbackfn Reducer of signature `(acc, value, index, self) => nextAcc`.\n * @param initialValue The initial accumulator value of type `E`.\n * @returns The final accumulated value typed as `E`.\n *\n * @overload\n * @template U The accumulator type when it differs from `E`.\n * @param callbackfn Reducer of signature `(acc: U, value, index, self) => U`.\n * @param initialValue The initial accumulator value of type `U`.\n * @returns The final accumulated value typed as `U`.\n *\n * @remarks\n * Time O(n), Space O(1). Throws if called on an empty structure without `initialValue`.\n */\n reduce<U>(callbackfn: ReduceElementCallback<E, R, U>, initialValue?: U): U {\n let index = 0;\n const iter = this[Symbol.iterator]();\n let acc: U;\n\n if (arguments.length >= 2) {\n acc = initialValue as U;\n } else {\n const first = iter.next();\n if (first.done) throw new TypeError('Reduce of empty structure with no initial value');\n acc = first.value as unknown as U;\n index = 1;\n }\n\n for (const value of iter as unknown as Iterable<E>) {\n acc = callbackfn(acc, value, index++, this);\n }\n return acc;\n }\n\n /**\n * Materializes the elements into a new array.\n *\n * @returns A shallow array copy of the iteration order.\n * @remarks\n * Time O(n), Space O(n).\n */\n toArray(): E[] {\n return [...this];\n }\n\n /**\n * Returns a representation of the structure suitable for quick visualization.\n * Defaults to an array of elements; subclasses may override to provide richer visuals.\n *\n * @returns A visual representation (array by default).\n * @remarks\n * Time O(n), Space O(n).\n */\n toVisual(): E[] {\n return [...this];\n }\n\n /**\n * Prints `toVisual()` to the console. Intended for quick debugging.\n *\n * @returns `void`.\n * @remarks\n * Time O(n) due to materialization, Space O(n) for the intermediate representation.\n */\n print(): void {\n console.log(this.toVisual());\n }\n\n /**\n * Indicates whether the structure currently contains no elements.\n *\n * @returns `true` if empty; otherwise `false`.\n * @remarks\n * Expected Time O(1), Space O(1) for most implementations.\n */\n abstract isEmpty(): boolean;\n\n /**\n * Removes all elements from the structure.\n *\n * @returns `void`.\n * @remarks\n * Expected Time O(1) or O(n) depending on the implementation; Space O(1).\n */\n abstract clear(): void;\n\n /**\n * Creates a structural copy with the same element values and configuration.\n *\n * @returns A clone of the current instance (same concrete type).\n * @remarks\n * Expected Time O(n) to copy elements; Space O(n).\n */\n abstract clone(): this;\n\n /**\n * Maps each element to a new element and returns a new iterable structure.\n *\n * @template EM The mapped element type.\n * @template RM The mapped raw element type used internally by the target structure.\n * @param callback Function with signature `(value, index, self) => mapped`.\n * @param options Optional options for the returned structure, including its `toElementFn`.\n * @param thisArg Optional `this` binding for the callback.\n * @returns A new `IterableElementBase<EM, RM>` containing mapped elements.\n *\n * @remarks\n * Time O(n), Space O(n).\n */\n abstract map<EM, RM>(\n callback: ElementCallback<E, R, EM>,\n options?: IterableElementBaseOptions<EM, RM>,\n thisArg?: unknown\n ): IterableElementBase<EM, RM>;\n\n /**\n * Maps each element to the same element type and returns the same concrete structure type.\n *\n * @param callback Function with signature `(value, index, self) => mappedValue`.\n * @param thisArg Optional `this` binding for the callback.\n * @returns A new instance of the same concrete type with mapped elements.\n *\n * @remarks\n * Time O(n), Space O(n).\n */\n abstract mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this;\n\n /**\n * Filters elements using the provided predicate and returns the same concrete structure type.\n *\n * @param predicate Function with signature `(value, index, self) => boolean`.\n * @param thisArg Optional `this` binding for the predicate.\n * @returns A new instance of the same concrete type containing only elements that pass the predicate.\n *\n * @remarks\n * Time O(n), Space O(k) where `k` is the number of kept elements.\n */\n abstract filter(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): this;\n\n /**\n * Internal iterator factory used by the default iterator.\n *\n * @param args Optional iterator arguments.\n * @returns An iterator over elements.\n *\n * @remarks\n * Implementations should yield in O(1) per element with O(1) extra space when possible.\n */\n protected abstract _getIterator(...args: unknown[]): IterableIterator<E>;\n}\n","import type { ElementCallback, LinearBaseOptions, ReduceLinearCallback } from '../../types';\nimport { IterableElementBase } from './iterable-element-base';\n\n/**\n * Singly-linked list node.\n * @template E - Element type.\n * @remarks Time O(1), Space O(1)\n */\nexport class LinkedListNode<E = any> {\n /**\n * Initialize a node.\n * @param value - Element value.\n * @remarks Time O(1), Space O(1)\n */\n constructor(value: E) {\n this._value = value;\n this._next = undefined;\n }\n\n protected _value: E;\n\n /**\n * Element payload getter.\n * @returns Element value.\n * @remarks Time O(1), Space O(1)\n */\n get value(): E {\n return this._value;\n }\n\n /**\n * Element payload setter.\n * @param value - New value.\n * @remarks Time O(1), Space O(1)\n */\n set value(value: E) {\n this._value = value;\n }\n\n protected _next: LinkedListNode<E> | undefined;\n\n /**\n * Next node getter.\n * @returns Next node or `undefined`.\n * @remarks Time O(1), Space O(1)\n */\n get next(): LinkedListNode<E> | undefined {\n return this._next;\n }\n\n /**\n * Next node setter.\n * @param value - Next node or `undefined`.\n * @remarks Time O(1), Space O(1)\n */\n set next(value: LinkedListNode<E> | undefined) {\n this._next = value;\n }\n}\n\n/**\n * Abstract linear container with array-like utilities.\n * @template E - Element type.\n * @template R - Return type for mapped/derived views.\n * @template NODE - Linked node type used by some implementations.\n * @remarks Time O(1), Space O(1)\n */\nexport abstract class LinearBase<\n E,\n R = any,\n NODE extends LinkedListNode<E> = LinkedListNode<E>\n> extends IterableElementBase<E, R> {\n /**\n * Construct a linear container with runtime options.\n * @param options - `{ maxLen?, ... }` bounds/behavior options.\n * @remarks Time O(1), Space O(1)\n */\n protected constructor(options?: LinearBaseOptions<E, R>) {\n super(options);\n if (options) {\n const { maxLen } = options;\n if (typeof maxLen === 'number' && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;\n }\n }\n\n /**\n * Element count.\n * @returns Number of elements.\n * @remarks Time O(1), Space O(1)\n */\n abstract get length(): number;\n\n protected _maxLen: number = -1;\n\n /**\n * Upper bound for length (if positive), or `-1` when unbounded.\n * @returns Maximum allowed length.\n * @remarks Time O(1), Space O(1)\n */\n get maxLen() {\n return this._maxLen;\n }\n\n /**\n * First index of a value from the left.\n * @param searchElement - Value to match.\n * @param fromIndex - Start position (supports negative index).\n * @returns Index or `-1` if not found.\n * @remarks Time O(n), Space O(1)\n */\n indexOf(searchElement: E, fromIndex: number = 0): number {\n if (this.length === 0) return -1;\n if (fromIndex < 0) fromIndex = this.length + fromIndex;\n if (fromIndex < 0) fromIndex = 0;\n\n for (let i = fromIndex; i < this.length; i++) {\n const element = this.at(i);\n if (element === searchElement) return i;\n }\n\n return -1;\n }\n\n /**\n * Last index of a value from the right.\n * @param searchElement - Value to match.\n * @param fromIndex - Start position (supports negative index).\n * @returns Index or `-1` if not found.\n * @remarks Time O(n), Space O(1)\n */\n lastIndexOf(searchElement: E, fromIndex: number = this.length - 1): number {\n if (this.length === 0) return -1;\n if (fromIndex >= this.length) fromIndex = this.length - 1;\n if (fromIndex < 0) fromIndex = this.length + fromIndex;\n\n for (let i = fromIndex; i >= 0; i--) {\n const element = this.at(i);\n if (element === searchElement) return i;\n }\n\n return -1;\n }\n\n /**\n * Find the first index matching a predicate.\n * @param predicate - `(element, index, self) => boolean`.\n * @param thisArg - Optional `this` for callback.\n * @returns Index or `-1`.\n * @remarks Time O(n), Space O(1)\n */\n findIndex(predicate: ElementCallback<E, R, boolean>, thisArg?: any): number {\n for (let i = 0; i < this.length; i++) {\n const item = this.at(i);\n if (item !== undefined && predicate.call(thisArg, item, i, this)) return i;\n }\n return -1;\n }\n\n /**\n * Concatenate multiple containers of the same species.\n * @param items - Other lists to append.\n * @returns New container with combined elements (`this` type).\n * @remarks Time O(sum(length)), Space O(sum(length))\n */\n concat(...items: this[]): this;\n\n /**\n * Concatenate elements and/or containers.\n * @param items - Elements or other containers.\n * @returns New container with combined elements (`this` type).\n * @remarks Time O(sum(length)), Space O(sum(length))\n */\n concat(...items: (E | this)[]): this {\n const newList = this.clone();\n\n for (const item of items) {\n if (item instanceof LinearBase) {\n newList.pushMany(item);\n } else {\n newList.push(item);\n }\n }\n\n return newList;\n }\n\n /**\n * In-place stable order via array sort semantics.\n * @param compareFn - Comparator `(a, b) => number`.\n * @returns This container.\n * @remarks Time O(n log n), Space O(n) (materializes to array temporarily)\n */\n sort(compareFn?: (a: E, b: E) => number): this {\n const arr = this.toArray();\n arr.sort(compareFn);\n this.clear();\n for (const item of arr) this.push(item);\n return this;\n }\n\n /**\n * Remove and/or insert elements at a position (array-compatible).\n * @param start - Start index (supports negative index).\n * @param deleteCount - How many to remove.\n * @param items - Elements to insert.\n * @returns Removed elements as a new list (`this` type).\n * @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`\n */\n splice(start: number, deleteCount: number = 0, ...items: E[]): this {\n const removedList = this._createInstance();\n\n start = start < 0 ? this.length + start : start;\n start = Math.max(0, Math.min(start, this.length));\n deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));\n\n for (let i = 0; i < deleteCount; i++) {\n const removed = this.deleteAt(start);\n if (removed !== undefined) {\n removedList.push(removed);\n }\n }\n\n for (let i = 0; i < items.length; i++) {\n this.addAt(start + i, items[i]);\n }\n\n return removedList;\n }\n\n /**\n * Join all elements into a string.\n * @param separator - Separator string.\n * @returns Concatenated string.\n * @remarks Time O(n), Space O(n)\n */\n join(separator: string = ','): string {\n return this.toArray().join(separator);\n }\n\n /**\n * Snapshot elements into a reversed array.\n * @returns New reversed array.\n * @remarks Time O(n), Space O(n)\n */\n toReversedArray(): E[] {\n const array: E[] = [];\n for (let i = this.length - 1; i >= 0; i--) {\n array.push(this.at(i)!);\n }\n return array;\n }\n\n reduceRight(callbackfn: ReduceLinearCallback<E>): E;\n\n reduceRight(callbackfn: ReduceLinearCallback<E>, initialValue: E): E;\n\n /**\n * Right-to-left reduction over elements.\n * @param callbackfn - `(acc, element, index, self) => acc`.\n * @param initialValue - Initial accumulator (optional generic overloads supported).\n * @returns Final accumulator.\n * @remarks Time O(n), Space O(1)\n */\n reduceRight<U>(callbackfn: ReduceLinearCallback<E, U>, initialValue: U): U;\n\n reduceRight<U>(callbackfn: ReduceLinearCallback<E, U>, initialValue?: U): U {\n let accumulator = initialValue ?? (0 as U);\n for (let i = this.length - 1; i >= 0; i--) {\n accumulator = callbackfn(accumulator, this.at(i)!, i, this);\n }\n return accumulator;\n }\n\n /**\n * Create a shallow copy of a subrange.\n * @param start - Inclusive start (supports negative index).\n * @param end - Exclusive end (supports negative index).\n * @returns New list with the range (`this` type).\n * @remarks Time O(n), Space O(n)\n */\n slice(start: number = 0, end: number = this.length): this {\n start = start < 0 ? this.length + start : start;\n end = end < 0 ? this.length + end : end;\n\n const newList = this._createInstance();\n for (let i = start; i < end; i++) {\n newList.push(this.at(i)!);\n }\n return newList;\n }\n\n /**\n * Fill a range with a value.\n * @param value - Value to set.\n * @param start - Inclusive start.\n * @param end - Exclusive end.\n * @returns This list.\n * @remarks Time O(n), Space O(1)\n */\n fill(value: E, start = 0, end = this.length): this {\n start = start < 0 ? this.length + start : start;\n end = end < 0 ? this.length + end : end;\n\n if (start < 0) start = 0;\n if (end > this.length) end = this.length;\n if (start >= end) return this;\n\n for (let i = start; i < end; i++) {\n this.setAt(i, value);\n }\n\n return this;\n }\n\n /**\n * Set the value at an index.\n * @param index - Position (0-based).\n * @param value - New value.\n * @returns `true` if updated.\n * @remarks Time O(1) typical, Space O(1)\n */\n abstract setAt(index: number, value: E): boolean;\n\n /**\n * Deep clone while preserving concrete subtype.\n * @returns New list of the same species (`this` type).\n * @remarks Time O(n), Space O(n)\n */\n abstract override clone(): this;\n\n /**\n * Reverse the order of elements in-place (or equivalent).\n * @returns This list.\n * @remarks Time O(n), Space O(1)\n */\n abstract reverse(): this;\n\n /**\n * Append one element or node to the tail.\n * @param elementOrNode - Element or node.\n * @returns `true` if appended.\n * @remarks Time O(1) amortized typical, Space O(1)\n */\n abstract push(elementOrNode: E | NODE): boolean;\n\n /**\n * Append many elements/nodes at once.\n * @param elements - Iterable of elements or nodes.\n * @returns Array of booleans indicating append success.\n * @remarks Time O(n), Space O(1)\n */\n abstract pushMany(elements: Iterable<E> | Iterable<R> | Iterable<NODE>): boolean[];\n\n /**\n * Remove one element or node if present.\n * @param elementOrNode - Element or node to delete.\n * @returns `true` if removed.\n * @remarks Time O(1)~O(n) depending on implementation, Space O(1)\n */\n abstract delete(elementOrNode: E | NODE | undefined): boolean;\n\n /**\n * Get element at an index.\n * @param index - Position (0-based).\n * @returns Element or `undefined`.\n * @remarks Time O(1)~O(n) depending on implementation, Space O(1)\n */\n abstract at(index: number): E | undefined;\n\n /**\n * Remove element at a position.\n * @param pos - Position (0-based).\n * @returns Removed element or `undefined`.\n * @remarks Time O(1)~O(n) depending on implementation, Space O(1)\n */\n abstract deleteAt(pos: number): E | undefined;\n\n /**\n * Insert an element/node at a position.\n * @param index - Position (0-based).\n * @param newElementOrNode - Element or node to insert.\n * @returns `true` if inserted.\n * @remarks Time O(1)~O(n) depending on implementation, Space O(1)\n */\n abstract addAt(index: number, newElementOrNode: E | NODE): boolean;\n\n /**\n * Create an empty list of the same species.\n * @param options - Runtime options to carry.\n * @returns Empty list (`this` type).\n * @remarks Time O(1), Space O(1)\n */\n protected abstract _createInstance(options?: LinearBaseOptions<E, R>): this;\n\n /**\n * Reverse-direction iterator over elements.\n * @returns Iterator of elements from tail to head.\n * @remarks Time O(n), Space O(1)\n */\n protected abstract _getReverseIterator(...args: any[]): IterableIterator<E>;\n}\n\n/**\n * Linked-list specialized linear container.\n * @template E - Element type.\n * @template R - Return type for mapped/derived views.\n * @template NODE - Linked node type.\n * @remarks Time O(1), Space O(1)\n */\nexport abstract class LinearLinkedBase<\n E,\n R = any,\n NODE extends LinkedListNode<E> = LinkedListNode<E>\n> extends LinearBase<E, R, NODE> {\n protected constructor(options?: LinearBaseOptions<E, R>) {\n super(options);\n if (options) {\n const { maxLen } = options;\n if (typeof maxLen === 'number' && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;\n }\n }\n\n /**\n * Linked-list optimized `indexOf` (forwards scan).\n * @param searchElement - Value to match.\n * @param fromIndex - Start position.\n * @returns Index or `-1`.\n * @remarks Time O(n), Space O(1)\n */\n override indexOf(searchElement: E, fromIndex: number = 0): number {\n const iterator = this._getIterator();\n let current = iterator.next();\n\n let index = 0;\n while (index < fromIndex) {\n current = iterator.next();\n index++;\n }\n\n while (!current.done) {\n if (current.value === searchElement) return index;\n current = iterator.next();\n index++;\n }\n\n return -1;\n }\n\n /**\n * Linked-list optimized `lastIndexOf` (reverse scan).\n * @param searchElement - Value to match.\n * @param fromIndex - Start position.\n * @returns Index or `-1`.\n * @remarks Time O(n), Space O(1)\n */\n override lastIndexOf(searchElement: E, fromIndex: number = this.length - 1): number {\n const iterator = this._getReverseIterator();\n let current = iterator.next();\n\n let index = this.length - 1;\n while (index > fromIndex) {\n current = iterator.next();\n index--;\n }\n\n while (!current.done) {\n if (current.value === searchElement) return index;\n current = iterator.next();\n index--;\n }\n\n return -1;\n }\n\n /**\n * Concatenate lists/elements preserving order.\n * @param items - Elements or `LinearBase` instances.\n * @returns New list with combined elements (`this` type).\n * @remarks Time O(sum(length)), Space O(sum(length))\n */\n override concat(...items: LinearBase<E, R>[]): this;\n\n override concat(...items: (E | LinearBase<E, R>)[]): this {\n const newList = this.clone();\n\n for (const item of items) {\n if (item instanceof LinearBase) {\n newList.pushMany(item);\n } else {\n newList.push(item);\n }\n }\n\n return newList;\n }\n\n /**\n * Slice via forward iteration (no random access required).\n * @param start - Inclusive start (supports negative index).\n * @param end - Exclusive end (supports negative index).\n * @returns New list (`this` type).\n * @remarks Time O(n), Space O(n)\n */\n override slice(start: number = 0, end: number = this.length): this {\n start = start < 0 ? this.length + start : start;\n end = end < 0 ? this.length + end : end;\n\n const newList = this._createInstance();\n const iterator = this._getIterator();\n let current = iterator.next();\n let c = 0;\n while (c < start) {\n current = iterator.next();\n c++;\n }\n for (let i = start; i < end; i++) {\n newList.push(current.value);\n current = iterator.next();\n }\n\n return newList;\n }\n\n /**\n * Splice by walking node iterators from the start index.\n * @param start - Start index.\n * @param deleteCount - How many elements to remove.\n * @param items - Elements to insert after the splice point.\n * @returns Removed elements as a new list (`this` type).\n * @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`\n */\n override splice(start: number, deleteCount: number = 0, ...items: E[]): this {\n const removedList = this._createInstance();\n\n start = start < 0 ? this.length + start : start;\n start = Math.max(0, Math.min(start, this.length));\n deleteCount = Math.max(0, deleteCount);\n\n let currentIndex = 0;\n let currentNode: NODE | undefined = undefined;\n let previousNode: NODE | undefined = undefined;\n\n const iterator = this._getNodeIterator();\n for (const node of iterator) {\n if (currentIndex === start) {\n currentNode = node;\n break;\n }\n previousNode = node;\n currentIndex++;\n }\n\n for (let i = 0; i < deleteCount && currentNode; i++) {\n removedList.push(currentNode.value);\n const nextNode = currentNode.next;\n this.delete(currentNode);\n currentNode = nextNode as NODE;\n }\n\n for (let i = 0; i < items.length; i++) {\n if (previousNode) {\n this.addAfter(previousNode, items[i]);\n previousNode = previousNode.next as NODE;\n } else {\n this.addAt(0, items[i]);\n previousNode = this._getNodeIterator().next().value;\n }\n }\n\n return removedList;\n }\n\n override reduceRight(callbackfn: ReduceLinearCallback<E>): E;\n\n override reduceRight(callbackfn: ReduceLinearCallback<E>, initialValue: E): E;\n\n /**\n * Right-to-left reduction using reverse iterator.\n * @param callbackfn - `(acc, element, index, self) => acc`.\n * @param initialValue - Initial accumulator.\n * @returns Final accumulator.\n * @remarks Time O(n), Space O(1)\n */\n override reduceRight<U>(callbackfn: ReduceLinearCallback<E, U>, initialValue: U): U;\n\n override reduceRight<U>(callbackfn: ReduceLinearCallback<E, U>, initialValue?: U): U {\n let accumulator = initialValue ?? (0 as U);\n let index = this.length - 1;\n for (const item of this._getReverseIterator()) {\n accumulator = callbackfn(accumulator, item, index--, this);\n }\n return accumulator;\n }\n\n /**\n * Delete by element or node in a linked list.\n * @param elementOrNode - Element or node.\n * @returns `true` if removed.\n * @remarks Time O(1)~O(n) depending on availability of links, Space O(1)\n */\n abstract override delete(elementOrNode: E | NODE | undefined): boolean;\n\n /**\n * Insert new element/node before an existing node.\n * @param existingElementOrNode - Reference element/node.\n * @param newElementOrNode - Element/node to insert.\n * @returns `true` if inserted.\n * @remarks Time O(1)~O(n) depending on reference access, Space O(1)\n */\n abstract addBefore(existingElementOrNode: E | NODE, newElementOrNode: E | NODE): boolean;\n\n /**\n * Insert new element/node after an existing node.\n * @param existingElementOrNode - Reference element/node.\n * @param newElementOrNode - Element/node to insert.\n * @returns `true` if inserted.\n * @remarks Time O(1)~O(n) depending on reference access, Space O(1)\n */\n abstract addAfter(existingElementOrNode: E | NODE, newElementOrNode: E | NODE): boolean;\n\n /**\n * Node at index (for random-access emulation).\n * @param index - Position (0-based).\n * @returns Node or `undefined`.\n * @remarks Time O(n), Space O(1)\n */\n abstract getNodeAt(index: number): NODE | undefined;\n\n /**\n * Iterate linked nodes from head to tail.\n * @returns Iterator over nodes.\n * @remarks Time O(n), Space O(1)\n */\n protected abstract _getNodeIterator(...args: any[]): IterableIterator<NODE>;\n\n /**\n * Get previous node of a given node.\n * @param node - Current node.\n * @returns Previous node or `undefined`.\n * @remarks Time O(1)~O(n) depending on list variant (singly vs doubly), Space O(1)\n */\n protected abstract _getPrevNode(node: NODE): NODE | undefined;\n}\n","/**\n * data-structure-typed\n *\n * @author Pablo Zeng\n * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>\n * @license MIT License\n */\n\nimport type {\n DequeOptions,\n ElementCallback,\n IterableElementBaseOptions,\n IterableWithSizeOrLength,\n LinearBaseOptions\n} from '../../types';\nimport { calcMinUnitsRequired, rangeCheck } from '../../utils';\nimport { LinearBase } from '../base/linear-base';\n\n/**\n * Deque implemented with circular buckets allowing O(1) amortized push/pop at both ends.\n * @remarks Time O(1), Space O(1)\n * @template E\n * @template R\n * 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).\n * 2. Efficient Random Access: Being based on an array, it offers fast random access capability, allowing constant time access to any element.\n * 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.\n * 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).\n * 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not\n * @example\n * // prize roulette\n * class PrizeRoulette {\n * private deque: Deque<string>;\n *\n * constructor(prizes: string[]) {\n * // Initialize the deque with prizes\n * this.deque = new Deque<string>(prizes);\n * }\n *\n * // Rotate clockwise to the right (forward)\n * rotateClockwise(steps: number): void {\n * const n = this.deque.length;\n * if (n === 0) return;\n *\n * for (let i = 0; i < steps; i++) {\n * const last = this.deque.pop(); // Remove the last element\n * this.deque.unshift(last!); // Add it to the front\n * }\n * }\n *\n * // Rotate counterclockwise to the left (backward)\n * rotateCounterClockwise(steps: number): void {\n * const n = this.deque.length;\n * if (n === 0) return;\n *\n * for (let i = 0; i < steps; i++) {\n * const first = this.deque.shift(); // Remove the first element\n * this.deque.push(first!); // Add it to the back\n * }\n * }\n *\n * // Display the current prize at the head\n * display() {\n * return this.deque.first;\n * }\n * }\n *\n * // Example usage\n * const prizes = ['Car', 'Bike', 'Laptop', 'Phone', 'Watch', 'Headphones']; // Initialize the prize list\n * const roulette = new PrizeRoulette(prizes);\n *\n * // Display the initial state\n * console.log(roulette.display()); // 'Car' // Car\n *\n * // Rotate clockwise by 3 steps\n * roulette.rotateClockwise(3);\n * console.log(roulette.display()); // 'Phone' // Phone\n *\n * // Rotate counterclockwise by 2 steps\n * roulette.rotateCounterClockwise(2);\n * console.log(roulette.display()); // 'Headphones'\n * @example\n * // sliding window\n * // Maximum function of sliding window\n * function maxSlidingWindow(nums: number[], k: number): number[] {\n * const n = nums.length;\n * if (n * k === 0) return [];\n *\n * const deq = new Deque<number>();\n * const result: number[] = [];\n *\n * for (let i = 0; i < n; i++) {\n * // Delete indexes in the queue that are not within the window range\n * if (deq.length > 0 && deq.first! === i - k) {\n * deq.shift();\n * }\n *\n * // Remove all indices less than the current value from the tail of the queue\n * while (deq.length > 0 && nums[deq.last!] < nums[i]) {\n * deq.pop();\n * }\n *\n * // Add the current index to the end of the queue\n * deq.push(i);\n *\n * // Add the maximum value of the window to the results\n * if (i >= k - 1) {\n * result.push(nums[deq.first!]);\n * }\n * }\n *\n * return result;\n * }\n *\n * const nums = [1, 3, -1, -3, 5, 3, 6, 7];\n * const k = 3;\n * console.log(maxSlidingWindow(nums, k)); // [3, 3, 5, 5, 6, 7]\n */\nexport class Deque<E = any, R = any> extends LinearBase<E, R> {\n protected _equals: (a: E, b: E) => boolean = Object.is as unknown as (a: E, b: E) => boolean;\n\n /**\n * Create a Deque and optionally bulk-insert elements.\n * @remarks Time O(N), Space O(N)\n * @param [elements] - Iterable (or iterable-like) of elements/records to insert.\n * @param [options] - Options such as bucketSize, toElementFn, and maxLen.\n * @returns New Deque instance.\n */\n\n constructor(elements: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R> = [], options?: DequeOptions<E, R>) {\n super(options);\n\n if (options) {\n const { bucketSize } = options;\n if (typeof bucketSize === 'number') this._bucketSize = bucketSize;\n }\n\n let _size: number;\n if ('length' in elements) {\n _size = typeof elements.length === 'function' ? elements.length() : elements.length;\n } else {\n _size = typeof elements.size === 'function' ? elements.size() : elements.size;\n }\n\n this._bucketCount = calcMinUnitsRequired(_size, this._bucketSize) || 1;\n for (let i = 0; i < this._bucketCount; ++i) {\n this._buckets.push(new Array(this._bucketSize));\n }\n const needBucketNum = calcMinUnitsRequired(_size, this._bucketSize);\n this._bucketFirst = this._bucketLast = (this._bucketCount >> 1) - (needBucketNum >> 1);\n this._firstInBucket = this._lastInBucket = (this._bucketSize - (_size % this._bucketSize)) >> 1;\n this.pushMany(elements);\n }\n\n protected _bucketSize: number = 1 << 12;\n\n /**\n * Get the current bucket size.\n * @remarks Time O(1), Space O(1)\n * @returns Bucket capacity per bucket.\n */\n\n get bucketSize() {\n return this._bucketSize;\n }\n\n protected _bucketFirst = 0;\n\n /**\n * Get the index of the first bucket in use.\n * @remarks Time O(1), Space O(1)\n * @returns Zero-based bucket index.\n */\n\n get bucketFirst(): number {\n return this._bucketFirst;\n }\n\n protected _firstInBucket = 0;\n\n /**\n * Get the index inside the first bucket.\n * @remarks Time O(1), Space O(1)\n * @returns Zero-based index within the first bucket.\n */\n\n get firstInBucket(): number {\n return this._firstInBucket;\n }\n\n protected _bucketLast = 0;\n\n /**\n * Get the index of the last bucket in use.\n * @remarks Time O(1), Space O(1)\n * @returns Zero-based bucket index.\n */\n\n get bucketLast(): number {\n return this._bucketLast;\n }\n\n protected _lastInBucket = 0;\n\n /**\n * Get the index inside the last bucket.\n * @remarks Time O(1), Space O(1)\n * @returns Zero-based index within the last bucket.\n */\n\n get lastInBucket(): number {\n return this._lastInBucket;\n }\n\n protected _bucketCount = 0;\n\n /**\n * Get the number of buckets allocated.\n * @remarks Time O(1), Space O(1)\n * @returns Bucket count.\n */\n\n get bucketCount(): number {\n return this._bucketCount;\n }\n\n protected _buckets: E[][] = [];\n\n /**\n * Get the internal buckets array.\n * @remarks Time O(1), Space O(1)\n * @returns Array of buckets storing values.\n */\n\n get buckets() {\n return this._buckets;\n }\n\n protected _length = 0;\n\n /**\n * Get the number of elements in the deque.\n * @remarks Time O(1), Space O(1)\n * @returns Current length.\n */\n\n get length() {\n return this._length;\n }\n\n /**\n * Get the first element without removing it.\n * @remarks Time O(1), Space O(1)\n * @returns First element or undefined.\n */\n\n get first(): E | undefined {\n if (this._length === 0) return;\n return this._buckets[this._bucketFirst][this._firstInBucket];\n }\n\n /**\n * Get the last element without removing it.\n * @remarks Time O(1), Space O(1)\n * @returns Last element or undefined.\n */\n\n get last(): E | undefined {\n if (this._length === 0) return;\n return this._buckets[this._bucketLast][this._lastInBucket];\n }\n\n /**\n * Create a Deque from an array of elements.\n * @remarks Time O(N), Space O(N)\n * @template E\n * @template R\n * @param this - Constructor (subclass) to instantiate.\n * @param data - Array of elements to insert in order.\n * @param [options] - Options forwarded to the constructor.\n * @returns A new Deque populated from the array.\n */\n\n static fromArray<E, R = any>(\n this: new (\n elements?: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R>,\n options?: DequeOptions<E, R>\n ) => any,\n data: E[],\n options?: DequeOptions<E, R>\n ) {\n return new this(data, options);\n }\n\n /**\n * Append one element at the back.\n * @remarks Time O(1) amortized, Space O(1)\n * @param element - Element to append.\n * @returns True when appended.\n */\n\n push(element: E): boolean {\n if (this._length) {\n if (this._lastInBucket < this._bucketSize - 1) {\n this._lastInBucket += 1;\n } else if (this._bucketLast < this._bucketCount - 1) {\n this._bucketLast += 1;\n this._lastInBucket = 0;\n } else {\n this._bucketLast = 0;\n this._lastInBucket = 0;\n }\n if (this._bucketLast === this._bucketFirst && this._lastInBucket === this._firstInBucket) this._reallocate();\n }\n this._length += 1;\n this._buckets[this._bucketLast][this._lastInBucket] = element;\n if (this._maxLen > 0 && this._length > this._maxLen) this.shift();\n return true;\n }\n\n /**\n * Remove and return the last element.\n * @remarks Time O(1), Space O(1)\n * @returns Removed element or undefined.\n */\n\n pop(): E | undefined {\n if (this._length === 0) return;\n const element = this._buckets[this._bucketLast][this._lastInBucket];\n if (this._length !== 1) {\n if (this._lastInBucket > 0) {\n this._lastInBucket -= 1;\n } else if (this._bucketLast > 0) {\n this._bucketLast -= 1;\n this._lastInBucket = this._bucketSize - 1;\n } else {\n this._bucketLast = this._bucketCount - 1;\n this._lastInBucket = this._bucketSize - 1;\n }\n }\n this._length -= 1;\n return element;\n }\n\n /**\n * Remove and return the first element.\n * @remarks Time O(1) amortized, Space O(1)\n * @returns Removed element or undefined.\n */\n\n shift(): E | undefined {\n if (this._length === 0) return;\n const element = this._buckets[this._bucketFirst][this._firstInBucket];\n if (this._length !== 1) {\n if (this._firstInBucket < this._bucketSize - 1) {\n this._firstInBucket += 1;\n } else if (this._bucketFirst < this._bucketCount - 1) {\n this._bucketFirst += 1;\n this._firstInBucket = 0;\n } else {\n this._bucketFirst = 0;\n this._firstInBucket = 0;\n }\n }\n this._length -= 1;\n return element;\n }\n\n /**\n * Prepend one element at the front.\n * @remarks Time O(1) amortized, Space O(1)\n * @param element - Element to prepend.\n * @returns True when prepended.\n */\n\n unshift(element: E): boolean {\n if (this._length) {\n if (this._firstInBucket > 0) {\n this._firstInBucket -= 1;\n } else if (this._bucketFirst > 0) {\n this._bucketFirst -= 1;\n this._firstInBucket = this._bucketSize - 1;\n } else {\n this._bucketFirst = this._bucketCount - 1;\n this._firstInBucket = this._bucketSize - 1;\n }\n if (this._bucketFirst === this._bucketLast && this._firstInBucket === this._lastInBucket) this._reallocate();\n }\n this._length += 1;\n this._buckets[this._bucketFirst][this._firstInBucket] = element;\n if (this._maxLen > 0 && this._length > this._maxLen) this.pop();\n return true;\n }\n\n /**\n * Append a sequence of elements.\n * @remarks Time O(N), Space O(1)\n * @param elements - Iterable (or iterable-like) of elements/records.\n * @returns Array of per-element success flags.\n */\n\n pushMany(elements: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R>) {\n const ans: boolean[] = [];\n for (const el of elements) {\n if (this.toElementFn) {\n ans.push(this.push(this.toElementFn(el as R)));\n } else {\n ans.push(this.push(el as E));\n }\n }\n return ans;\n }\n\n /**\n * Prepend a sequence of elements.\n * @remarks Time O(N), Space O(1)\n * @param [elements] - Iterable (or iterable-like) of elements/records.\n * @returns Array of per-element success flags.\n */\n\n unshiftMany(elements: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R> = []) {\n const ans: boolean[] = [];\n for (const el of elements) {\n if (this.toElementFn) {\n ans.push(this.unshift(this.toElementFn(el as R)));\n } else {\n ans.push(this.unshift(el as E));\n }\n }\n return ans;\n }\n\n /**\n * Check whether the deque is empty.\n * @remarks Time O(1), Space O(1)\n * @returns True if length is 0.\n */\n\n isEmpty(): boolean {\n return this._length === 0;\n }\n\n /**\n * Remove all elements and reset structure.\n * @remarks Time O(1), Space O(1)\n * @returns void\n */\n\n clear(): void {\n this._buckets = [new Array(this._bucketSize)];\n this._bucketCount = 1;\n this._bucketFirst = this._bucketLast = this._length = 0;\n this._firstInBucket = this._lastInBucket = this._bucketSize >> 1;\n }\n\n /**\n * Get the element at a given position.\n * @remarks Time O(1), Space O(1)\n * @param pos - Zero-based position from the front.\n * @returns Element or undefined.\n */\n\n at(pos: number): E | undefined {\n if (pos < 0 || pos >= this._length) return undefined;\n const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);\n return this._buckets[bucketIndex][indexInBucket];\n }\n\n /**\n * Replace the element at a given position.\n * @remarks Time O(1), Space O(1)\n * @param pos - Zero-based position from the front.\n * @param element - New element value.\n * @returns True if updated.\n */\n\n setAt(pos: number, element: E): boolean {\n rangeCheck(pos, 0, this._length - 1);\n const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);\n this._buckets[bucketIndex][indexInBucket] = element;\n return true;\n }\n\n /**\n * Insert repeated copies of an element at a position.\n * @remarks Time O(N), Space O(1)\n * @param pos - Zero-based position from the front.\n * @param element - Element to insert.\n * @param [num] - Number of times to insert (default 1).\n * @returns True if inserted.\n */\n\n addAt(pos: number, element: E, num = 1): boolean {\n const length = this._length;\n rangeCheck(pos, 0, length);\n if (pos === 0) {\n while (num--) this.unshift(element);\n } else if (pos === this._length) {\n while (num--) this.push(element);\n } else {\n const arr: E[] = [];\n for (let i = pos; i < this._length; ++i) {\n const v = this.at(i);\n if (v !== undefined) arr.push(v);\n }\n this.cut(pos - 1, true);\n for (let i = 0; i < num; ++i) this.push(element);\n for (let i = 0; i < arr.length; ++i) this.push(arr[i]);\n }\n return true;\n }\n\n /**\n * Cut the deque to keep items up to index; optionally mutate in-place.\n * @remarks Time O(N), Space O(1)\n * @param pos - Last index to keep.\n * @param [isCutSelf] - When true, mutate this deque; otherwise return a new deque.\n * @returns This deque if in-place; otherwise a new deque of the prefix.\n */\n\n cut(pos: number, isCutSelf = false): Deque<E> {\n if (isCutSelf) {\n if (pos < 0) {\n this.clear();\n return this;\n }\n const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);\n this._bucketLast = bucketIndex;\n this._lastInBucket = indexInBucket;\n this._length = pos + 1;\n return this;\n } else {\n const newDeque = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });\n newDeque._setBucketSize(this._bucketSize);\n for (let i = 0; i <= pos; i++) {\n const v = this.at(i);\n if (v !== undefined) newDeque.push(v);\n }\n\n return newDeque;\n }\n }\n\n /**\n * Remove and/or insert elements at a position (array-like behavior).\n * @remarks Time O(N + M), Space O(M)\n * @param start - Start index (clamped to [0, length]).\n * @param [deleteCount] - Number of elements to remove (default: length - start).\n * @param [items] - Elements to insert after `start`.\n * @returns A new deque containing the removed elements (typed as `this`).\n */\n\n override splice(start: number, deleteCount: number = this._length - start, ...items: E[]): this {\n rangeCheck(start, 0, this._length);\n if (deleteCount < 0) deleteCount = 0;\n if (start + deleteCount > this._length) deleteCount = this._length - start;\n\n const removed = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });\n removed._setBucketSize(this._bucketSize);\n for (let i = 0; i < deleteCount; i++) {\n const v = this.at(start + i);\n if (v !== undefined) removed.push(v);\n }\n\n const tail: E[] = [];\n for (let i = start + deleteCount; i < this._length; i++) {\n const v = this.at(i);\n if (v !== undefined) tail.push(v);\n }\n\n this.cut(start - 1, true);\n\n for (const it of items) this.push(it);\n\n for (const v of tail) this.push(v);\n\n return removed as unknown as this;\n }\n\n /**\n * Cut the deque to keep items from index onward; optionally mutate in-place.\n * @remarks Time O(N), Space O(1)\n * @param pos - First index to keep.\n * @param [isCutSelf] - When true, mutate this deque; otherwise return a new deque.\n * @returns This deque if in-place; otherwise a new deque of the suffix.\n */\n\n cutRest(pos: number, isCutSelf = false): Deque<E> {\n if (isCutSelf) {\n if (pos < 0) {\n return this;\n }\n const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);\n this._bucketFirst = bucketIndex;\n this._firstInBucket = indexInBucket;\n this._length = this._length - pos;\n return this;\n } else {\n const newDeque = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });\n newDeque._setBucketSize(this._bucketSize);\n if (pos < 0) pos = 0;\n for (let i = pos; i < this._length; i++) {\n const v = this.at(i);\n if (v !== undefined) newDeque.push(v);\n }\n return newDeque;\n }\n }\n\n /**\n * Delete the element at a given position.\n * @remarks Time O(N), Space O(1)\n * @param pos - Zero-based position from the front.\n * @returns Removed element or undefined.\n */\n\n deleteAt(pos: number): E | undefined {\n rangeCheck(pos, 0, this._length - 1);\n\n let deleted: E | undefined;\n if (pos === 0) {\n return this.shift();\n } else if (pos === this._length - 1) {\n deleted = this.last;\n this.pop();\n return deleted;\n } else {\n const length = this._length - 1;\n const { bucketIndex: targetBucket, indexInBucket: targetPointer } = this._getBucketAndPosition(pos);\n deleted = this._buckets[targetBucket][targetPointer];\n\n for (let i = pos; i < length; i++) {\n const { bucketIndex: curBucket, indexInBucket: curPointer } = this._getBucketAndPosition(i);\n const { bucketIndex: nextBucket, indexInBucket: nextPointer } = this._getBucketAndPosition(i + 1);\n this._buckets[curBucket][curPointer] = this._buckets[nextBucket][nextPointer];\n }\n\n this.pop();\n return deleted;\n }\n }\n\n /**\n * Delete the first occurrence of a value.\n * @remarks Time O(N), Space O(1)\n * @param element - Element to remove (using the configured equality).\n * @returns True if an element was removed.\n */\n\n delete(element: E): boolean {\n const size = this._length;\n if (size === 0) return false;\n let i = 0;\n let index = 0;\n while (i < size) {\n const oldElement = this.at(i);\n if (!this._equals(oldElement as E, element)) {\n this.setAt(index, oldElement!);\n index += 1;\n }\n i += 1;\n }\n this.cut(index - 1, true);\n return true;\n }\n\n /**\n * Delete the first element matching a predicate.\n * @remarks Time O(N), Space O(1)\n * @param predicate - Function (value, index, deque) → boolean.\n * @returns True if a match was removed.\n */\n\n deleteWhere(predicate: (value: E, index: number, deque: this) => boolean): boolean {\n for (let i = 0; i < this._length; i++) {\n const v = this.at(i);\n if (predicate(v as E, i, this)) {\n this.deleteAt(i);\n return true;\n }\n }\n return false;\n }\n\n /**\n * Set the equality comparator used by delete operations.\n * @remarks Time O(1), Space O(1)\n * @param equals - Equality predicate (a, b) → boolean.\n * @returns This deque.\n */\n\n setEquality(equals: (a: E, b: E) => boolean): this {\n this._equals = equals;\n return this;\n }\n\n /**\n * Reverse the deque by reversing buckets and pointers.\n * @remarks Time O(N), Space O(N)\n * @returns This deque.\n */\n\n reverse(): this {\n this._buckets.reverse().forEach(function (bucket) {\n bucket.reverse();\n });\n const { _bucketFirst, _bucketLast, _firstInBucket, _lastInBucket } = this;\n this._bucketFirst = this._bucketCount - _bucketLast - 1;\n this._bucketLast = this._bucketCount - _bucketFirst - 1;\n this._firstInBucket = this._bucketSize - _lastInBucket - 1;\n this._lastInBucket = this._bucketSize - _firstInBucket - 1;\n return this;\n }\n\n /**\n * Deduplicate consecutive equal elements in-place.\n * @remarks Time O(N), Space O(1)\n * @returns This deque.\n */\n\n unique(): this {\n if (this._length <= 1) {\n return this;\n }\n let index = 1;\n let prev = this.at(0);\n for (let i = 1; i < this._length; ++i) {\n const cur = this.at(i);\n if (!this._equals(cur as E, prev as E)) {\n prev = cur;\n this.setAt(index++, cur as E);\n }\n }\n this.cut(index - 1, true);\n return this;\n }\n\n /**\n * Trim unused buckets to fit exactly the active range.\n * @remarks Time O(N), Space O(1)\n * @returns void\n */\n\n shrinkToFit(): void {\n if (this._length === 0) return;\n const newBuckets = [] as E[][];\n if (this._bucketFirst === this._bucketLast) return;\n else if (this._bucketFirst < this._bucketLast) {\n for (let i = this._bucketFirst; i <= this._bucketLast; ++i) {\n newBuckets.push(this._buckets[i]);\n }\n } else {\n for (let i = this._bucketFirst; i < this._bucketCount; ++i) {\n newBuckets.push(this._buckets[i]);\n }\n for (let i = 0; i <= this._bucketLast; ++i) {\n newBuckets.push(this._buckets[i]);\n }\n }\n this._bucketFirst = 0;\n this._bucketLast = newBuckets.length - 1;\n this._buckets = newBuckets;\n }\n\n /**\n * Deep clone this deque, preserving options.\n * @remarks Time O(N), Space O(N)\n * @returns A new deque with the same content and options.\n */\n\n clone(): this {\n return this._createLike<E, R>(this, {\n bucketSize: this.bucketSize,\n toElementFn: this.toElementFn,\n maxLen: this._maxLen\n }) as this;\n }\n\n /**\n * Filter elements into a new deque of the same class.\n * @remarks Time O(N), Space O(N)\n * @param predicate - Predicate (value, index, deque) → boolean to keep element.\n * @param [thisArg] - Value for `this` inside the predicate.\n * @returns A new deque with kept elements.\n */\n\n filter(predicate: ElementCallback<E, R, boolean>, thisArg?: any): this {\n const out = this._createInstance({ toElementFn: this.toElementFn, maxLen: this._maxLen });\n out._setBucketSize(this._bucketSize);\n let index = 0;\n for (const el of this) {\n if (predicate.call(thisArg, el, index, this)) out.push(el);\n index++;\n }\n return out;\n }\n\n /**\n * Map elements into a new deque of the same element type.\n * @remarks Time O(N), Space O(N)\n * @param callback - Mapping function (value, index, deque) → newValue.\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new deque with mapped values.\n */\n\n mapSame(callback: ElementCallback<E, R, E>, thisArg?: any): this {\n const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });\n out._setBucketSize(this._bucketSize);\n let index = 0;\n for (const v of this) {\n const mv = thisArg === undefined ? callback(v, index++, this) : callback.call(thisArg, v, index++, this);\n out.push(mv);\n }\n return out;\n }\n\n /**\n * Map elements into a new deque (possibly different element type).\n * @remarks Time O(N), Space O(N)\n * @template EM\n * @template RM\n * @param callback - Mapping function (value, index, deque) → newElement.\n * @param [options] - Options for the output deque (e.g., bucketSize, toElementFn, maxLen).\n * @param [thisArg] - Value for `this` inside the callback.\n * @returns A new Deque with mapped elements.\n */\n\n map<EM, RM>(\n callback: ElementCallback<E, R, EM>,\n options?: IterableElementBaseOptions<EM, RM>,\n thisArg?: any\n ): Deque<EM, RM> {\n const out = this._createLike<EM, RM>([], {\n ...(options ?? {}),\n bucketSize: this._bucketSize,\n maxLen: this._maxLen\n }) as Deque<EM, RM>;\n let index = 0;\n for (const el of this) {\n const mv = thisArg === undefined ? callback(el, index, this) : callback.call(thisArg, el, index, this);\n out.push(mv);\n index++;\n }\n return out;\n }\n\n /**\n * (Protected) Set the internal bucket size.\n * @remarks Time O(1), Space O(1)\n * @param size - Bucket capacity to assign.\n * @returns void\n */\n\n protected _setBucketSize(size: number): void {\n this._bucketSize = size;\n }\n\n /**\n * (Protected) Iterate elements from front to back.\n * @remarks Time O(N), Space O(1)\n * @returns Iterator of elements.\n */\n\n protected *_getIterator(): IterableIterator<E> {\n for (let i = 0; i < this._length; ++i) {\n const v = this.at(i);\n if (v !== undefined) yield v;\n }\n }\n\n /**\n * (Protected) Reallocate buckets to make room near the ends.\n * @remarks Time O(N), Space O(N)\n * @param [needBucketNum] - How many extra buckets to add; defaults to half of current.\n * @returns void\n */\n\n protected _reallocate(needBucketNum?: number) {\n const newBuckets = [] as E[][];\n const addBucketNum = needBucketNum || this._bucketCount >> 1 || 1;\n for (let i = 0; i < addBucketNum; ++i) {\n newBuckets[i] = new Array(this._bucketSize);\n }\n for (let i = this._bucketFirst; i < this._bucketCount; ++i) {\n newBuckets[newBuckets.length] = this._buckets[i];\n }\n for (let i = 0; i < this._bucketLast; ++i) {\n newBuckets[newBuckets.length] = this._buckets[i];\n }\n newBuckets[newBuckets.length] = [...this._buckets[this._bucketLast]];\n this._bucketFirst = addBucketNum;\n this._bucketLast = newBuckets.length - 1;\n for (let i = 0; i < addBucketNum; ++i) {\n newBuckets[newBuckets.length] = new Array(this._bucketSize);\n }\n this._buckets = newBuckets;\n this._bucketCount = newBuckets.length;\n }\n\n /**\n * (Protected) Translate a logical position to bucket/offset.\n * @remarks Time O(1), Space O(1)\n * @param pos - Zero-based position.\n * @returns An object containing bucketIndex and indexInBucket.\n */\n\n protected _getBucketAndPosition(pos: number) {\n let bucketIndex: number;\n let indexInBucket: number;\n\n const overallIndex = this._firstInBucket + pos;\n bucketIndex = this._bucketFirst + Math.floor(overallIndex / this._bucketSize);\n\n if (bucketIndex >= this._bucketCount) {\n bucketIndex -= this._bucketCount;\n }\n\n indexInBucket = ((overallIndex + 1) % this._bucketSize) - 1;\n if (indexInBucket < 0) {\n indexInBucket = this._bucketSize - 1;\n }\n\n return { bucketIndex, indexInBucket };\n }\n\n /**\n * (Protected) Create an empty instance of the same concrete class.\n * @remarks Time O(1), Space O(1)\n * @param [options] - Options forwarded to the constructor.\n * @returns An empty like-kind deque instance.\n */\n\n protected override _createInstance(options?: LinearBaseOptions<E, R>): this {\n const Ctor = this.constructor as new (\n elements?: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R>,\n options?: DequeOptions<E, R>\n ) => this;\n return new Ctor([], options as DequeOptions<E, R> | undefined);\n }\n\n /**\n * (Protected) Create a like-kind deque seeded by elements.\n * @remarks Time O(N), Space O(N)\n * @template T\n * @template RR\n * @param [elements] - Iterable used to seed the new deque.\n * @param [options] - Options forwarded to the constructor.\n * @returns A like-kind Deque instance.\n */\n\n protected _createLike<T = E, RR = R>(\n elements: IterableWithSizeOrLength<T> | IterableWithSizeOrLength<RR> = [],\n options?: DequeOptions<T, RR>\n ): any {\n const Ctor = this.constructor as new (\n elements?: IterableWithSizeOrLength<T> | IterableWithSizeOrLength<RR>,\n options?: DequeOptions<T, RR>\n ) => any;\n return new Ctor(elements, options);\n }\n\n /**\n * (Protected) Iterate elements from back to front.\n * @remarks Time O(N), Space O(1)\n * @returns Iterator of elements.\n */\n\n protected *_getReverseIterator(): IterableIterator<E> {\n for (let i = this._length - 1; i > -1; i--) {\n const v = this.at(i);\n if (v !== undefined) yield v;\n }\n }\n}\n","import { isComparable } from '../utils';\n\nexport enum DFSOperation {\n VISIT = 0,\n PROCESS = 1\n}\n\nexport class Range<K> {\n constructor(\n public low: K,\n public high: K,\n public includeLow: boolean = true,\n public includeHigh: boolean = true\n ) {\n if (!(isComparable(low) && isComparable(high))) throw new RangeError('low or high is not comparable');\n if (low > high) throw new RangeError('low must be less than or equal to high');\n }\n\n // Determine whether a key is within the range\n isInRange(key: K, comparator: (a: K, b: K) => number): boolean {\n const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;\n const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;\n return lowCheck && highCheck;\n }\n}\n"]}