data-structure-typed 2.0.5 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (785) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/COMMANDS.md +27 -0
  3. package/README.md +5 -34
  4. package/benchmark/report.html +13 -77
  5. package/benchmark/report.json +152 -184
  6. package/dist/cjs/index.cjs +13062 -0
  7. package/dist/cjs/index.cjs.map +1 -0
  8. package/dist/esm/index.mjs +12984 -0
  9. package/dist/esm/index.mjs.map +1 -0
  10. package/dist/index.cjs +13091 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.js +13013 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/types/data-structures/base/iterable-element-base.d.ts +219 -0
  15. package/dist/types/data-structures/base/iterable-entry-base.d.ts +144 -0
  16. package/dist/types/data-structures/base/linear-base.d.ts +335 -0
  17. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +182 -0
  18. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +135 -0
  19. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +291 -0
  20. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +754 -0
  21. package/dist/types/data-structures/binary-tree/bst.d.ts +413 -0
  22. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +208 -0
  23. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +190 -0
  24. package/dist/{esm → types}/data-structures/binary-tree/tree-multi-map.d.ts +72 -69
  25. package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -0
  26. package/dist/types/data-structures/graph/directed-graph.d.ts +207 -0
  27. package/dist/types/data-structures/graph/map-graph.d.ts +78 -0
  28. package/dist/types/data-structures/graph/undirected-graph.d.ts +188 -0
  29. package/dist/types/data-structures/hash/hash-map.d.ts +345 -0
  30. package/dist/types/data-structures/heap/heap.d.ts +503 -0
  31. package/dist/types/data-structures/heap/max-heap.d.ts +32 -0
  32. package/dist/types/data-structures/heap/min-heap.d.ts +33 -0
  33. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +769 -0
  34. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +451 -0
  35. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -0
  36. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -0
  37. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -0
  38. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -0
  39. package/dist/types/data-structures/queue/deque.d.ts +431 -0
  40. package/dist/types/data-structures/queue/queue.d.ts +308 -0
  41. package/dist/{cjs → types}/data-structures/stack/stack.d.ts +124 -102
  42. package/dist/types/data-structures/trie/trie.d.ts +350 -0
  43. package/dist/types/interfaces/binary-tree.d.ts +59 -0
  44. package/dist/types/interfaces/graph.d.ts +21 -0
  45. package/dist/{cjs → types}/types/data-structures/base/base.d.ts +1 -1
  46. package/dist/{esm → types}/types/data-structures/graph/abstract-graph.d.ts +4 -0
  47. package/dist/{cjs → types}/types/utils/utils.d.ts +1 -0
  48. package/dist/{esm → types}/utils/utils.d.ts +1 -1
  49. package/dist/umd/data-structure-typed.js +4693 -6484
  50. package/dist/umd/data-structure-typed.js.map +1 -0
  51. package/dist/umd/data-structure-typed.min.js +8 -6
  52. package/dist/umd/data-structure-typed.min.js.map +1 -1
  53. package/jest.integration.config.js +3 -0
  54. package/package.json +13 -12
  55. package/src/data-structures/base/iterable-element-base.ts +238 -115
  56. package/src/data-structures/base/iterable-entry-base.ts +96 -120
  57. package/src/data-structures/base/linear-base.ts +271 -277
  58. package/src/data-structures/binary-tree/avl-tree-counter.ts +196 -217
  59. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +188 -102
  60. package/src/data-structures/binary-tree/avl-tree.ts +237 -206
  61. package/src/data-structures/binary-tree/binary-tree.ts +665 -896
  62. package/src/data-structures/binary-tree/bst.ts +565 -572
  63. package/src/data-structures/binary-tree/red-black-tree.ts +157 -223
  64. package/src/data-structures/binary-tree/tree-counter.ts +195 -219
  65. package/src/data-structures/binary-tree/tree-multi-map.ts +127 -98
  66. package/src/data-structures/graph/abstract-graph.ts +339 -264
  67. package/src/data-structures/graph/directed-graph.ts +146 -236
  68. package/src/data-structures/graph/map-graph.ts +63 -60
  69. package/src/data-structures/graph/undirected-graph.ts +129 -152
  70. package/src/data-structures/hash/hash-map.ts +274 -496
  71. package/src/data-structures/heap/heap.ts +389 -402
  72. package/src/data-structures/heap/max-heap.ts +12 -76
  73. package/src/data-structures/heap/min-heap.ts +13 -76
  74. package/src/data-structures/linked-list/doubly-linked-list.ts +426 -530
  75. package/src/data-structures/linked-list/singly-linked-list.ts +495 -517
  76. package/src/data-structures/linked-list/skip-linked-list.ts +1 -108
  77. package/src/data-structures/priority-queue/max-priority-queue.ts +12 -87
  78. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -88
  79. package/src/data-structures/priority-queue/priority-queue.ts +3 -92
  80. package/src/data-structures/queue/deque.ts +381 -357
  81. package/src/data-structures/queue/queue.ts +310 -264
  82. package/src/data-structures/stack/stack.ts +217 -131
  83. package/src/data-structures/trie/trie.ts +240 -175
  84. package/src/interfaces/binary-tree.ts +240 -6
  85. package/src/interfaces/graph.ts +37 -0
  86. package/src/types/data-structures/base/base.ts +5 -5
  87. package/src/types/data-structures/graph/abstract-graph.ts +5 -0
  88. package/src/types/utils/utils.ts +2 -0
  89. package/src/utils/utils.ts +9 -14
  90. package/test/integration/all-in-one.test.ts +1 -1
  91. package/test/integration/index.html +1 -1
  92. package/test/performance/benchmark-runner.ts +528 -0
  93. package/test/performance/data-structures/comparison/comparison.test.ts +27 -57
  94. package/test/performance/reportor.mjs +43 -43
  95. package/test/performance/runner-config.json +39 -0
  96. package/test/performance/single-suite-runner.ts +69 -0
  97. package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +3 -3
  98. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +5 -5
  99. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +4 -4
  100. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +350 -90
  101. package/test/unit/data-structures/binary-tree/bst.test.ts +12 -9
  102. package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +2 -2
  103. package/test/unit/data-structures/binary-tree/tree-counter.test.ts +25 -24
  104. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +112 -4
  105. package/test/unit/data-structures/graph/abstract-graph.test.ts +0 -4
  106. package/test/unit/data-structures/graph/directed-graph.test.ts +1 -1
  107. package/test/unit/data-structures/heap/heap.test.ts +14 -21
  108. package/test/unit/data-structures/heap/max-heap.test.ts +5 -9
  109. package/test/unit/data-structures/heap/min-heap.test.ts +1 -4
  110. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +14 -14
  111. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +0 -7
  112. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +8 -11
  113. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -4
  114. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +1 -4
  115. package/test/unit/data-structures/queue/queue.test.ts +4 -5
  116. package/test/unit/utils/utils.test.ts +0 -1
  117. package/tsconfig-base.json +20 -20
  118. package/tsconfig-types.json +17 -0
  119. package/tsconfig.test.json +8 -0
  120. package/tsup.config.js +11 -22
  121. package/tsup.node.config.ts +37 -0
  122. package/dist/cjs/common/index.js +0 -29
  123. package/dist/cjs/common/index.js.map +0 -1
  124. package/dist/cjs/data-structures/base/index.js +0 -19
  125. package/dist/cjs/data-structures/base/index.js.map +0 -1
  126. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +0 -116
  127. package/dist/cjs/data-structures/base/iterable-element-base.js +0 -202
  128. package/dist/cjs/data-structures/base/iterable-element-base.js.map +0 -1
  129. package/dist/cjs/data-structures/base/iterable-entry-base.d.ts +0 -168
  130. package/dist/cjs/data-structures/base/iterable-entry-base.js +0 -241
  131. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +0 -1
  132. package/dist/cjs/data-structures/base/linear-base.d.ts +0 -277
  133. package/dist/cjs/data-structures/base/linear-base.js +0 -553
  134. package/dist/cjs/data-structures/base/linear-base.js.map +0 -1
  135. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.d.ts +0 -214
  136. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +0 -409
  137. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  138. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -104
  139. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +0 -203
  140. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  141. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -302
  142. package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -599
  143. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +0 -1
  144. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +0 -295
  145. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  146. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +0 -910
  147. package/dist/cjs/data-structures/binary-tree/binary-tree.js +0 -2197
  148. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +0 -1
  149. package/dist/cjs/data-structures/binary-tree/bst.d.ts +0 -461
  150. package/dist/cjs/data-structures/binary-tree/bst.js +0 -880
  151. package/dist/cjs/data-structures/binary-tree/bst.js.map +0 -1
  152. package/dist/cjs/data-structures/binary-tree/index.js +0 -27
  153. package/dist/cjs/data-structures/binary-tree/index.js.map +0 -1
  154. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +0 -280
  155. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +0 -642
  156. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +0 -1
  157. package/dist/cjs/data-structures/binary-tree/segment-tree.js +0 -298
  158. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +0 -1
  159. package/dist/cjs/data-structures/binary-tree/tree-counter.d.ts +0 -212
  160. package/dist/cjs/data-structures/binary-tree/tree-counter.js +0 -445
  161. package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +0 -1
  162. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -267
  163. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +0 -365
  164. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  165. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -335
  166. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -867
  167. package/dist/cjs/data-structures/graph/abstract-graph.js.map +0 -1
  168. package/dist/cjs/data-structures/graph/directed-graph.d.ts +0 -323
  169. package/dist/cjs/data-structures/graph/directed-graph.js +0 -613
  170. package/dist/cjs/data-structures/graph/directed-graph.js.map +0 -1
  171. package/dist/cjs/data-structures/graph/index.js +0 -21
  172. package/dist/cjs/data-structures/graph/index.js.map +0 -1
  173. package/dist/cjs/data-structures/graph/map-graph.d.ts +0 -84
  174. package/dist/cjs/data-structures/graph/map-graph.js +0 -111
  175. package/dist/cjs/data-structures/graph/map-graph.js.map +0 -1
  176. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +0 -231
  177. package/dist/cjs/data-structures/graph/undirected-graph.js +0 -445
  178. package/dist/cjs/data-structures/graph/undirected-graph.js.map +0 -1
  179. package/dist/cjs/data-structures/hash/hash-map.d.ts +0 -519
  180. package/dist/cjs/data-structures/hash/hash-map.js +0 -880
  181. package/dist/cjs/data-structures/hash/hash-map.js.map +0 -1
  182. package/dist/cjs/data-structures/hash/index.js +0 -18
  183. package/dist/cjs/data-structures/hash/index.js.map +0 -1
  184. package/dist/cjs/data-structures/heap/heap.d.ts +0 -578
  185. package/dist/cjs/data-structures/heap/heap.js +0 -911
  186. package/dist/cjs/data-structures/heap/heap.js.map +0 -1
  187. package/dist/cjs/data-structures/heap/index.js +0 -20
  188. package/dist/cjs/data-structures/heap/index.js.map +0 -1
  189. package/dist/cjs/data-structures/heap/max-heap.d.ts +0 -68
  190. package/dist/cjs/data-structures/heap/max-heap.js +0 -96
  191. package/dist/cjs/data-structures/heap/max-heap.js.map +0 -1
  192. package/dist/cjs/data-structures/heap/min-heap.d.ts +0 -68
  193. package/dist/cjs/data-structures/heap/min-heap.js +0 -87
  194. package/dist/cjs/data-structures/heap/min-heap.js.map +0 -1
  195. package/dist/cjs/data-structures/index.js +0 -29
  196. package/dist/cjs/data-structures/index.js.map +0 -1
  197. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +0 -885
  198. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +0 -1238
  199. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  200. package/dist/cjs/data-structures/linked-list/index.js +0 -20
  201. package/dist/cjs/data-structures/linked-list/index.js.map +0 -1
  202. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +0 -500
  203. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +0 -870
  204. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +0 -1
  205. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +0 -134
  206. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +0 -245
  207. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +0 -1
  208. package/dist/cjs/data-structures/matrix/index.js +0 -19
  209. package/dist/cjs/data-structures/matrix/index.js.map +0 -1
  210. package/dist/cjs/data-structures/matrix/matrix.js +0 -449
  211. package/dist/cjs/data-structures/matrix/matrix.js.map +0 -1
  212. package/dist/cjs/data-structures/matrix/navigator.js +0 -112
  213. package/dist/cjs/data-structures/matrix/navigator.js.map +0 -1
  214. package/dist/cjs/data-structures/priority-queue/index.js +0 -20
  215. package/dist/cjs/data-structures/priority-queue/index.js.map +0 -1
  216. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +0 -71
  217. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +0 -102
  218. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  219. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +0 -72
  220. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +0 -94
  221. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  222. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +0 -74
  223. package/dist/cjs/data-structures/priority-queue/priority-queue.js +0 -96
  224. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +0 -1
  225. package/dist/cjs/data-structures/queue/deque.d.ts +0 -458
  226. package/dist/cjs/data-structures/queue/deque.js +0 -919
  227. package/dist/cjs/data-structures/queue/deque.js.map +0 -1
  228. package/dist/cjs/data-structures/queue/index.js +0 -19
  229. package/dist/cjs/data-structures/queue/index.js.map +0 -1
  230. package/dist/cjs/data-structures/queue/queue.d.ts +0 -329
  231. package/dist/cjs/data-structures/queue/queue.js +0 -457
  232. package/dist/cjs/data-structures/queue/queue.js.map +0 -1
  233. package/dist/cjs/data-structures/stack/index.js +0 -18
  234. package/dist/cjs/data-structures/stack/index.js.map +0 -1
  235. package/dist/cjs/data-structures/stack/stack.js +0 -346
  236. package/dist/cjs/data-structures/stack/stack.js.map +0 -1
  237. package/dist/cjs/data-structures/tree/index.js +0 -18
  238. package/dist/cjs/data-structures/tree/index.js.map +0 -1
  239. package/dist/cjs/data-structures/tree/tree.js +0 -108
  240. package/dist/cjs/data-structures/tree/tree.js.map +0 -1
  241. package/dist/cjs/data-structures/trie/index.js +0 -18
  242. package/dist/cjs/data-structures/trie/index.js.map +0 -1
  243. package/dist/cjs/data-structures/trie/trie.d.ts +0 -351
  244. package/dist/cjs/data-structures/trie/trie.js +0 -594
  245. package/dist/cjs/data-structures/trie/trie.js.map +0 -1
  246. package/dist/cjs/index.js +0 -22
  247. package/dist/cjs/index.js.map +0 -1
  248. package/dist/cjs/interfaces/binary-tree.d.ts +0 -9
  249. package/dist/cjs/interfaces/binary-tree.js +0 -3
  250. package/dist/cjs/interfaces/binary-tree.js.map +0 -1
  251. package/dist/cjs/interfaces/doubly-linked-list.js +0 -3
  252. package/dist/cjs/interfaces/doubly-linked-list.js.map +0 -1
  253. package/dist/cjs/interfaces/graph.d.ts +0 -5
  254. package/dist/cjs/interfaces/graph.js +0 -3
  255. package/dist/cjs/interfaces/graph.js.map +0 -1
  256. package/dist/cjs/interfaces/heap.js +0 -3
  257. package/dist/cjs/interfaces/heap.js.map +0 -1
  258. package/dist/cjs/interfaces/index.js +0 -25
  259. package/dist/cjs/interfaces/index.js.map +0 -1
  260. package/dist/cjs/interfaces/navigator.js +0 -3
  261. package/dist/cjs/interfaces/navigator.js.map +0 -1
  262. package/dist/cjs/interfaces/priority-queue.js +0 -3
  263. package/dist/cjs/interfaces/priority-queue.js.map +0 -1
  264. package/dist/cjs/interfaces/segment-tree.js +0 -3
  265. package/dist/cjs/interfaces/segment-tree.js.map +0 -1
  266. package/dist/cjs/interfaces/singly-linked-list.js +0 -3
  267. package/dist/cjs/interfaces/singly-linked-list.js.map +0 -1
  268. package/dist/cjs/types/common.js +0 -3
  269. package/dist/cjs/types/common.js.map +0 -1
  270. package/dist/cjs/types/data-structures/base/base.js +0 -3
  271. package/dist/cjs/types/data-structures/base/base.js.map +0 -1
  272. package/dist/cjs/types/data-structures/base/index.js +0 -18
  273. package/dist/cjs/types/data-structures/base/index.js.map +0 -1
  274. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js +0 -3
  275. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  276. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -3
  277. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  278. package/dist/cjs/types/data-structures/binary-tree/avl-tree.js +0 -3
  279. package/dist/cjs/types/data-structures/binary-tree/avl-tree.js.map +0 -1
  280. package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js +0 -3
  281. package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  282. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +0 -3
  283. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +0 -1
  284. package/dist/cjs/types/data-structures/binary-tree/bst.js +0 -3
  285. package/dist/cjs/types/data-structures/binary-tree/bst.js.map +0 -1
  286. package/dist/cjs/types/data-structures/binary-tree/index.js +0 -26
  287. package/dist/cjs/types/data-structures/binary-tree/index.js.map +0 -1
  288. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js +0 -3
  289. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
  290. package/dist/cjs/types/data-structures/binary-tree/segment-tree.js +0 -3
  291. package/dist/cjs/types/data-structures/binary-tree/segment-tree.js.map +0 -1
  292. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js +0 -3
  293. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js.map +0 -1
  294. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js +0 -3
  295. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  296. package/dist/cjs/types/data-structures/graph/abstract-graph.d.ts +0 -10
  297. package/dist/cjs/types/data-structures/graph/abstract-graph.js +0 -3
  298. package/dist/cjs/types/data-structures/graph/abstract-graph.js.map +0 -1
  299. package/dist/cjs/types/data-structures/graph/directed-graph.js +0 -3
  300. package/dist/cjs/types/data-structures/graph/directed-graph.js.map +0 -1
  301. package/dist/cjs/types/data-structures/graph/index.js +0 -20
  302. package/dist/cjs/types/data-structures/graph/index.js.map +0 -1
  303. package/dist/cjs/types/data-structures/graph/map-graph.js +0 -3
  304. package/dist/cjs/types/data-structures/graph/map-graph.js.map +0 -1
  305. package/dist/cjs/types/data-structures/graph/undirected-graph.js +0 -3
  306. package/dist/cjs/types/data-structures/graph/undirected-graph.js.map +0 -1
  307. package/dist/cjs/types/data-structures/hash/hash-map.js +0 -3
  308. package/dist/cjs/types/data-structures/hash/hash-map.js.map +0 -1
  309. package/dist/cjs/types/data-structures/hash/index.js +0 -18
  310. package/dist/cjs/types/data-structures/hash/index.js.map +0 -1
  311. package/dist/cjs/types/data-structures/heap/heap.js +0 -3
  312. package/dist/cjs/types/data-structures/heap/heap.js.map +0 -1
  313. package/dist/cjs/types/data-structures/heap/index.js +0 -18
  314. package/dist/cjs/types/data-structures/heap/index.js.map +0 -1
  315. package/dist/cjs/types/data-structures/heap/max-heap.js +0 -3
  316. package/dist/cjs/types/data-structures/heap/max-heap.js.map +0 -1
  317. package/dist/cjs/types/data-structures/heap/min-heap.js +0 -3
  318. package/dist/cjs/types/data-structures/heap/min-heap.js.map +0 -1
  319. package/dist/cjs/types/data-structures/index.js +0 -29
  320. package/dist/cjs/types/data-structures/index.js.map +0 -1
  321. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js +0 -3
  322. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  323. package/dist/cjs/types/data-structures/linked-list/index.js +0 -20
  324. package/dist/cjs/types/data-structures/linked-list/index.js.map +0 -1
  325. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js +0 -3
  326. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
  327. package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js +0 -3
  328. package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
  329. package/dist/cjs/types/data-structures/matrix/index.js +0 -19
  330. package/dist/cjs/types/data-structures/matrix/index.js.map +0 -1
  331. package/dist/cjs/types/data-structures/matrix/matrix.js +0 -3
  332. package/dist/cjs/types/data-structures/matrix/matrix.js.map +0 -1
  333. package/dist/cjs/types/data-structures/matrix/navigator.js +0 -3
  334. package/dist/cjs/types/data-structures/matrix/navigator.js.map +0 -1
  335. package/dist/cjs/types/data-structures/priority-queue/index.js +0 -20
  336. package/dist/cjs/types/data-structures/priority-queue/index.js.map +0 -1
  337. package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js +0 -3
  338. package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  339. package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js +0 -3
  340. package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  341. package/dist/cjs/types/data-structures/priority-queue/priority-queue.js +0 -3
  342. package/dist/cjs/types/data-structures/priority-queue/priority-queue.js.map +0 -1
  343. package/dist/cjs/types/data-structures/queue/deque.js +0 -3
  344. package/dist/cjs/types/data-structures/queue/deque.js.map +0 -1
  345. package/dist/cjs/types/data-structures/queue/index.js +0 -19
  346. package/dist/cjs/types/data-structures/queue/index.js.map +0 -1
  347. package/dist/cjs/types/data-structures/queue/queue.js +0 -3
  348. package/dist/cjs/types/data-structures/queue/queue.js.map +0 -1
  349. package/dist/cjs/types/data-structures/stack/index.js +0 -18
  350. package/dist/cjs/types/data-structures/stack/index.js.map +0 -1
  351. package/dist/cjs/types/data-structures/stack/stack.js +0 -3
  352. package/dist/cjs/types/data-structures/stack/stack.js.map +0 -1
  353. package/dist/cjs/types/data-structures/tree/index.js +0 -18
  354. package/dist/cjs/types/data-structures/tree/index.js.map +0 -1
  355. package/dist/cjs/types/data-structures/tree/tree.js +0 -3
  356. package/dist/cjs/types/data-structures/tree/tree.js.map +0 -1
  357. package/dist/cjs/types/data-structures/trie/index.js +0 -18
  358. package/dist/cjs/types/data-structures/trie/index.js.map +0 -1
  359. package/dist/cjs/types/data-structures/trie/trie.js +0 -3
  360. package/dist/cjs/types/data-structures/trie/trie.js.map +0 -1
  361. package/dist/cjs/types/index.js +0 -20
  362. package/dist/cjs/types/index.js.map +0 -1
  363. package/dist/cjs/types/utils/index.js +0 -19
  364. package/dist/cjs/types/utils/index.js.map +0 -1
  365. package/dist/cjs/types/utils/utils.js +0 -3
  366. package/dist/cjs/types/utils/utils.js.map +0 -1
  367. package/dist/cjs/types/utils/validate-type.js +0 -3
  368. package/dist/cjs/types/utils/validate-type.js.map +0 -1
  369. package/dist/cjs/utils/index.js +0 -19
  370. package/dist/cjs/utils/index.js.map +0 -1
  371. package/dist/cjs/utils/number.js +0 -24
  372. package/dist/cjs/utils/number.js.map +0 -1
  373. package/dist/cjs/utils/utils.d.ts +0 -209
  374. package/dist/cjs/utils/utils.js +0 -353
  375. package/dist/cjs/utils/utils.js.map +0 -1
  376. package/dist/esm/common/index.d.ts +0 -12
  377. package/dist/esm/common/index.js +0 -29
  378. package/dist/esm/common/index.js.map +0 -1
  379. package/dist/esm/data-structures/base/index.d.ts +0 -2
  380. package/dist/esm/data-structures/base/index.js +0 -3
  381. package/dist/esm/data-structures/base/index.js.map +0 -1
  382. package/dist/esm/data-structures/base/iterable-element-base.d.ts +0 -116
  383. package/dist/esm/data-structures/base/iterable-element-base.js +0 -199
  384. package/dist/esm/data-structures/base/iterable-element-base.js.map +0 -1
  385. package/dist/esm/data-structures/base/iterable-entry-base.d.ts +0 -168
  386. package/dist/esm/data-structures/base/iterable-entry-base.js +0 -237
  387. package/dist/esm/data-structures/base/iterable-entry-base.js.map +0 -1
  388. package/dist/esm/data-structures/base/linear-base.d.ts +0 -277
  389. package/dist/esm/data-structures/base/linear-base.js +0 -549
  390. package/dist/esm/data-structures/base/linear-base.js.map +0 -1
  391. package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +0 -214
  392. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js +0 -410
  393. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  394. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -104
  395. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +0 -205
  396. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  397. package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +0 -302
  398. package/dist/esm/data-structures/binary-tree/avl-tree.js +0 -601
  399. package/dist/esm/data-structures/binary-tree/avl-tree.js.map +0 -1
  400. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
  401. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js +0 -296
  402. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  403. package/dist/esm/data-structures/binary-tree/binary-tree.d.ts +0 -910
  404. package/dist/esm/data-structures/binary-tree/binary-tree.js +0 -2198
  405. package/dist/esm/data-structures/binary-tree/binary-tree.js.map +0 -1
  406. package/dist/esm/data-structures/binary-tree/bst.d.ts +0 -461
  407. package/dist/esm/data-structures/binary-tree/bst.js +0 -881
  408. package/dist/esm/data-structures/binary-tree/bst.js.map +0 -1
  409. package/dist/esm/data-structures/binary-tree/index.d.ts +0 -10
  410. package/dist/esm/data-structures/binary-tree/index.js +0 -11
  411. package/dist/esm/data-structures/binary-tree/index.js.map +0 -1
  412. package/dist/esm/data-structures/binary-tree/red-black-tree.d.ts +0 -280
  413. package/dist/esm/data-structures/binary-tree/red-black-tree.js +0 -641
  414. package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +0 -1
  415. package/dist/esm/data-structures/binary-tree/segment-tree.d.ts +0 -160
  416. package/dist/esm/data-structures/binary-tree/segment-tree.js +0 -295
  417. package/dist/esm/data-structures/binary-tree/segment-tree.js.map +0 -1
  418. package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +0 -212
  419. package/dist/esm/data-structures/binary-tree/tree-counter.js +0 -446
  420. package/dist/esm/data-structures/binary-tree/tree-counter.js.map +0 -1
  421. package/dist/esm/data-structures/binary-tree/tree-multi-map.js +0 -367
  422. package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  423. package/dist/esm/data-structures/graph/abstract-graph.d.ts +0 -335
  424. package/dist/esm/data-structures/graph/abstract-graph.js +0 -862
  425. package/dist/esm/data-structures/graph/abstract-graph.js.map +0 -1
  426. package/dist/esm/data-structures/graph/directed-graph.d.ts +0 -323
  427. package/dist/esm/data-structures/graph/directed-graph.js +0 -609
  428. package/dist/esm/data-structures/graph/directed-graph.js.map +0 -1
  429. package/dist/esm/data-structures/graph/index.d.ts +0 -4
  430. package/dist/esm/data-structures/graph/index.js +0 -5
  431. package/dist/esm/data-structures/graph/index.js.map +0 -1
  432. package/dist/esm/data-structures/graph/map-graph.d.ts +0 -84
  433. package/dist/esm/data-structures/graph/map-graph.js +0 -108
  434. package/dist/esm/data-structures/graph/map-graph.js.map +0 -1
  435. package/dist/esm/data-structures/graph/undirected-graph.d.ts +0 -231
  436. package/dist/esm/data-structures/graph/undirected-graph.js +0 -439
  437. package/dist/esm/data-structures/graph/undirected-graph.js.map +0 -1
  438. package/dist/esm/data-structures/hash/hash-map.d.ts +0 -519
  439. package/dist/esm/data-structures/hash/hash-map.js +0 -878
  440. package/dist/esm/data-structures/hash/hash-map.js.map +0 -1
  441. package/dist/esm/data-structures/hash/index.d.ts +0 -1
  442. package/dist/esm/data-structures/hash/index.js +0 -2
  443. package/dist/esm/data-structures/hash/index.js.map +0 -1
  444. package/dist/esm/data-structures/heap/heap.d.ts +0 -578
  445. package/dist/esm/data-structures/heap/heap.js +0 -914
  446. package/dist/esm/data-structures/heap/heap.js.map +0 -1
  447. package/dist/esm/data-structures/heap/index.d.ts +0 -3
  448. package/dist/esm/data-structures/heap/index.js +0 -4
  449. package/dist/esm/data-structures/heap/index.js.map +0 -1
  450. package/dist/esm/data-structures/heap/max-heap.d.ts +0 -68
  451. package/dist/esm/data-structures/heap/max-heap.js +0 -95
  452. package/dist/esm/data-structures/heap/max-heap.js.map +0 -1
  453. package/dist/esm/data-structures/heap/min-heap.d.ts +0 -68
  454. package/dist/esm/data-structures/heap/min-heap.js +0 -83
  455. package/dist/esm/data-structures/heap/min-heap.js.map +0 -1
  456. package/dist/esm/data-structures/index.d.ts +0 -12
  457. package/dist/esm/data-structures/index.js +0 -13
  458. package/dist/esm/data-structures/index.js.map +0 -1
  459. package/dist/esm/data-structures/linked-list/doubly-linked-list.d.ts +0 -885
  460. package/dist/esm/data-structures/linked-list/doubly-linked-list.js +0 -1236
  461. package/dist/esm/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  462. package/dist/esm/data-structures/linked-list/index.d.ts +0 -3
  463. package/dist/esm/data-structures/linked-list/index.js +0 -4
  464. package/dist/esm/data-structures/linked-list/index.js.map +0 -1
  465. package/dist/esm/data-structures/linked-list/singly-linked-list.d.ts +0 -500
  466. package/dist/esm/data-structures/linked-list/singly-linked-list.js +0 -866
  467. package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +0 -1
  468. package/dist/esm/data-structures/linked-list/skip-linked-list.d.ts +0 -134
  469. package/dist/esm/data-structures/linked-list/skip-linked-list.js +0 -243
  470. package/dist/esm/data-structures/linked-list/skip-linked-list.js.map +0 -1
  471. package/dist/esm/data-structures/matrix/index.d.ts +0 -2
  472. package/dist/esm/data-structures/matrix/index.js +0 -3
  473. package/dist/esm/data-structures/matrix/index.js.map +0 -1
  474. package/dist/esm/data-structures/matrix/matrix.d.ts +0 -168
  475. package/dist/esm/data-structures/matrix/matrix.js +0 -444
  476. package/dist/esm/data-structures/matrix/matrix.js.map +0 -1
  477. package/dist/esm/data-structures/matrix/navigator.d.ts +0 -55
  478. package/dist/esm/data-structures/matrix/navigator.js +0 -114
  479. package/dist/esm/data-structures/matrix/navigator.js.map +0 -1
  480. package/dist/esm/data-structures/priority-queue/index.d.ts +0 -3
  481. package/dist/esm/data-structures/priority-queue/index.js +0 -4
  482. package/dist/esm/data-structures/priority-queue/index.js.map +0 -1
  483. package/dist/esm/data-structures/priority-queue/max-priority-queue.d.ts +0 -71
  484. package/dist/esm/data-structures/priority-queue/max-priority-queue.js +0 -101
  485. package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  486. package/dist/esm/data-structures/priority-queue/min-priority-queue.d.ts +0 -72
  487. package/dist/esm/data-structures/priority-queue/min-priority-queue.js +0 -90
  488. package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  489. package/dist/esm/data-structures/priority-queue/priority-queue.d.ts +0 -74
  490. package/dist/esm/data-structures/priority-queue/priority-queue.js +0 -92
  491. package/dist/esm/data-structures/priority-queue/priority-queue.js.map +0 -1
  492. package/dist/esm/data-structures/queue/deque.d.ts +0 -458
  493. package/dist/esm/data-structures/queue/deque.js +0 -915
  494. package/dist/esm/data-structures/queue/deque.js.map +0 -1
  495. package/dist/esm/data-structures/queue/index.d.ts +0 -2
  496. package/dist/esm/data-structures/queue/index.js +0 -3
  497. package/dist/esm/data-structures/queue/index.js.map +0 -1
  498. package/dist/esm/data-structures/queue/queue.d.ts +0 -329
  499. package/dist/esm/data-structures/queue/queue.js +0 -452
  500. package/dist/esm/data-structures/queue/queue.js.map +0 -1
  501. package/dist/esm/data-structures/stack/index.d.ts +0 -1
  502. package/dist/esm/data-structures/stack/index.js +0 -2
  503. package/dist/esm/data-structures/stack/index.js.map +0 -1
  504. package/dist/esm/data-structures/stack/stack.d.ts +0 -284
  505. package/dist/esm/data-structures/stack/stack.js +0 -342
  506. package/dist/esm/data-structures/stack/stack.js.map +0 -1
  507. package/dist/esm/data-structures/tree/index.d.ts +0 -1
  508. package/dist/esm/data-structures/tree/index.js +0 -2
  509. package/dist/esm/data-structures/tree/index.js.map +0 -1
  510. package/dist/esm/data-structures/tree/tree.d.ts +0 -62
  511. package/dist/esm/data-structures/tree/tree.js +0 -107
  512. package/dist/esm/data-structures/tree/tree.js.map +0 -1
  513. package/dist/esm/data-structures/trie/index.d.ts +0 -1
  514. package/dist/esm/data-structures/trie/index.js +0 -2
  515. package/dist/esm/data-structures/trie/index.js.map +0 -1
  516. package/dist/esm/data-structures/trie/trie.d.ts +0 -351
  517. package/dist/esm/data-structures/trie/trie.js +0 -592
  518. package/dist/esm/data-structures/trie/trie.js.map +0 -1
  519. package/dist/esm/index.d.ts +0 -5
  520. package/dist/esm/index.js +0 -6
  521. package/dist/esm/index.js.map +0 -1
  522. package/dist/esm/interfaces/binary-tree.d.ts +0 -9
  523. package/dist/esm/interfaces/binary-tree.js +0 -2
  524. package/dist/esm/interfaces/binary-tree.js.map +0 -1
  525. package/dist/esm/interfaces/doubly-linked-list.d.ts +0 -1
  526. package/dist/esm/interfaces/doubly-linked-list.js +0 -2
  527. package/dist/esm/interfaces/doubly-linked-list.js.map +0 -1
  528. package/dist/esm/interfaces/graph.d.ts +0 -5
  529. package/dist/esm/interfaces/graph.js +0 -2
  530. package/dist/esm/interfaces/graph.js.map +0 -1
  531. package/dist/esm/interfaces/heap.d.ts +0 -1
  532. package/dist/esm/interfaces/heap.js +0 -2
  533. package/dist/esm/interfaces/heap.js.map +0 -1
  534. package/dist/esm/interfaces/index.d.ts +0 -8
  535. package/dist/esm/interfaces/index.js +0 -9
  536. package/dist/esm/interfaces/index.js.map +0 -1
  537. package/dist/esm/interfaces/navigator.d.ts +0 -1
  538. package/dist/esm/interfaces/navigator.js +0 -2
  539. package/dist/esm/interfaces/navigator.js.map +0 -1
  540. package/dist/esm/interfaces/priority-queue.d.ts +0 -1
  541. package/dist/esm/interfaces/priority-queue.js +0 -2
  542. package/dist/esm/interfaces/priority-queue.js.map +0 -1
  543. package/dist/esm/interfaces/segment-tree.d.ts +0 -1
  544. package/dist/esm/interfaces/segment-tree.js +0 -2
  545. package/dist/esm/interfaces/segment-tree.js.map +0 -1
  546. package/dist/esm/interfaces/singly-linked-list.d.ts +0 -1
  547. package/dist/esm/interfaces/singly-linked-list.js +0 -2
  548. package/dist/esm/interfaces/singly-linked-list.js.map +0 -1
  549. package/dist/esm/types/common.d.ts +0 -15
  550. package/dist/esm/types/common.js +0 -2
  551. package/dist/esm/types/common.js.map +0 -1
  552. package/dist/esm/types/data-structures/base/base.d.ts +0 -13
  553. package/dist/esm/types/data-structures/base/base.js +0 -2
  554. package/dist/esm/types/data-structures/base/base.js.map +0 -1
  555. package/dist/esm/types/data-structures/base/index.d.ts +0 -1
  556. package/dist/esm/types/data-structures/base/index.js +0 -2
  557. package/dist/esm/types/data-structures/base/index.js.map +0 -1
  558. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -2
  559. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
  560. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  561. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -2
  562. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
  563. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  564. package/dist/esm/types/data-structures/binary-tree/avl-tree.d.ts +0 -2
  565. package/dist/esm/types/data-structures/binary-tree/avl-tree.js +0 -2
  566. package/dist/esm/types/data-structures/binary-tree/avl-tree.js.map +0 -1
  567. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -1
  568. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
  569. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  570. package/dist/esm/types/data-structures/binary-tree/binary-tree.d.ts +0 -29
  571. package/dist/esm/types/data-structures/binary-tree/binary-tree.js +0 -2
  572. package/dist/esm/types/data-structures/binary-tree/binary-tree.js.map +0 -1
  573. package/dist/esm/types/data-structures/binary-tree/bst.d.ts +0 -12
  574. package/dist/esm/types/data-structures/binary-tree/bst.js +0 -2
  575. package/dist/esm/types/data-structures/binary-tree/bst.js.map +0 -1
  576. package/dist/esm/types/data-structures/binary-tree/index.d.ts +0 -9
  577. package/dist/esm/types/data-structures/binary-tree/index.js +0 -10
  578. package/dist/esm/types/data-structures/binary-tree/index.js.map +0 -1
  579. package/dist/esm/types/data-structures/binary-tree/red-black-tree.d.ts +0 -3
  580. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js +0 -2
  581. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
  582. package/dist/esm/types/data-structures/binary-tree/segment-tree.d.ts +0 -1
  583. package/dist/esm/types/data-structures/binary-tree/segment-tree.js +0 -2
  584. package/dist/esm/types/data-structures/binary-tree/segment-tree.js.map +0 -1
  585. package/dist/esm/types/data-structures/binary-tree/tree-counter.d.ts +0 -2
  586. package/dist/esm/types/data-structures/binary-tree/tree-counter.js +0 -2
  587. package/dist/esm/types/data-structures/binary-tree/tree-counter.js.map +0 -1
  588. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -2
  589. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js +0 -2
  590. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  591. package/dist/esm/types/data-structures/graph/abstract-graph.js +0 -2
  592. package/dist/esm/types/data-structures/graph/abstract-graph.js.map +0 -1
  593. package/dist/esm/types/data-structures/graph/directed-graph.d.ts +0 -1
  594. package/dist/esm/types/data-structures/graph/directed-graph.js +0 -2
  595. package/dist/esm/types/data-structures/graph/directed-graph.js.map +0 -1
  596. package/dist/esm/types/data-structures/graph/index.d.ts +0 -3
  597. package/dist/esm/types/data-structures/graph/index.js +0 -4
  598. package/dist/esm/types/data-structures/graph/index.js.map +0 -1
  599. package/dist/esm/types/data-structures/graph/map-graph.d.ts +0 -1
  600. package/dist/esm/types/data-structures/graph/map-graph.js +0 -2
  601. package/dist/esm/types/data-structures/graph/map-graph.js.map +0 -1
  602. package/dist/esm/types/data-structures/graph/undirected-graph.d.ts +0 -1
  603. package/dist/esm/types/data-structures/graph/undirected-graph.js +0 -2
  604. package/dist/esm/types/data-structures/graph/undirected-graph.js.map +0 -1
  605. package/dist/esm/types/data-structures/hash/hash-map.d.ts +0 -19
  606. package/dist/esm/types/data-structures/hash/hash-map.js +0 -2
  607. package/dist/esm/types/data-structures/hash/hash-map.js.map +0 -1
  608. package/dist/esm/types/data-structures/hash/index.d.ts +0 -2
  609. package/dist/esm/types/data-structures/hash/index.js +0 -2
  610. package/dist/esm/types/data-structures/hash/index.js.map +0 -1
  611. package/dist/esm/types/data-structures/heap/heap.d.ts +0 -5
  612. package/dist/esm/types/data-structures/heap/heap.js +0 -2
  613. package/dist/esm/types/data-structures/heap/heap.js.map +0 -1
  614. package/dist/esm/types/data-structures/heap/index.d.ts +0 -1
  615. package/dist/esm/types/data-structures/heap/index.js +0 -2
  616. package/dist/esm/types/data-structures/heap/index.js.map +0 -1
  617. package/dist/esm/types/data-structures/heap/max-heap.d.ts +0 -1
  618. package/dist/esm/types/data-structures/heap/max-heap.js +0 -2
  619. package/dist/esm/types/data-structures/heap/max-heap.js.map +0 -1
  620. package/dist/esm/types/data-structures/heap/min-heap.d.ts +0 -1
  621. package/dist/esm/types/data-structures/heap/min-heap.js +0 -2
  622. package/dist/esm/types/data-structures/heap/min-heap.js.map +0 -1
  623. package/dist/esm/types/data-structures/index.d.ts +0 -12
  624. package/dist/esm/types/data-structures/index.js +0 -13
  625. package/dist/esm/types/data-structures/index.js.map +0 -1
  626. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -2
  627. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js +0 -2
  628. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  629. package/dist/esm/types/data-structures/linked-list/index.d.ts +0 -3
  630. package/dist/esm/types/data-structures/linked-list/index.js +0 -4
  631. package/dist/esm/types/data-structures/linked-list/index.js.map +0 -1
  632. package/dist/esm/types/data-structures/linked-list/singly-linked-list.d.ts +0 -2
  633. package/dist/esm/types/data-structures/linked-list/singly-linked-list.js +0 -2
  634. package/dist/esm/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
  635. package/dist/esm/types/data-structures/linked-list/skip-linked-list.d.ts +0 -4
  636. package/dist/esm/types/data-structures/linked-list/skip-linked-list.js +0 -2
  637. package/dist/esm/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
  638. package/dist/esm/types/data-structures/matrix/index.d.ts +0 -2
  639. package/dist/esm/types/data-structures/matrix/index.js +0 -3
  640. package/dist/esm/types/data-structures/matrix/index.js.map +0 -1
  641. package/dist/esm/types/data-structures/matrix/matrix.d.ts +0 -7
  642. package/dist/esm/types/data-structures/matrix/matrix.js +0 -2
  643. package/dist/esm/types/data-structures/matrix/matrix.js.map +0 -1
  644. package/dist/esm/types/data-structures/matrix/navigator.d.ts +0 -14
  645. package/dist/esm/types/data-structures/matrix/navigator.js +0 -2
  646. package/dist/esm/types/data-structures/matrix/navigator.js.map +0 -1
  647. package/dist/esm/types/data-structures/priority-queue/index.d.ts +0 -3
  648. package/dist/esm/types/data-structures/priority-queue/index.js +0 -4
  649. package/dist/esm/types/data-structures/priority-queue/index.js.map +0 -1
  650. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -1
  651. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js +0 -2
  652. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  653. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -1
  654. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js +0 -2
  655. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  656. package/dist/esm/types/data-structures/priority-queue/priority-queue.d.ts +0 -2
  657. package/dist/esm/types/data-structures/priority-queue/priority-queue.js +0 -2
  658. package/dist/esm/types/data-structures/priority-queue/priority-queue.js.map +0 -1
  659. package/dist/esm/types/data-structures/queue/deque.d.ts +0 -4
  660. package/dist/esm/types/data-structures/queue/deque.js +0 -2
  661. package/dist/esm/types/data-structures/queue/deque.js.map +0 -1
  662. package/dist/esm/types/data-structures/queue/index.d.ts +0 -2
  663. package/dist/esm/types/data-structures/queue/index.js +0 -3
  664. package/dist/esm/types/data-structures/queue/index.js.map +0 -1
  665. package/dist/esm/types/data-structures/queue/queue.d.ts +0 -4
  666. package/dist/esm/types/data-structures/queue/queue.js +0 -2
  667. package/dist/esm/types/data-structures/queue/queue.js.map +0 -1
  668. package/dist/esm/types/data-structures/stack/index.d.ts +0 -1
  669. package/dist/esm/types/data-structures/stack/index.js +0 -2
  670. package/dist/esm/types/data-structures/stack/index.js.map +0 -1
  671. package/dist/esm/types/data-structures/stack/stack.d.ts +0 -2
  672. package/dist/esm/types/data-structures/stack/stack.js +0 -2
  673. package/dist/esm/types/data-structures/stack/stack.js.map +0 -1
  674. package/dist/esm/types/data-structures/tree/index.d.ts +0 -1
  675. package/dist/esm/types/data-structures/tree/index.js +0 -2
  676. package/dist/esm/types/data-structures/tree/index.js.map +0 -1
  677. package/dist/esm/types/data-structures/tree/tree.d.ts +0 -1
  678. package/dist/esm/types/data-structures/tree/tree.js +0 -2
  679. package/dist/esm/types/data-structures/tree/tree.js.map +0 -1
  680. package/dist/esm/types/data-structures/trie/index.d.ts +0 -1
  681. package/dist/esm/types/data-structures/trie/index.js +0 -2
  682. package/dist/esm/types/data-structures/trie/index.js.map +0 -1
  683. package/dist/esm/types/data-structures/trie/trie.d.ts +0 -4
  684. package/dist/esm/types/data-structures/trie/trie.js +0 -2
  685. package/dist/esm/types/data-structures/trie/trie.js.map +0 -1
  686. package/dist/esm/types/index.d.ts +0 -3
  687. package/dist/esm/types/index.js +0 -4
  688. package/dist/esm/types/index.js.map +0 -1
  689. package/dist/esm/types/utils/index.d.ts +0 -2
  690. package/dist/esm/types/utils/index.js +0 -3
  691. package/dist/esm/types/utils/index.js.map +0 -1
  692. package/dist/esm/types/utils/utils.d.ts +0 -21
  693. package/dist/esm/types/utils/utils.js +0 -2
  694. package/dist/esm/types/utils/utils.js.map +0 -1
  695. package/dist/esm/types/utils/validate-type.d.ts +0 -19
  696. package/dist/esm/types/utils/validate-type.js +0 -2
  697. package/dist/esm/types/utils/validate-type.js.map +0 -1
  698. package/dist/esm/utils/index.d.ts +0 -2
  699. package/dist/esm/utils/index.js +0 -3
  700. package/dist/esm/utils/index.js.map +0 -1
  701. package/dist/esm/utils/number.d.ts +0 -14
  702. package/dist/esm/utils/number.js +0 -21
  703. package/dist/esm/utils/number.js.map +0 -1
  704. package/dist/esm/utils/utils.js +0 -324
  705. package/dist/esm/utils/utils.js.map +0 -1
  706. package/test/performance/data-structures/binary-tree/avl-tree.test.mjs +0 -71
  707. package/test/performance/data-structures/binary-tree/red-black-tree.test.mjs +0 -81
  708. package/tsconfig-cjs.json +0 -14
  709. package/tsconfig-esm.json +0 -14
  710. /package/dist/{cjs → types}/common/index.d.ts +0 -0
  711. /package/dist/{cjs → types}/data-structures/base/index.d.ts +0 -0
  712. /package/dist/{cjs → types}/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  713. /package/dist/{cjs → types}/data-structures/binary-tree/index.d.ts +0 -0
  714. /package/dist/{cjs → types}/data-structures/binary-tree/segment-tree.d.ts +0 -0
  715. /package/dist/{cjs → types}/data-structures/graph/index.d.ts +0 -0
  716. /package/dist/{cjs → types}/data-structures/hash/index.d.ts +0 -0
  717. /package/dist/{cjs → types}/data-structures/heap/index.d.ts +0 -0
  718. /package/dist/{cjs → types}/data-structures/index.d.ts +0 -0
  719. /package/dist/{cjs → types}/data-structures/linked-list/index.d.ts +0 -0
  720. /package/dist/{cjs → types}/data-structures/matrix/index.d.ts +0 -0
  721. /package/dist/{cjs → types}/data-structures/matrix/matrix.d.ts +0 -0
  722. /package/dist/{cjs → types}/data-structures/matrix/navigator.d.ts +0 -0
  723. /package/dist/{cjs → types}/data-structures/priority-queue/index.d.ts +0 -0
  724. /package/dist/{cjs → types}/data-structures/queue/index.d.ts +0 -0
  725. /package/dist/{cjs → types}/data-structures/stack/index.d.ts +0 -0
  726. /package/dist/{cjs → types}/data-structures/tree/index.d.ts +0 -0
  727. /package/dist/{cjs → types}/data-structures/tree/tree.d.ts +0 -0
  728. /package/dist/{cjs → types}/data-structures/trie/index.d.ts +0 -0
  729. /package/dist/{cjs → types}/index.d.ts +0 -0
  730. /package/dist/{cjs → types}/interfaces/doubly-linked-list.d.ts +0 -0
  731. /package/dist/{cjs → types}/interfaces/heap.d.ts +0 -0
  732. /package/dist/{cjs → types}/interfaces/index.d.ts +0 -0
  733. /package/dist/{cjs → types}/interfaces/navigator.d.ts +0 -0
  734. /package/dist/{cjs → types}/interfaces/priority-queue.d.ts +0 -0
  735. /package/dist/{cjs → types}/interfaces/segment-tree.d.ts +0 -0
  736. /package/dist/{cjs → types}/interfaces/singly-linked-list.d.ts +0 -0
  737. /package/dist/{cjs → types}/types/common.d.ts +0 -0
  738. /package/dist/{cjs → types}/types/data-structures/base/index.d.ts +0 -0
  739. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -0
  740. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -0
  741. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree.d.ts +0 -0
  742. /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  743. /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-tree.d.ts +0 -0
  744. /package/dist/{cjs → types}/types/data-structures/binary-tree/bst.d.ts +0 -0
  745. /package/dist/{cjs → types}/types/data-structures/binary-tree/index.d.ts +0 -0
  746. /package/dist/{cjs → types}/types/data-structures/binary-tree/red-black-tree.d.ts +0 -0
  747. /package/dist/{cjs → types}/types/data-structures/binary-tree/segment-tree.d.ts +0 -0
  748. /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-counter.d.ts +0 -0
  749. /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -0
  750. /package/dist/{cjs → types}/types/data-structures/graph/directed-graph.d.ts +0 -0
  751. /package/dist/{cjs → types}/types/data-structures/graph/index.d.ts +0 -0
  752. /package/dist/{cjs → types}/types/data-structures/graph/map-graph.d.ts +0 -0
  753. /package/dist/{cjs → types}/types/data-structures/graph/undirected-graph.d.ts +0 -0
  754. /package/dist/{cjs → types}/types/data-structures/hash/hash-map.d.ts +0 -0
  755. /package/dist/{cjs → types}/types/data-structures/hash/index.d.ts +0 -0
  756. /package/dist/{cjs → types}/types/data-structures/heap/heap.d.ts +0 -0
  757. /package/dist/{cjs → types}/types/data-structures/heap/index.d.ts +0 -0
  758. /package/dist/{cjs → types}/types/data-structures/heap/max-heap.d.ts +0 -0
  759. /package/dist/{cjs → types}/types/data-structures/heap/min-heap.d.ts +0 -0
  760. /package/dist/{cjs → types}/types/data-structures/index.d.ts +0 -0
  761. /package/dist/{cjs → types}/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  762. /package/dist/{cjs → types}/types/data-structures/linked-list/index.d.ts +0 -0
  763. /package/dist/{cjs → types}/types/data-structures/linked-list/singly-linked-list.d.ts +0 -0
  764. /package/dist/{cjs → types}/types/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  765. /package/dist/{cjs → types}/types/data-structures/matrix/index.d.ts +0 -0
  766. /package/dist/{cjs → types}/types/data-structures/matrix/matrix.d.ts +0 -0
  767. /package/dist/{cjs → types}/types/data-structures/matrix/navigator.d.ts +0 -0
  768. /package/dist/{cjs → types}/types/data-structures/priority-queue/index.d.ts +0 -0
  769. /package/dist/{cjs → types}/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  770. /package/dist/{cjs → types}/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  771. /package/dist/{cjs → types}/types/data-structures/priority-queue/priority-queue.d.ts +0 -0
  772. /package/dist/{cjs → types}/types/data-structures/queue/deque.d.ts +0 -0
  773. /package/dist/{cjs → types}/types/data-structures/queue/index.d.ts +0 -0
  774. /package/dist/{cjs → types}/types/data-structures/queue/queue.d.ts +0 -0
  775. /package/dist/{cjs → types}/types/data-structures/stack/index.d.ts +0 -0
  776. /package/dist/{cjs → types}/types/data-structures/stack/stack.d.ts +0 -0
  777. /package/dist/{cjs → types}/types/data-structures/tree/index.d.ts +0 -0
  778. /package/dist/{cjs → types}/types/data-structures/tree/tree.d.ts +0 -0
  779. /package/dist/{cjs → types}/types/data-structures/trie/index.d.ts +0 -0
  780. /package/dist/{cjs → types}/types/data-structures/trie/trie.d.ts +0 -0
  781. /package/dist/{cjs → types}/types/index.d.ts +0 -0
  782. /package/dist/{cjs → types}/types/utils/index.d.ts +0 -0
  783. /package/dist/{cjs → types}/types/utils/validate-type.d.ts +0 -0
  784. /package/dist/{cjs → types}/utils/index.d.ts +0 -0
  785. /package/dist/{cjs → types}/utils/number.d.ts +0 -0
