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,870 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SinglyLinkedList = exports.SinglyLinkedListNode = void 0;
4
- const linear_base_1 = require("../base/linear-base");
5
- class SinglyLinkedListNode extends linear_base_1.LinkedListNode {
6
- /**
7
- * The constructor function initializes an instance of a class with a given value and sets the next property to undefined.
8
- * @param {E} value - The "value" parameter is of type E, which means it can be any data type. It represents the value that
9
- * will be stored in the node of a linked list.
10
- */
11
- constructor(value) {
12
- super(value);
13
- this._value = value;
14
- this._next = undefined;
15
- }
16
- get next() {
17
- return this._next;
18
- }
19
- set next(value) {
20
- this._next = value;
21
- }
22
- }
23
- exports.SinglyLinkedListNode = SinglyLinkedListNode;
24
- /**
25
- * 1. Node Structure: Each node contains three parts: a data field, a pointer (or reference) to the previous node, and a pointer to the next node. This structure allows traversal of the linked list in both directions.
26
- * 2. Bidirectional Traversal: Unlike doubly linked lists, singly linked lists can be easily traversed forwards but not backwards.
27
- * 3. No Centralized Index: Unlike arrays, elements in a linked list are not stored contiguously, so there is no centralized index. Accessing elements in a linked list typically requires traversing from the head or tail node.
28
- * 4. High Efficiency in Insertion and Deletion: Adding or removing elements in a linked list does not require moving other elements, making these operations more efficient than in arrays.
29
- * Caution: Although our linked list classes provide methods such as at, setAt, addAt, and indexOf that are based on array indices, their time complexity, like that of the native Array.lastIndexOf, is 𝑂(𝑛). If you need to use these methods frequently, you might want to consider other data structures, such as Deque or Queue (designed for random access). Similarly, since the native Array.shift method has a time complexity of 𝑂(𝑛), using an array to simulate a queue can be inefficient. In such cases, you should use Queue or Deque, as these data structures leverage deferred array rearrangement, effectively reducing the average time complexity to 𝑂(1).
30
- *
31
- * @example
32
- * // implementation of a basic text editor
33
- * class TextEditor {
34
- * private content: SinglyLinkedList<string>;
35
- * private cursorIndex: number;
36
- * private undoStack: Stack<{ operation: string; data?: any }>;
37
- *
38
- * constructor() {
39
- * this.content = new SinglyLinkedList<string>();
40
- * this.cursorIndex = 0; // Cursor starts at the beginning
41
- * this.undoStack = new Stack<{ operation: string; data?: any }>(); // Stack to keep track of operations for undo
42
- * }
43
- *
44
- * insert(char: string) {
45
- * this.content.addAt(this.cursorIndex, char);
46
- * this.cursorIndex++;
47
- * this.undoStack.push({ operation: 'insert', data: { index: this.cursorIndex - 1 } });
48
- * }
49
- *
50
- * delete() {
51
- * if (this.cursorIndex === 0) return; // Nothing to delete
52
- * const deleted = this.content.deleteAt(this.cursorIndex - 1);
53
- * this.cursorIndex--;
54
- * this.undoStack.push({ operation: 'delete', data: { index: this.cursorIndex, char: deleted } });
55
- * }
56
- *
57
- * moveCursor(index: number) {
58
- * this.cursorIndex = Math.max(0, Math.min(index, this.content.length));
59
- * }
60
- *
61
- * undo() {
62
- * if (this.undoStack.size === 0) return; // No operations to undo
63
- * const lastAction = this.undoStack.pop();
64
- *
65
- * if (lastAction!.operation === 'insert') {
66
- * this.content.deleteAt(lastAction!.data.index);
67
- * this.cursorIndex = lastAction!.data.index;
68
- * } else if (lastAction!.operation === 'delete') {
69
- * this.content.addAt(lastAction!.data.index, lastAction!.data.char);
70
- * this.cursorIndex = lastAction!.data.index + 1;
71
- * }
72
- * }
73
- *
74
- * getText(): string {
75
- * return [...this.content].join('');
76
- * }
77
- * }
78
- *
79
- * // Example Usage
80
- * const editor = new TextEditor();
81
- * editor.insert('H');
82
- * editor.insert('e');
83
- * editor.insert('l');
84
- * editor.insert('l');
85
- * editor.insert('o');
86
- * console.log(editor.getText()); // 'Hello' // Output: "Hello"
87
- *
88
- * editor.delete();
89
- * console.log(editor.getText()); // 'Hell' // Output: "Hell"
90
- *
91
- * editor.undo();
92
- * console.log(editor.getText()); // 'Hello' // Output: "Hello"
93
- *
94
- * editor.moveCursor(1);
95
- * editor.insert('a');
96
- * console.log(editor.getText()); // 'Haello'
97
- */
98
- class SinglyLinkedList extends linear_base_1.LinearLinkedBase {
99
- constructor(elements = [], options) {
100
- super(options);
101
- this._length = 0;
102
- if (options) {
103
- }
104
- this.pushMany(elements);
105
- }
106
- get head() {
107
- return this._head;
108
- }
109
- get tail() {
110
- return this._tail;
111
- }
112
- get first() {
113
- var _a;
114
- return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
115
- }
116
- get last() {
117
- var _a;
118
- return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.value;
119
- }
120
- get length() {
121
- return this._length;
122
- }
123
- /**
124
- * Time Complexity: O(n)
125
- * Space Complexity: O(n)
126
- *
127
- * The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
128
- * array.
129
- * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
130
- * @returns The `fromArray` function returns a `SinglyLinkedList` object.
131
- */
132
- static fromArray(data) {
133
- const singlyLinkedList = new SinglyLinkedList();
134
- for (const item of data) {
135
- singlyLinkedList.push(item);
136
- }
137
- return singlyLinkedList;
138
- }
139
- /**
140
- * Time Complexity: O(1)
141
- * Space Complexity: O(1)
142
- *
143
- * The `push` function adds a new element or node to the end of a singly linked list.
144
- * @param {E | SinglyLinkedListNode<E>} elementOrNode - The `elementOrNode` parameter in the `push`
145
- * method can accept either an element of type `E` or a `SinglyLinkedListNode<E>` object.
146
- * @returns The `push` method is returning a boolean value, specifically `true`.
147
- */
148
- push(elementOrNode) {
149
- const newNode = this._ensureNode(elementOrNode);
150
- if (!this.head) {
151
- this._head = newNode;
152
- this._tail = newNode;
153
- }
154
- else {
155
- this.tail.next = newNode;
156
- this._tail = newNode;
157
- }
158
- this._length++;
159
- if (this._maxLen > 0 && this.length > this._maxLen)
160
- this.shift();
161
- return true;
162
- }
163
- /**
164
- * Time Complexity: O(n)
165
- * Space Complexity: O(1)
166
- *
167
- * The `pop` function removes and returns the value of the last element in a linked list.
168
- * @returns The method is returning the value of the element that is being popped from the end of the
169
- * list.
170
- */
171
- pop() {
172
- if (!this.head)
173
- return undefined;
174
- if (this.head === this.tail) {
175
- const value = this.head.value;
176
- this._head = undefined;
177
- this._tail = undefined;
178
- this._length--;
179
- return value;
180
- }
181
- let current = this.head;
182
- while (current.next !== this.tail) {
183
- current = current.next;
184
- }
185
- const value = this.tail.value;
186
- current.next = undefined;
187
- this._tail = current;
188
- this._length--;
189
- return value;
190
- }
191
- /**
192
- * Time Complexity: O(1)
193
- * Space Complexity: O(1)
194
- *
195
- * The `shift()` function removes and returns the value of the first element in a linked list.
196
- * @returns The value of the removed node.
197
- */
198
- shift() {
199
- if (!this.head)
200
- return undefined;
201
- const removedNode = this.head;
202
- this._head = this.head.next;
203
- this._length--;
204
- return removedNode.value;
205
- }
206
- /**
207
- * Time Complexity: O(1)
208
- * Space Complexity: O(1)
209
- *
210
- * The unshift function adds a new element or node to the beginning of a singly linked list in
211
- * TypeScript.
212
- * @param {E | SinglyLinkedListNode<E>} elementOrNode - The `elementOrNode` parameter in the
213
- * `unshift` method can be either an element of type `E` or a `SinglyLinkedListNode` containing an
214
- * element of type `E`.
215
- * @returns The `unshift` method is returning a boolean value, specifically `true`.
216
- */
217
- unshift(elementOrNode) {
218
- const newNode = this._ensureNode(elementOrNode);
219
- if (!this.head) {
220
- this._head = newNode;
221
- this._tail = newNode;
222
- }
223
- else {
224
- newNode.next = this.head;
225
- this._head = newNode;
226
- }
227
- this._length++;
228
- return true;
229
- }
230
- /**
231
- * Time Complexity: O(k)
232
- * Space Complexity: O(k)
233
- *
234
- * The function `pushMany` iterates over elements and pushes them into a data structure, applying a
235
- * transformation function if provided.
236
- * @param {Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>} elements - The `elements`
237
- * parameter in the `pushMany` function can accept an iterable containing elements of type `E`, `R`,
238
- * or `SinglyLinkedListNode<E>`.
239
- * @returns The `pushMany` function returns an array of boolean values indicating whether each
240
- * element was successfully pushed into the data structure.
241
- */
242
- pushMany(elements) {
243
- const ans = [];
244
- for (const el of elements) {
245
- if (this.toElementFn) {
246
- ans.push(this.push(this.toElementFn(el)));
247
- continue;
248
- }
249
- ans.push(this.push(el));
250
- }
251
- return ans;
252
- }
253
- /**
254
- * Time Complexity: O(k)
255
- * Space Complexity: O(k)
256
- *
257
- * The function `unshiftMany` iterates over elements and adds them to a data structure, optionally
258
- * converting them using a provided function.
259
- * @param {Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>} elements - The `elements`
260
- * parameter in the `unshiftMany` function can accept an iterable containing elements of type `E`,
261
- * `R`, or `SinglyLinkedListNode<E>`. The function iterates over each element in the iterable and
262
- * performs an `unshift` operation on the linked list for each
263
- * @returns The `unshiftMany` function is returning an array of boolean values, where each value
264
- * represents the result of calling the `unshift` method on the current instance of the class.
265
- */
266
- unshiftMany(elements) {
267
- const ans = [];
268
- for (const el of elements) {
269
- if (this.toElementFn) {
270
- ans.push(this.unshift(this.toElementFn(el)));
271
- continue;
272
- }
273
- ans.push(this.unshift(el));
274
- }
275
- return ans;
276
- }
277
- /**
278
- * Time Complexity: O(n)
279
- * Space Complexity: O(1)
280
- *
281
- * This function searches for a specific element in a singly linked list based on a given node or
282
- * predicate.
283
- * @param {E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)} elementNodeOrPredicate
284
- * elementNodeOrPredicate - The `elementNodeOrPredicate` parameter in the `get` method can be one of
285
- * the following types:
286
- * @returns The `get` method returns the value of the first node in the singly linked list that
287
- * satisfies the provided predicate function. If no such node is found, it returns `undefined`.
288
- */
289
- search(elementNodeOrPredicate) {
290
- const predicate = this._ensurePredicate(elementNodeOrPredicate);
291
- let current = this.head;
292
- while (current) {
293
- if (predicate(current))
294
- return current.value;
295
- current = current.next;
296
- }
297
- return undefined;
298
- }
299
- /**
300
- * Time Complexity: O(n)
301
- * Space Complexity: O(1)
302
- *
303
- * The function `at` returns the value at a specified index in a linked list, or undefined if the index is out of range.
304
- * @param {number} index - The index parameter is a number that represents the position of the element we want to
305
- * retrieve from the list.
306
- * @returns The method `at(index: number): E | undefined` returns the value at the specified index in the linked list, or
307
- * `undefined` if the index is out of bounds.
308
- */
309
- at(index) {
310
- if (index < 0 || index >= this._length)
311
- return undefined;
312
- let current = this.head;
313
- for (let i = 0; i < index; i++) {
314
- current = current.next;
315
- }
316
- return current.value;
317
- }
318
- /**
319
- * Time Complexity: O(1)
320
- * Space Complexity: O(1)
321
- *
322
- * The function `isNode` in TypeScript checks if the input is an instance of `SinglyLinkedListNode`.
323
- * @param {E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)} elementNodeOrPredicate
324
- * elementNodeOrPredicate - The `elementNodeOrPredicate` parameter in the `isNode` function can be
325
- * one of the following types:
326
- * @returns The `isNode` function is checking if the `elementNodeOrPredicate` parameter is an
327
- * instance of `SinglyLinkedListNode<E>`. If it is, the function returns `true`, indicating that the
328
- * parameter is a `SinglyLinkedListNode<E>`. If it is not an instance of `SinglyLinkedListNode<E>`,
329
- * the function returns `false`.
330
- */
331
- isNode(elementNodeOrPredicate) {
332
- return elementNodeOrPredicate instanceof SinglyLinkedListNode;
333
- }
334
- /**
335
- * Time Complexity: O(n)
336
- * Space Complexity: O(1)
337
- *
338
- * The function `getNodeAt` returns the node at a given index in a singly linked list.
339
- * @param {number} index - The `index` parameter is a number that represents the position of the node we want to
340
- * retrieve from the linked list. It indicates the zero-based index of the node we want to access.
341
- * @returns The method `getNodeAt(index: number)` returns a `SinglyLinkedListNode<E>` object if the node at the
342
- * specified index exists, or `undefined` if the index is out of bounds.
343
- */
344
- getNodeAt(index) {
345
- let current = this.head;
346
- for (let i = 0; i < index; i++) {
347
- current = current.next;
348
- }
349
- return current;
350
- }
351
- /**
352
- * Time Complexity: O(n)
353
- * Space Complexity: O(1)
354
- *
355
- * The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
356
- * @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
357
- * data structure. It is of type number.
358
- * @returns The method `deleteAt` returns the value of the node that was deleted, or `undefined` if the index is out of
359
- * bounds.
360
- */
361
- deleteAt(index) {
362
- if (index < 0 || index >= this._length)
363
- return;
364
- let deleted;
365
- if (index === 0) {
366
- deleted = this.first;
367
- this.shift();
368
- return deleted;
369
- }
370
- const targetNode = this.getNodeAt(index);
371
- const prevNode = this._getPrevNode(targetNode);
372
- if (prevNode && targetNode) {
373
- deleted = targetNode.value;
374
- prevNode.next = targetNode.next;
375
- if (targetNode === this.tail)
376
- this._tail = prevNode;
377
- this._length--;
378
- return deleted;
379
- }
380
- return;
381
- }
382
- /**
383
- * Time Complexity: O(n)
384
- * Space Complexity: O(1)
385
- *
386
- * The delete function removes a node with a specific value from a singly linked list.
387
- * @param {E | SinglyLinkedListNode<E>} elementOrNode - The `elementOrNode` parameter can accept either a value of type `E`
388
- * or a `SinglyLinkedListNode<E>` object.
389
- * @returns The `delete` method returns a boolean value. It returns `true` if the value or node is found and
390
- * successfully deleted from the linked list, and `false` if the value or node is not found in the linked list.
391
- */
392
- delete(elementOrNode) {
393
- if (elementOrNode === undefined || !this.head)
394
- return false;
395
- const node = this.isNode(elementOrNode) ? elementOrNode : this.getNode(elementOrNode);
396
- if (!node)
397
- return false;
398
- const prevNode = this._getPrevNode(node);
399
- if (!prevNode) {
400
- // The node is the head
401
- this._head = node.next;
402
- if (node === this.tail)
403
- this._tail = undefined;
404
- }
405
- else {
406
- prevNode.next = node.next;
407
- if (node === this.tail)
408
- this._tail = prevNode;
409
- }
410
- this._length--;
411
- return true;
412
- }
413
- /**
414
- * Time Complexity: O(n)
415
- * Space Complexity: O(1)
416
- *
417
- * The `addAt` function inserts a new element or node at a specified index in a singly linked list.
418
- * @param {number} index - The `index` parameter represents the position at which you want to add a
419
- * new element or node in the linked list. It is a number that indicates the index where the new
420
- * element or node should be inserted.
421
- * @param {E | SinglyLinkedListNode<E>} newElementOrNode - The `newElementOrNode` parameter in the
422
- * `addAt` method can be either a value of type `E` or a `SinglyLinkedListNode<E>` object. This
423
- * parameter represents the element or node that you want to add to the linked list at the specified
424
- * index.
425
- * @returns The `addAt` method returns a boolean value - `true` if the element or node was
426
- * successfully added at the specified index, and `false` if the index is out of bounds.
427
- */
428
- addAt(index, newElementOrNode) {
429
- if (index < 0 || index > this._length)
430
- return false;
431
- if (index === 0) {
432
- this.unshift(newElementOrNode);
433
- return true;
434
- }
435
- if (index === this._length) {
436
- this.push(newElementOrNode);
437
- return true;
438
- }
439
- const newNode = this._ensureNode(newElementOrNode);
440
- const prevNode = this.getNodeAt(index - 1);
441
- newNode.next = prevNode.next;
442
- prevNode.next = newNode;
443
- this._length++;
444
- return true;
445
- }
446
- /**
447
- * Time Complexity: O(n)
448
- * Space Complexity: O(1)
449
- *
450
- * The function setAt(index, value) updates the value at a specified index in a data structure if the
451
- * index exists.
452
- * @param {number} index - The `index` parameter in the `setAt` method refers to the position in the
453
- * data structure where you want to set a new value.
454
- * @param {E} value - The `value` parameter in the `setAt` method represents the new value that you
455
- * want to set at the specified index in the data structure.
456
- * @returns The `setAt` method returns a boolean value - `true` if the value at the specified index
457
- * is successfully updated, and `false` if the index is out of bounds (i.e., the node at that index
458
- * does not exist).
459
- */
460
- setAt(index, value) {
461
- const node = this.getNodeAt(index);
462
- if (node) {
463
- node.value = value;
464
- return true;
465
- }
466
- return false;
467
- }
468
- /**
469
- * Time Complexity: O(1)
470
- * Space Complexity: O(1)
471
- *
472
- * The function checks if the length of a data structure is equal to zero and returns a boolean value indicating
473
- * whether it is empty or not.
474
- * @returns A boolean value indicating whether the length of the object is equal to 0.
475
- */
476
- isEmpty() {
477
- return this._length === 0;
478
- }
479
- /**
480
- * Time Complexity: O(1)
481
- * Space Complexity: O(1)
482
- *
483
- * The `clear` function resets the linked list by setting the head, tail, and length to undefined and 0 respectively.
484
- */
485
- clear() {
486
- this._head = undefined;
487
- this._tail = undefined;
488
- this._length = 0;
489
- }
490
- /**
491
- * Time Complexity: O(n)
492
- * Space Complexity: O(1)
493
- *
494
- * The `reverse` function reverses the order of the nodes in a singly linked list.
495
- * @returns The reverse() method does not return anything. It has a return type of void.
496
- */
497
- reverse() {
498
- if (!this.head || this.head === this.tail)
499
- return this;
500
- let prev = undefined;
501
- let current = this.head;
502
- let next = undefined;
503
- while (current) {
504
- next = current.next;
505
- current.next = prev;
506
- prev = current;
507
- current = next;
508
- }
509
- [this._head, this._tail] = [this.tail, this.head];
510
- return this;
511
- }
512
- /**
513
- * Time Complexity: O(n)
514
- * Space Complexity: O(1)
515
- *
516
- * The function `getNode` in TypeScript searches for a node in a singly linked list based on a given
517
- * element, node, or predicate.
518
- * @param {E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean) | undefined} elementNodeOrPredicate
519
- * elementNodeOrPredicate - The `elementNodeOrPredicate` parameter in the `getNode` method can be one
520
- * of the following types:
521
- * @returns The `getNode` method returns either a `SinglyLinkedListNode<E>` if a matching node is
522
- * found based on the provided predicate, or it returns `undefined` if no matching node is found or
523
- * if the input parameter is `undefined`.
524
- */
525
- getNode(elementNodeOrPredicate) {
526
- if (elementNodeOrPredicate === undefined)
527
- return;
528
- if (this.isNode(elementNodeOrPredicate))
529
- return elementNodeOrPredicate;
530
- const predicate = this._ensurePredicate(elementNodeOrPredicate);
531
- let current = this.head;
532
- while (current) {
533
- if (predicate(current)) {
534
- return current;
535
- }
536
- current = current.next;
537
- }
538
- return undefined;
539
- }
540
- /**
541
- * Time Complexity: O(n)
542
- * Space Complexity: O(1)
543
- *
544
- * The function `addBefore` in TypeScript adds a new element or node before an existing element or
545
- * node in a singly linked list.
546
- * @param {E | SinglyLinkedListNode<E>} existingElementOrNode - existingElementOrNode represents the
547
- * element or node in the linked list before which you want to add a new element or node.
548
- * @param {E | SinglyLinkedListNode<E>} newElementOrNode - The `newElementOrNode` parameter in the
549
- * `addBefore` method represents the element or node that you want to insert before the existing
550
- * element or node in the linked list. This new element can be of type `E` or a
551
- * `SinglyLinkedListNode<E>`.
552
- * @returns The `addBefore` method returns a boolean value - `true` if the new element or node was
553
- * successfully added before the existing element or node, and `false` if the operation was
554
- * unsuccessful.
555
- */
556
- addBefore(existingElementOrNode, newElementOrNode) {
557
- const existingNode = this.getNode(existingElementOrNode);
558
- if (!existingNode)
559
- return false;
560
- const prevNode = this._getPrevNode(existingNode);
561
- const newNode = this._ensureNode(newElementOrNode);
562
- if (!prevNode) {
563
- // Add at the head
564
- this.unshift(newNode);
565
- }
566
- else {
567
- prevNode.next = newNode;
568
- newNode.next = existingNode;
569
- this._length++;
570
- }
571
- return true;
572
- }
573
- /**
574
- * Time Complexity: O(n)
575
- * Space Complexity: O(1)
576
- *
577
- * The `addAfter` function in TypeScript adds a new element or node after an existing element or node
578
- * in a singly linked list.
579
- * @param {E | SinglyLinkedListNode<E>} existingElementOrNode - existingElementOrNode can be either
580
- * an element of type E or a SinglyLinkedListNode of type E.
581
- * @param {E | SinglyLinkedListNode<E>} newElementOrNode - The `newElementOrNode` parameter in the
582
- * `addAfter` method represents the element or node that you want to add after the existing element
583
- * or node in a singly linked list. This parameter can be either the value of the new element or a
584
- * reference to a `SinglyLinkedListNode` containing
585
- * @returns The `addAfter` method returns a boolean value - `true` if the new element or node was
586
- * successfully added after the existing element or node, and `false` if the existing element or node
587
- * was not found.
588
- */
589
- addAfter(existingElementOrNode, newElementOrNode) {
590
- const existingNode = this.getNode(existingElementOrNode);
591
- if (existingNode) {
592
- const newNode = this._ensureNode(newElementOrNode);
593
- newNode.next = existingNode.next;
594
- existingNode.next = newNode;
595
- if (existingNode === this.tail) {
596
- this._tail = newNode;
597
- }
598
- this._length++;
599
- return true;
600
- }
601
- return false;
602
- }
603
- /**
604
- * Time Complexity: O(n)
605
- * Space Complexity: O(1)
606
- *
607
- * The function `splice` in TypeScript overrides the default behavior to remove and insert elements
608
- * in a singly linked list while handling boundary cases.
609
- * @param {number} start - The `start` parameter in the `splice` method indicates the index at which
610
- * to start modifying the list. It specifies the position where elements will be added or removed.
611
- * @param {number} [deleteCount=0] - The `deleteCount` parameter in the `splice` method specifies the
612
- * number of elements to remove from the array starting at the specified `start` index. If
613
- * `deleteCount` is not provided, it defaults to 0, meaning no elements will be removed but new
614
- * elements can still be inserted at
615
- * @param {E[]} items - The `items` parameter in the `splice` method represents the elements to be
616
- * inserted into the list at the specified `start` index. These elements will be inserted in place of
617
- * the elements that are removed from the list. The `splice` method allows you to add new elements to
618
- * the list while
619
- * @returns The `splice` method is returning a `SinglyLinkedList` containing the elements that were
620
- * removed from the original list during the splice operation.
621
- */
622
- splice(start, deleteCount = 0, ...items) {
623
- const removedList = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });
624
- // If `start` is out of range, perform boundary processing
625
- start = Math.max(0, Math.min(start, this.length));
626
- deleteCount = Math.max(0, deleteCount);
627
- // Find the predecessor node of `start`
628
- const prevNode = start === 0 ? undefined : this.getNodeAt(start - 1);
629
- const startNode = prevNode ? prevNode.next : this.head;
630
- let current = startNode;
631
- for (let i = 0; i < deleteCount && current; i++) {
632
- removedList.push(current.value);
633
- current = current.next;
634
- }
635
- const nextNode = current;
636
- let lastInsertedNode = undefined;
637
- for (const item of items) {
638
- const newNode = this._ensureNode(item);
639
- if (!lastInsertedNode) {
640
- if (prevNode) {
641
- prevNode.next = newNode;
642
- }
643
- else {
644
- this._head = newNode;
645
- }
646
- }
647
- else {
648
- lastInsertedNode.next = newNode;
649
- }
650
- lastInsertedNode = newNode;
651
- }
652
- // Connect new node to `nextNode`
653
- if (lastInsertedNode) {
654
- lastInsertedNode.next = nextNode;
655
- }
656
- else if (prevNode) {
657
- prevNode.next = nextNode;
658
- }
659
- // Update tail node and length
660
- if (!nextNode) {
661
- this._tail = lastInsertedNode || prevNode;
662
- }
663
- this._length += items.length - removedList.length;
664
- return removedList;
665
- }
666
- /**
667
- * Time Complexity: O(n)
668
- * Space Complexity: O(1)
669
- *
670
- * The function `countOccurrences` iterates through a singly linked list and counts the occurrences
671
- * of a specified element or nodes that satisfy a given predicate.
672
- * @param {E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)} elementOrNode
673
- * - The `elementOrNode` parameter in the `countOccurrences` method can accept three types of values:
674
- * @returns The `countOccurrences` method returns the number of occurrences of the specified element,
675
- * node, or predicate function in the singly linked list.
676
- */
677
- countOccurrences(elementOrNode) {
678
- const predicate = this._ensurePredicate(elementOrNode);
679
- let count = 0;
680
- let current = this.head;
681
- while (current) {
682
- if (predicate(current)) {
683
- count++;
684
- }
685
- current = current.next;
686
- }
687
- return count;
688
- }
689
- /**
690
- * Time Complexity: O(n)
691
- * Space Complexity: O(n)
692
- *
693
- * The `clone` function returns a new instance of the `SinglyLinkedList` class with the same values
694
- * as the original list.
695
- * @returns The `clone()` method is returning a new instance of the `SinglyLinkedList` class, which
696
- * is a clone of the original list.
697
- */
698
- clone() {
699
- return new SinglyLinkedList(this, { toElementFn: this.toElementFn, maxLen: this._maxLen });
700
- }
701
- /**
702
- * Time Complexity: O(n)
703
- * Space Complexity: O(n)
704
- *
705
- * The `filter` function creates a new SinglyLinkedList by iterating over the elements of the current
706
- * list and applying a callback function to each element to determine if it should be included in the
707
- * filtered list.
708
- * @param callback - The callback parameter is a function that will be called for each element in the
709
- * list. It takes three arguments: the current element, the index of the current element, and the
710
- * list itself. The callback function should return a boolean value indicating whether the current
711
- * element should be included in the filtered list or not
712
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
713
- * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
714
- * passed as the `this` value to the `callback` function. If `thisArg` is
715
- * @returns The `filter` method is returning a new `SinglyLinkedList` object that contains the
716
- * elements that pass the filter condition specified by the `callback` function.
717
- */
718
- filter(callback, thisArg) {
719
- const filteredList = this._createInstance({ toElementFn: this.toElementFn, maxLen: this._maxLen });
720
- let index = 0;
721
- for (const current of this) {
722
- if (callback.call(thisArg, current, index, this)) {
723
- filteredList.push(current);
724
- }
725
- index++;
726
- }
727
- return filteredList;
728
- }
729
- /**
730
- * Time Complexity: O(n)
731
- * Space Complexity: O(n)
732
- *
733
- * The `map` function takes a callback function and returns a new SinglyLinkedList with the results
734
- * of applying the callback to each element in the original list.
735
- * @param callback - The `callback` parameter is a function that will be called for each element in
736
- * the original list. It takes three arguments: `current` (the current element being processed),
737
- * `index` (the index of the current element), and `this` (the original list). It should return a
738
- * value
739
- * @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
740
- * convert the raw element (`RR`) to the desired element type (`T`). It takes the raw element as
741
- * input and returns the converted element. If this parameter is not provided, the raw element will
742
- * be used as is.
743
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
744
- * specify the value of `this` within the callback function. It is used to set the context or scope
745
- * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
746
- * value of
747
- * @returns a new instance of the `SinglyLinkedList` class with the mapped elements.
748
- */
749
- map(callback, toElementFn, thisArg) {
750
- const mappedList = new SinglyLinkedList([], { toElementFn, maxLen: this._maxLen });
751
- let index = 0;
752
- for (const current of this) {
753
- mappedList.push(callback.call(thisArg, current, index, this));
754
- index++;
755
- }
756
- return mappedList;
757
- }
758
- /**
759
- * The function `_createInstance` returns a new instance of `SinglyLinkedList` with the specified
760
- * options.
761
- * @param [options] - The `options` parameter in the `_createInstance` method is of type
762
- * `SinglyLinkedListOptions<E, R>`, which is used to configure the behavior of the `SinglyLinkedList`
763
- * instance being created. It is an optional parameter, meaning it can be omitted when calling the
764
- * method.
765
- * @returns An instance of the `SinglyLinkedList` class with an empty array and the provided options
766
- * is being returned.
767
- */
768
- _createInstance(options) {
769
- return new SinglyLinkedList([], options);
770
- }
771
- /**
772
- * The function `_getIterator` returns an iterable iterator that yields the values of a linked list.
773
- */
774
- *_getIterator() {
775
- let current = this.head;
776
- while (current) {
777
- yield current.value;
778
- current = current.next;
779
- }
780
- }
781
- /**
782
- * The function returns an iterator that iterates over the elements of a collection in reverse order.
783
- */
784
- *_getReverseIterator() {
785
- const reversedArr = [...this].reverse();
786
- for (const item of reversedArr) {
787
- yield item;
788
- }
789
- }
790
- /**
791
- * The function `_getNodeIterator` returns an iterator that iterates over the nodes of a singly
792
- * linked list.
793
- */
794
- *_getNodeIterator() {
795
- let current = this.head;
796
- while (current) {
797
- yield current;
798
- current = current.next;
799
- }
800
- }
801
- // protected *_getReverseNodeIterator(): IterableIterator<SinglyLinkedListNode<E>> {
802
- // const reversedArr = [...this._getNodeIterator()].reverse();
803
- //
804
- // for (const item of reversedArr) {
805
- // yield item;
806
- // }
807
- // }
808
- /**
809
- * The _isPredicate function in TypeScript checks if the input is a function that takes a
810
- * SinglyLinkedListNode as an argument and returns a boolean.
811
- * @param {E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)} elementNodeOrPredicate
812
- * elementNodeOrPredicate - The `elementNodeOrPredicate` parameter can be one of the following types:
813
- * @returns The _isPredicate method is returning a boolean value based on whether the
814
- * elementNodeOrPredicate parameter is a function or not. If the elementNodeOrPredicate is a
815
- * function, the method will return true, indicating that it is a predicate function. If it is not a
816
- * function, the method will return false.
817
- */
818
- _isPredicate(elementNodeOrPredicate) {
819
- return typeof elementNodeOrPredicate === 'function';
820
- }
821
- /**
822
- * The function `_ensureNode` ensures that the input is a valid node and returns it, creating a new
823
- * node if necessary.
824
- * @param {E | SinglyLinkedListNode<E>} elementOrNode - The `elementOrNode` parameter can be either
825
- * an element of type `E` or a `SinglyLinkedListNode` containing an element of type `E`.
826
- * @returns A SinglyLinkedListNode<E> object is being returned.
827
- */
828
- _ensureNode(elementOrNode) {
829
- if (this.isNode(elementOrNode))
830
- return elementOrNode;
831
- return new SinglyLinkedListNode(elementOrNode);
832
- }
833
- /**
834
- * The function `_ensurePredicate` in TypeScript ensures that the input is either a node, a predicate
835
- * function, or a value to compare with the node's value.
836
- * @param {E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)} elementNodeOrPredicate
837
- * elementNodeOrPredicate - The `elementNodeOrPredicate` parameter can be one of the following types:
838
- * @returns A function is being returned. If the input `elementNodeOrPredicate` is already a node, a
839
- * function is returned that checks if a given node is equal to the input node. If the input is a
840
- * predicate function, it is returned as is. If the input is neither a node nor a predicate function,
841
- * a function is returned that checks if a given node's value is equal to the input
842
- */
843
- _ensurePredicate(elementNodeOrPredicate) {
844
- if (this.isNode(elementNodeOrPredicate))
845
- return (node) => node === elementNodeOrPredicate;
846
- if (this._isPredicate(elementNodeOrPredicate))
847
- return elementNodeOrPredicate;
848
- return (node) => node.value === elementNodeOrPredicate;
849
- }
850
- /**
851
- * The function `_getPrevNode` returns the node before a given node in a singly linked list.
852
- * @param node - The `node` parameter in the `_getPrevNode` method is a reference to a node in a
853
- * singly linked list. The method is used to find the node that comes before the given node in the
854
- * linked list.
855
- * @returns The `_getPrevNode` method returns either the previous node of the input node in a singly
856
- * linked list or `undefined` if the input node is the head of the list or if the input node is not
857
- * found in the list.
858
- */
859
- _getPrevNode(node) {
860
- if (!this.head || this.head === node)
861
- return undefined;
862
- let current = this.head;
863
- while (current.next && current.next !== node) {
864
- current = current.next;
865
- }
866
- return current.next === node ? current : undefined;
867
- }
868
- }
869
- exports.SinglyLinkedList = SinglyLinkedList;
870
- //# sourceMappingURL=singly-linked-list.js.map