@@ -1,919 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Deque = void 0;
4
- const utils_1 = require("../../utils");
5
- const linear_base_1 = require("../base/linear-base");
6
- /**
7
- * 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).
8
- * 2. Efficient Random Access: Being based on an array, it offers fast random access capability, allowing constant time access to any element.
9
- * 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.
10
- * 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).
11
- * 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
12
- * @example
13
- * // prize roulette
14
- * class PrizeRoulette {
15
- * private deque: Deque<string>;
16
- *
17
- * constructor(prizes: string[]) {
18
- * // Initialize the deque with prizes
19
- * this.deque = new Deque<string>(prizes);
20
- * }
21
- *
22
- * // Rotate clockwise to the right (forward)
23
- * rotateClockwise(steps: number): void {
24
- * const n = this.deque.length;
25
- * if (n === 0) return;
26
- *
27
- * for (let i = 0; i < steps; i++) {
28
- * const last = this.deque.pop(); // Remove the last element
29
- * this.deque.unshift(last!); // Add it to the front
30
- * }
31
- * }
32
- *
33
- * // Rotate counterclockwise to the left (backward)
34
- * rotateCounterClockwise(steps: number): void {
35
- * const n = this.deque.length;
36
- * if (n === 0) return;
37
- *
38
- * for (let i = 0; i < steps; i++) {
39
- * const first = this.deque.shift(); // Remove the first element
40
- * this.deque.push(first!); // Add it to the back
41
- * }
42
- * }
43
- *
44
- * // Display the current prize at the head
45
- * display() {
46
- * return this.deque.first;
47
- * }
48
- * }
49
- *
50
- * // Example usage
51
- * const prizes = ['Car', 'Bike', 'Laptop', 'Phone', 'Watch', 'Headphones']; // Initialize the prize list
52
- * const roulette = new PrizeRoulette(prizes);
53
- *
54
- * // Display the initial state
55
- * console.log(roulette.display()); // 'Car' // Car
56
- *
57
- * // Rotate clockwise by 3 steps
58
- * roulette.rotateClockwise(3);
59
- * console.log(roulette.display()); // 'Phone' // Phone
60
- *
61
- * // Rotate counterclockwise by 2 steps
62
- * roulette.rotateCounterClockwise(2);
63
- * console.log(roulette.display()); // 'Headphones'
64
- * @example
65
- * // sliding window
66
- * // Maximum function of sliding window
67
- * function maxSlidingWindow(nums: number[], k: number): number[] {
68
- * const n = nums.length;
69
- * if (n * k === 0) return [];
70
- *
71
- * const deq = new Deque<number>();
72
- * const result: number[] = [];
73
- *
74
- * for (let i = 0; i < n; i++) {
75
- * // Delete indexes in the queue that are not within the window range
76
- * if (deq.length > 0 && deq.first! === i - k) {
77
- * deq.shift();
78
- * }
79
- *
80
- * // Remove all indices less than the current value from the tail of the queue
81
- * while (deq.length > 0 && nums[deq.last!] < nums[i]) {
82
- * deq.pop();
83
- * }
84
- *
85
- * // Add the current index to the end of the queue
86
- * deq.push(i);
87
- *
88
- * // Add the maximum value of the window to the results
89
- * if (i >= k - 1) {
90
- * result.push(nums[deq.first!]);
91
- * }
92
- * }
93
- *
94
- * return result;
95
- * }
96
- *
97
- * const nums = [1, 3, -1, -3, 5, 3, 6, 7];
98
- * const k = 3;
99
- * console.log(maxSlidingWindow(nums, k)); // [3, 3, 5, 5, 6, 7]
100
- */
101
- class Deque extends linear_base_1.LinearBase {
102
- /**
103
- * The constructor initializes a Deque object with optional iterable of elements and options.
104
- * @param elements - An iterable object (such as an array or a Set) that contains the initial
105
- * elements to be added to the deque. It can also be an object with a `length` or `size` property
106
- * that represents the number of elements in the iterable object. If no elements are provided, an
107
- * empty deque
108
- * @param {DequeOptions} [options] - The `options` parameter is an optional object that can contain
109
- * configuration options for the deque. In this code, it is used to set the `bucketSize` option,
110
- * which determines the size of each bucket in the deque. If the `bucketSize` option is not provided
111
- * or is not a number
112
- */
113
- constructor(elements = [], options) {
114
- super(options);
115
- this._bucketSize = 1 << 12;
116
- this._bucketFirst = 0;
117
- this._firstInBucket = 0;
118
- this._bucketLast = 0;
119
- this._lastInBucket = 0;
120
- this._bucketCount = 0;
121
- this._buckets = [];
122
- this._length = 0;
123
- if (options) {
124
- const { bucketSize } = options;
125
- if (typeof bucketSize === 'number')
126
- this._bucketSize = bucketSize;
127
- }
128
- let _size;
129
- if ('length' in elements) {
130
- if (elements.length instanceof Function)
131
- _size = elements.length();
132
- else
133
- _size = elements.length;
134
- }
135
- else {
136
- if (elements.size instanceof Function)
137
- _size = elements.size();
138
- else
139
- _size = elements.size;
140
- }
141
- this._bucketCount = (0, utils_1.calcMinUnitsRequired)(_size, this._bucketSize) || 1;
142
- for (let i = 0; i < this._bucketCount; ++i) {
143
- this._buckets.push(new Array(this._bucketSize));
144
- }
145
- const needBucketNum = (0, utils_1.calcMinUnitsRequired)(_size, this._bucketSize);
146
- this._bucketFirst = this._bucketLast = (this._bucketCount >> 1) - (needBucketNum >> 1);
147
- this._firstInBucket = this._lastInBucket = (this._bucketSize - (_size % this._bucketSize)) >> 1;
148
- this.pushMany(elements);
149
- }
150
- get bucketSize() {
151
- return this._bucketSize;
152
- }
153
- get bucketFirst() {
154
- return this._bucketFirst;
155
- }
156
- get firstInBucket() {
157
- return this._firstInBucket;
158
- }
159
- get bucketLast() {
160
- return this._bucketLast;
161
- }
162
- get lastInBucket() {
163
- return this._lastInBucket;
164
- }
165
- get bucketCount() {
166
- return this._bucketCount;
167
- }
168
- get buckets() {
169
- return this._buckets;
170
- }
171
- get length() {
172
- return this._length;
173
- }
174
- /**
175
- * The function returns the first element in a collection if it exists, otherwise it returns
176
- * undefined.
177
- * @returns The first element of the collection, of type E, is being returned.
178
- */
179
- get first() {
180
- if (this._length === 0)
181
- return;
182
- return this._buckets[this._bucketFirst][this._firstInBucket];
183
- }
184
- /**
185
- * The last function returns the last element in the queue.
186
- * @return The last element in the array
187
- */
188
- get last() {
189
- if (this._length === 0)
190
- return;
191
- return this._buckets[this._bucketLast][this._lastInBucket];
192
- }
193
- /**
194
- * Time Complexity - Amortized O(1) (possible reallocation),
195
- * Space Complexity - O(n) (due to potential resizing).
196
- *
197
- * The push function adds an element to a data structure and reallocates memory if necessary.
198
- * @param {E} element - The `element` parameter represents the value that you want to add to the data
199
- * structure.
200
- * @returns The size of the data structure after the element has been pushed.
201
- */
202
- push(element) {
203
- if (this._length) {
204
- if (this._lastInBucket < this._bucketSize - 1) {
205
- this._lastInBucket += 1;
206
- }
207
- else if (this._bucketLast < this._bucketCount - 1) {
208
- this._bucketLast += 1;
209
- this._lastInBucket = 0;
210
- }
211
- else {
212
- this._bucketLast = 0;
213
- this._lastInBucket = 0;
214
- }
215
- if (this._bucketLast === this._bucketFirst && this._lastInBucket === this._firstInBucket)
216
- this._reallocate();
217
- }
218
- this._length += 1;
219
- this._buckets[this._bucketLast][this._lastInBucket] = element;
220
- if (this._maxLen > 0 && this._length > this._maxLen)
221
- this.shift();
222
- return true;
223
- }
224
- /**
225
- * Time Complexity: O(1)
226
- * Space Complexity: O(1)
227
- *
228
- * The `pop()` function removes and returns the last element from a data structure, updating the
229
- * internal state variables accordingly.
230
- * @returns The element that was removed from the data structure is being returned.
231
- */
232
- pop() {
233
- if (this._length === 0)
234
- return;
235
- const element = this._buckets[this._bucketLast][this._lastInBucket];
236
- if (this._length !== 1) {
237
- if (this._lastInBucket > 0) {
238
- this._lastInBucket -= 1;
239
- }
240
- else if (this._bucketLast > 0) {
241
- this._bucketLast -= 1;
242
- this._lastInBucket = this._bucketSize - 1;
243
- }
244
- else {
245
- this._bucketLast = this._bucketCount - 1;
246
- this._lastInBucket = this._bucketSize - 1;
247
- }
248
- }
249
- this._length -= 1;
250
- return element;
251
- }
252
- /**
253
- * Time Complexity: O(1)
254
- * Space Complexity: O(1)
255
- *
256
- * The `shift()` function removes and returns the first element from a data structure, updating the
257
- * internal state variables accordingly.
258
- * @returns The element that is being removed from the beginning of the data structure is being
259
- * returned.
260
- */
261
- shift() {
262
- if (this._length === 0)
263
- return;
264
- const element = this._buckets[this._bucketFirst][this._firstInBucket];
265
- if (this._length !== 1) {
266
- if (this._firstInBucket < this._bucketSize - 1) {
267
- this._firstInBucket += 1;
268
- }
269
- else if (this._bucketFirst < this._bucketCount - 1) {
270
- this._bucketFirst += 1;
271
- this._firstInBucket = 0;
272
- }
273
- else {
274
- this._bucketFirst = 0;
275
- this._firstInBucket = 0;
276
- }
277
- }
278
- this._length -= 1;
279
- return element;
280
- }
281
- /**
282
- * Time Complexity: Amortized O(1)
283
- * Space Complexity: O(n)
284
- *
285
- * The `unshift` function adds an element to the beginning of an array-like data structure and
286
- * returns the new size of the structure.
287
- * @param {E} element - The `element` parameter represents the element that you want to add to the
288
- * beginning of the data structure.
289
- * @returns The size of the data structure after the element has been added.
290
- */
291
- unshift(element) {
292
- if (this._length) {
293
- if (this._firstInBucket > 0) {
294
- this._firstInBucket -= 1;
295
- }
296
- else if (this._bucketFirst > 0) {
297
- this._bucketFirst -= 1;
298
- this._firstInBucket = this._bucketSize - 1;
299
- }
300
- else {
301
- this._bucketFirst = this._bucketCount - 1;
302
- this._firstInBucket = this._bucketSize - 1;
303
- }
304
- if (this._bucketFirst === this._bucketLast && this._firstInBucket === this._lastInBucket)
305
- this._reallocate();
306
- }
307
- this._length += 1;
308
- this._buckets[this._bucketFirst][this._firstInBucket] = element;
309
- if (this._maxLen > 0 && this._length > this._maxLen)
310
- this.pop();
311
- return true;
312
- }
313
- /**
314
- * Time Complexity: O(k)
315
- * Space Complexity: O(k)
316
- *
317
- * The function `pushMany` iterates over elements and pushes them into an array after applying a
318
- * transformation function if provided.
319
- * @param {IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R>} elements - The `elements`
320
- * parameter in the `pushMany` function is expected to be an iterable containing elements of type `E`
321
- * or `R`. It can be either an `IterableWithSizeOrLength<E>` or an `IterableWithSizeOrLength<R>`. The
322
- * function iterates over each element
323
- * @returns The `pushMany` function is returning an array of boolean values, where each value
324
- * represents the result of calling the `push` method on the current object instance with the
325
- * corresponding element from the input `elements` iterable.
326
- */
327
- pushMany(elements) {
328
- const ans = [];
329
- for (const el of elements) {
330
- if (this.toElementFn) {
331
- ans.push(this.push(this.toElementFn(el)));
332
- }
333
- else {
334
- ans.push(this.push(el));
335
- }
336
- }
337
- return ans;
338
- }
339
- /**
340
- * Time Complexity: O(k)
341
- * Space Complexity: O(k)
342
- *
343
- * The `unshiftMany` function in TypeScript iterates over elements and adds them to the beginning of
344
- * an array, optionally converting them using a provided function.
345
- * @param {IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R>} elements - The `elements`
346
- * parameter in the `unshiftMany` function is an iterable containing elements of type `E` or `R`. It
347
- * can be an array or any other iterable data structure that has a known size or length. The function
348
- * iterates over each element in the `elements` iterable and
349
- * @returns The `unshiftMany` function returns an array of boolean values indicating whether each
350
- * element was successfully added to the beginning of the array.
351
- */
352
- unshiftMany(elements = []) {
353
- const ans = [];
354
- for (const el of elements) {
355
- if (this.toElementFn) {
356
- ans.push(this.unshift(this.toElementFn(el)));
357
- }
358
- else {
359
- ans.push(this.unshift(el));
360
- }
361
- }
362
- return ans;
363
- }
364
- /**
365
- * Time Complexity: O(1)
366
- * Space Complexity: O(1)
367
- *
368
- * The function checks if the size of an object is equal to zero and returns a boolean value.
369
- * @returns A boolean value indicating whether the size of the object is 0 or not.
370
- */
371
- isEmpty() {
372
- return this._length === 0;
373
- }
374
- /**
375
- * Time Complexity: O(1)
376
- * Space Complexity: O(1)
377
- *
378
- * The clear() function resets the state of the object by initializing all variables to their default
379
- * values.
380
- */
381
- clear() {
382
- this._buckets = [new Array(this._bucketSize)];
383
- this._bucketCount = 1;
384
- this._bucketFirst = this._bucketLast = this._length = 0;
385
- this._firstInBucket = this._lastInBucket = this._bucketSize >> 1;
386
- }
387
- /**
388
- * Time Complexity: O(1)
389
- * Space Complexity: O(1)
390
- *
391
- * The `at` function retrieves an element at a specified position in an array-like data structure.
392
- * @param {number} pos - The `pos` parameter represents the position of the element that you want to
393
- * retrieve from the data structure. It is of type `number` and should be a valid index within the
394
- * range of the data structure.
395
- * @returns The element at the specified position in the data structure is being returned.
396
- */
397
- at(pos) {
398
- (0, utils_1.rangeCheck)(pos, 0, this._length - 1);
399
- const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
400
- return this._buckets[bucketIndex][indexInBucket];
401
- }
402
- /**
403
- * Time Complexity: O(1)
404
- * Space Complexity: O(1)
405
- *
406
- * The `setAt` function sets an element at a specific position in an array-like data structure.
407
- * @param {number} pos - The `pos` parameter represents the position at which the element needs to be
408
- * set. It is of type `number`.
409
- * @param {E} element - The `element` parameter is the value that you want to set at the specified
410
- * position in the data structure.
411
- */
412
- setAt(pos, element) {
413
- (0, utils_1.rangeCheck)(pos, 0, this._length - 1);
414
- const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
415
- this._buckets[bucketIndex][indexInBucket] = element;
416
- return true;
417
- }
418
- /**
419
- * Time Complexity: O(n)
420
- * Space Complexity: O(n)
421
- *
422
- * The `addAt` function inserts one or more elements at a specified position in an array-like data
423
- * structure.
424
- * @param {number} pos - The `pos` parameter represents the position at which the element(s) should
425
- * be inserted. It is of type `number`.
426
- * @param {E} element - The `element` parameter represents the element that you want to insert into
427
- * the array at the specified position.
428
- * @param [num=1] - The `num` parameter represents the number of times the `element` should be
429
- * inserted at the specified position (`pos`). By default, it is set to 1, meaning that the `element`
430
- * will be inserted once. However, you can provide a different value for `num` if you want
431
- * @returns The size of the array after the insertion is being returned.
432
- */
433
- addAt(pos, element, num = 1) {
434
- const length = this._length;
435
- (0, utils_1.rangeCheck)(pos, 0, length);
436
- if (pos === 0) {
437
- while (num--)
438
- this.unshift(element);
439
- }
440
- else if (pos === this._length) {
441
- while (num--)
442
- this.push(element);
443
- }
444
- else {
445
- const arr = [];
446
- for (let i = pos; i < this._length; ++i) {
447
- arr.push(this.at(i));
448
- }
449
- this.cut(pos - 1, true);
450
- for (let i = 0; i < num; ++i)
451
- this.push(element);
452
- for (let i = 0; i < arr.length; ++i)
453
- this.push(arr[i]);
454
- }
455
- return true;
456
- }
457
- /**
458
- * Time Complexity: O(1)
459
- * Space Complexity: O(1)
460
- *
461
- * The `cut` function updates the state of the object based on the given position and returns the
462
- * updated size.
463
- * @param {number} pos - The `pos` parameter represents the position at which the string should be
464
- * cut. It is a number that indicates the index of the character where the cut should be made.
465
- * @param {boolean} isCutSelf - If true, the original deque will not be cut, and return a new deque
466
- * @returns The method is returning the updated size of the data structure.
467
- */
468
- cut(pos, isCutSelf = false) {
469
- if (isCutSelf) {
470
- if (pos < 0) {
471
- this.clear();
472
- return this;
473
- }
474
- const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
475
- this._bucketLast = bucketIndex;
476
- this._lastInBucket = indexInBucket;
477
- this._length = pos + 1;
478
- return this;
479
- }
480
- else {
481
- const newDeque = this._createInstance({
482
- bucketSize: this._bucketSize,
483
- toElementFn: this._toElementFn,
484
- maxLen: this._maxLen
485
- });
486
- for (let i = 0; i <= pos; i++) {
487
- newDeque.push(this.at(i));
488
- }
489
- return newDeque;
490
- }
491
- }
492
- /**
493
- * Time Complexity: O(n)
494
- * Space Complexity: O(1)
495
- *
496
- * The `splice` function in TypeScript overrides the default behavior to remove and insert elements
497
- * in a Deque data structure while ensuring the starting position and delete count are within bounds.
498
- * @param {number} start - The `start` parameter in the `splice` method represents the index at which
499
- * to start changing the array. Items will be removed or added starting from this index.
500
- * @param {number} deleteCount - The `deleteCount` parameter in the `splice` method represents the
501
- * number of elements to remove from the array starting at the specified `start` index. If
502
- * `deleteCount` is not provided, it defaults to the number of elements from the `start` index to the
503
- * end of the array (`
504
- * @param {E[]} items - The `items` parameter in the `splice` method represents the elements that
505
- * will be inserted into the deque at the specified `start` index. These elements will be inserted in
506
- * place of the elements that are removed based on the `start` and `deleteCount` parameters.
507
- * @returns The `splice` method is returning the array `deletedElements` which contains the elements
508
- * that were removed from the Deque during the splice operation.
509
- */
510
- splice(start, deleteCount = this._length - start, ...items) {
511
- // Check whether the starting position is legal
512
- (0, utils_1.rangeCheck)(start, 0, this._length);
513
- // Adjust the value of deleteCount
514
- if (deleteCount < 0)
515
- deleteCount = 0;
516
- if (start + deleteCount > this._length)
517
- deleteCount = this._length - start;
518
- // Save deleted elements
519
- const deletedElements = this._createInstance();
520
- // Add removed elements to the result
521
- for (let i = 0; i < deleteCount; i++) {
522
- deletedElements.push(this.at(start + i));
523
- }
524
- // Calculate the range that needs to be deleted
525
- const elementsAfter = [];
526
- for (let i = start + deleteCount; i < this._length; i++) {
527
- elementsAfter.push(this.at(i));
528
- }
529
- // Adjust the length of the current Deque
530
- this.cut(start - 1, true);
531
- for (const item of items) {
532
- this.push(item);
533
- }
534
- // Insert subsequent elements back
535
- for (const element of elementsAfter) {
536
- this.push(element);
537
- }
538
- return deletedElements;
539
- }
540
- /**
541
- * Time Complexity: O(1)
542
- * Space Complexity: O(1) or O(n)
543
- *
544
- * The `cutRest` function cuts the elements from a specified position in a deque and returns a new
545
- * deque with the cut elements.
546
- * @param {number} pos - The `pos` parameter represents the position from which to cut the Deque. It
547
- * is a number that indicates the index of the element in the Deque where the cut should start.
548
- * @param [isCutSelf=false] - isCutSelf is a boolean parameter that determines whether the original
549
- * Deque should be modified or a new Deque should be created. If isCutSelf is true, the original
550
- * Deque will be modified by cutting off elements starting from the specified position. If isCutSelf
551
- * is false, a new De
552
- * @returns The function `cutRest` returns either the modified original deque (`this`) or a new deque
553
- * (`newDeque`) depending on the value of the `isCutSelf` parameter.
554
- */
555
- cutRest(pos, isCutSelf = false) {
556
- if (isCutSelf) {
557
- if (pos < 0) {
558
- return this;
559
- }
560
- const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
561
- this._bucketFirst = bucketIndex;
562
- this._firstInBucket = indexInBucket;
563
- this._length = this._length - pos;
564
- return this;
565
- }
566
- else {
567
- const newDeque = this._createInstance({
568
- bucketSize: this._bucketSize,
569
- toElementFn: this._toElementFn,
570
- maxLen: this._maxLen
571
- });
572
- if (pos < 0)
573
- pos = 0;
574
- for (let i = pos; i < this._length; i++) {
575
- newDeque.push(this.at(i));
576
- }
577
- return newDeque;
578
- }
579
- }
580
- /**
581
- * Time Complexity: O(n)
582
- * Space Complexity: O(1) or O(n)
583
- *
584
- * The `deleteAt` function removes an element at a specified position in an array-like data
585
- * structure.
586
- * @param {number} pos - The `pos` parameter in the `deleteAt` function represents the position at
587
- * which an element needs to be deleted from the data structure. It is of type `number` and indicates
588
- * the index of the element to be deleted.
589
- * @returns The size of the data structure after the deletion operation is performed.
590
- */
591
- deleteAt(pos) {
592
- (0, utils_1.rangeCheck)(pos, 0, this._length - 1);
593
- let deleted;
594
- if (pos === 0) {
595
- //If it is the first element, use shift() directly
596
- return this.shift();
597
- }
598
- else if (pos === this._length - 1) {
599
- // If it is the last element, just use pop()
600
- deleted = this.last;
601
- this.pop();
602
- return deleted;
603
- }
604
- else {
605
- // Delete the middle element
606
- const length = this._length - 1;
607
- const { bucketIndex: targetBucket, indexInBucket: targetPointer } = this._getBucketAndPosition(pos);
608
- deleted = this._buckets[targetBucket][targetPointer];
609
- for (let i = pos; i < length; i++) {
610
- const { bucketIndex: curBucket, indexInBucket: curPointer } = this._getBucketAndPosition(i);
611
- const { bucketIndex: nextBucket, indexInBucket: nextPointer } = this._getBucketAndPosition(i + 1);
612
- this._buckets[curBucket][curPointer] = this._buckets[nextBucket][nextPointer];
613
- }
614
- // Remove last duplicate element
615
- this.pop();
616
- return deleted;
617
- }
618
- }
619
- /**
620
- * Time Complexity: O(n)
621
- * Space Complexity: O(1)
622
- *
623
- * The `delete` function removes all occurrences of a specified element from an array-like data
624
- * structure.
625
- * @param {E} element - The `element` parameter represents the element that you want to delete from
626
- * the data structure.
627
- * @returns The size of the data structure after the element has been deleted.
628
- */
629
- delete(element) {
630
- const size = this._length;
631
- if (size === 0)
632
- return false;
633
- let i = 0;
634
- let index = 0;
635
- while (i < size) {
636
- const oldElement = this.at(i);
637
- if (oldElement !== element) {
638
- this.setAt(index, oldElement);
639
- index += 1;
640
- }
641
- i += 1;
642
- }
643
- this.cut(index - 1, true);
644
- return true;
645
- }
646
- // /**
647
- // * Time Complexity: O(n)
648
- // * Space Complexity: O(1)
649
- // *
650
- // * This function overrides the indexOf method to search for an element within a custom data
651
- // * structure.
652
- // * @param {E} searchElement - The `searchElement` parameter is the element that you are searching for
653
- // * within the data structure. The `indexOf` method will return the index of the first occurrence of
654
- // * this element within the data structure.
655
- // * @param {number} [fromIndex=0] - The `fromIndex` parameter in the `indexOf` method specifies the
656
- // * index at which to start searching for the `searchElement` within the data structure. If provided,
657
- // * the search will begin at this index instead of the beginning of the data structure.
658
- // * @returns The indexOf method is returning the index of the searchElement if it is found in the data
659
- // * structure, or -1 if the searchElement is not found.
660
- // */
661
- // override indexOf(searchElement: E, fromIndex: number = 0): number {
662
- // let index = fromIndex;
663
- // let bucketIndex = this._bucketFirst;
664
- // let indexInBucket = this._firstInBucket + fromIndex;
665
- //
666
- // for (let i = 0; i < this._length; i++) {
667
- // if (this._buckets[bucketIndex][indexInBucket] === searchElement) {
668
- // return index;
669
- // }
670
- // index++;
671
- // indexInBucket++;
672
- // if (indexInBucket >= this._bucketSize) {
673
- // bucketIndex++;
674
- // indexInBucket = 0;
675
- // }
676
- // if (bucketIndex >= this._bucketCount) {
677
- // bucketIndex = 0;
678
- // }
679
- // }
680
- // return -1;
681
- // }
682
- /**
683
- * Time Complexity: O(n)
684
- * Space Complexity: O(1)
685
- *
686
- * The reverse() function reverses the order of the buckets and the elements within each bucket in a
687
- * data structure.
688
- * @returns The reverse() method is returning the object itself (this) after performing the reverse
689
- * operation on the buckets and updating the relevant properties.
690
- */
691
- reverse() {
692
- this._buckets.reverse().forEach(function (bucket) {
693
- bucket.reverse();
694
- });
695
- const { _bucketFirst, _bucketLast, _firstInBucket, _lastInBucket } = this;
696
- this._bucketFirst = this._bucketCount - _bucketLast - 1;
697
- this._bucketLast = this._bucketCount - _bucketFirst - 1;
698
- this._firstInBucket = this._bucketSize - _lastInBucket - 1;
699
- this._lastInBucket = this._bucketSize - _firstInBucket - 1;
700
- return this;
701
- }
702
- /**
703
- * Time Complexity: O(n)
704
- * Space Complexity: O(1)
705
- *
706
- * The `unique()` function removes duplicate elements from an array-like data structure and returns
707
- * the number of unique elements.
708
- * @returns The size of the modified array is being returned.
709
- */
710
- unique() {
711
- if (this._length <= 1) {
712
- return this;
713
- }
714
- let index = 1;
715
- let prev = this.at(0);
716
- for (let i = 1; i < this._length; ++i) {
717
- const cur = this.at(i);
718
- if (cur !== prev) {
719
- prev = cur;
720
- this.setAt(index++, cur);
721
- }
722
- }
723
- this.cut(index - 1, true);
724
- return this;
725
- }
726
- /**
727
- * Time Complexity: O(n)
728
- * Space Complexity: O(n)
729
- *
730
- * The `shrinkToFit` function reorganizes the elements in an array-like data structure to minimize
731
- * memory usage.
732
- * @returns Nothing is being returned. The function is using the `return` statement to exit early if
733
- * `this._length` is 0, but it does not return any value.
734
- */
735
- shrinkToFit() {
736
- if (this._length === 0)
737
- return;
738
- const newBuckets = [];
739
- if (this._bucketFirst === this._bucketLast)
740
- return;
741
- else if (this._bucketFirst < this._bucketLast) {
742
- for (let i = this._bucketFirst; i <= this._bucketLast; ++i) {
743
- newBuckets.push(this._buckets[i]);
744
- }
745
- }
746
- else {
747
- for (let i = this._bucketFirst; i < this._bucketCount; ++i) {
748
- newBuckets.push(this._buckets[i]);
749
- }
750
- for (let i = 0; i <= this._bucketLast; ++i) {
751
- newBuckets.push(this._buckets[i]);
752
- }
753
- }
754
- this._bucketFirst = 0;
755
- this._bucketLast = newBuckets.length - 1;
756
- this._buckets = newBuckets;
757
- }
758
- /**
759
- * Time Complexity: O(n)
760
- * Space Complexity: O(n)
761
- *
762
- * The `clone()` function returns a new instance of the `Deque` class with the same elements and
763
- * bucket size as the original instance.
764
- * @returns The `clone()` method is returning a new instance of the `Deque` class with the same
765
- * elements as the original deque (`this`) and the same bucket size.
766
- */
767
- clone() {
768
- return new Deque(this, {
769
- bucketSize: this.bucketSize,
770
- toElementFn: this.toElementFn,
771
- maxLen: this._maxLen
772
- });
773
- }
774
- /**
775
- * Time Complexity: O(n)
776
- * Space Complexity: O(n)
777
- *
778
- * The `filter` function creates a new deque containing elements from the original deque that satisfy
779
- * a given predicate function.
780
- * @param predicate - The `predicate` parameter is a callback function that takes three arguments:
781
- * the current element being iterated over, the index of the current element, and the deque itself.
782
- * It should return a boolean value indicating whether the element should be included in the filtered
783
- * deque or not.
784
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
785
- * to be used as `this` when executing the `predicate` function. If `thisArg` is provided, it will be
786
- * passed as the `this` value to the `predicate` function. If `thisArg` is
787
- * @returns The `filter` method is returning a new `Deque` object that contains the elements that
788
- * satisfy the given predicate function.
789
- */
790
- filter(predicate, thisArg) {
791
- const newDeque = this._createInstance({
792
- bucketSize: this._bucketSize,
793
- toElementFn: this.toElementFn,
794
- maxLen: this._maxLen
795
- });
796
- let index = 0;
797
- for (const el of this) {
798
- if (predicate.call(thisArg, el, index, this)) {
799
- newDeque.push(el);
800
- }
801
- index++;
802
- }
803
- return newDeque;
804
- }
805
- /**
806
- * Time Complexity: O(n)
807
- * Space Complexity: O(n)
808
- *
809
- * The `map` function takes a callback function and applies it to each element in the deque,
810
- * returning a new deque with the results.
811
- * @param callback - The callback parameter is a function that will be called for each element in the
812
- * deque. It takes three arguments: the current element, the index of the element, and the deque
813
- * itself. It should return a value of type EM.
814
- * @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
815
- * transform the raw element (`RM`) into a new element (`EM`) before adding it to the new deque. If
816
- * provided, this function will be called for each raw element in the original deque.
817
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
818
- * specify the value of `this` within the callback function. It is used to set the context or scope
819
- * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
820
- * value of
821
- * @returns a new Deque object with elements of type EM and raw elements of type RM.
822
- */
823
- map(callback, toElementFn, thisArg) {
824
- const newDeque = new Deque([], { bucketSize: this._bucketSize, toElementFn, maxLen: this._maxLen });
825
- let index = 0;
826
- for (const el of this) {
827
- newDeque.push(callback.call(thisArg, el, index, this));
828
- index++;
829
- }
830
- return newDeque;
831
- }
832
- /**
833
- * Time Complexity: O(n)
834
- * Space Complexity: O(1)
835
- *
836
- * The above function is an implementation of the iterator protocol in TypeScript, allowing the
837
- * object to be iterated over using a for...of loop.
838
- */
839
- *_getIterator() {
840
- for (let i = 0; i < this._length; ++i) {
841
- yield this.at(i);
842
- }
843
- }
844
- /**
845
- * Time Complexity: O(n)
846
- * Space Complexity: O(n)
847
- *
848
- * The `_reallocate` function reallocates the buckets in an array, adding new buckets if needed.
849
- * @param {number} [needBucketNum] - The `needBucketNum` parameter is an optional number that
850
- * specifies the number of new buckets needed. If not provided, it will default to half of the
851
- * current bucket count (`this._bucketCount >> 1`) or 1 if the current bucket count is less than 2.
852
- */
853
- _reallocate(needBucketNum) {
854
- const newBuckets = [];
855
- const addBucketNum = needBucketNum || this._bucketCount >> 1 || 1;
856
- for (let i = 0; i < addBucketNum; ++i) {
857
- newBuckets[i] = new Array(this._bucketSize);
858
- }
859
- for (let i = this._bucketFirst; i < this._bucketCount; ++i) {
860
- newBuckets[newBuckets.length] = this._buckets[i];
861
- }
862
- for (let i = 0; i < this._bucketLast; ++i) {
863
- newBuckets[newBuckets.length] = this._buckets[i];
864
- }
865
- newBuckets[newBuckets.length] = [...this._buckets[this._bucketLast]];
866
- this._bucketFirst = addBucketNum;
867
- this._bucketLast = newBuckets.length - 1;
868
- for (let i = 0; i < addBucketNum; ++i) {
869
- newBuckets[newBuckets.length] = new Array(this._bucketSize);
870
- }
871
- this._buckets = newBuckets;
872
- this._bucketCount = newBuckets.length;
873
- }
874
- /**
875
- * Time Complexity: O(1)
876
- * Space Complexity: O(1)
877
- *
878
- * The function calculates the bucket index and index within the bucket based on the given position.
879
- * @param {number} pos - The `pos` parameter represents the position within the data structure. It is
880
- * a number that indicates the index or position of an element within the structure.
881
- * @returns an object with two properties: "bucketIndex" and "indexInBucket".
882
- */
883
- _getBucketAndPosition(pos) {
884
- let bucketIndex;
885
- let indexInBucket;
886
- const overallIndex = this._firstInBucket + pos;
887
- bucketIndex = this._bucketFirst + Math.floor(overallIndex / this._bucketSize);
888
- if (bucketIndex >= this._bucketCount) {
889
- bucketIndex -= this._bucketCount;
890
- }
891
- indexInBucket = ((overallIndex + 1) % this._bucketSize) - 1;
892
- if (indexInBucket < 0) {
893
- indexInBucket = this._bucketSize - 1;
894
- }
895
- return { bucketIndex, indexInBucket };
896
- }
897
- /**
898
- * The function `_createInstance` returns a new instance of the `Deque` class with the specified
899
- * options.
900
- * @param [options] - The `options` parameter in the `_createInstance` method is of type
901
- * `DequeOptions<E, R>`, which is an optional parameter that allows you to pass additional
902
- * configuration options when creating a new instance of the `Deque` class.
903
- * @returns An instance of the `Deque` class with an empty array and the provided options, casted as
904
- * `this`.
905
- */
906
- _createInstance(options) {
907
- return new Deque([], options);
908
- }
909
- /**
910
- * This function returns an iterator that iterates over elements in reverse order.
911
- */
912
- *_getReverseIterator() {
913
- for (let i = this._length - 1; i > -1; i--) {
914
- yield this.at(i);
915
- }
916
- }
917
- }
918
- exports.Deque = Deque;
919
- //# sourceMappingURL=deque.js.map