data-structure-typed 1.37.4 → 1.37.5

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 (327) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +141 -43
  3. package/dist/data-structures/binary-tree/binary-indexed-tree.js +230 -42
  4. package/dist/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  5. package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
  6. package/dist/data-structures/binary-tree/bst.js.map +1 -1
  7. package/{lib/types/data-structures → dist/types/data-structures/binary-tree}/avl-tree.d.ts +1 -1
  8. package/dist/types/data-structures/binary-tree/avl-tree.js.map +1 -0
  9. package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  10. package/dist/types/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
  11. package/dist/types/data-structures/{binary-tree.d.ts → binary-tree/binary-tree.d.ts} +1 -5
  12. package/dist/types/data-structures/binary-tree/binary-tree.js.map +1 -0
  13. package/dist/types/data-structures/{bst.d.ts → binary-tree/bst.d.ts} +1 -1
  14. package/dist/types/data-structures/binary-tree/bst.js.map +1 -0
  15. package/dist/types/data-structures/binary-tree/index.d.ts +6 -0
  16. package/dist/types/data-structures/binary-tree/index.js +23 -0
  17. package/dist/types/data-structures/binary-tree/index.js.map +1 -0
  18. package/dist/types/data-structures/{rb-tree.d.ts → binary-tree/rb-tree.d.ts} +1 -1
  19. package/dist/types/data-structures/binary-tree/rb-tree.js.map +1 -0
  20. package/dist/types/data-structures/binary-tree/segment-tree.js.map +1 -0
  21. package/dist/types/data-structures/{tree-multiset.d.ts → binary-tree/tree-multiset.d.ts} +1 -1
  22. package/dist/types/data-structures/binary-tree/tree-multiset.js.map +1 -0
  23. package/dist/types/data-structures/graph/abstract-graph.js.map +1 -0
  24. package/dist/types/data-structures/graph/directed-graph.js.map +1 -0
  25. package/dist/types/data-structures/graph/index.d.ts +3 -0
  26. package/dist/types/data-structures/graph/index.js +20 -0
  27. package/dist/types/data-structures/graph/index.js.map +1 -0
  28. package/dist/types/data-structures/graph/map-graph.js.map +1 -0
  29. package/dist/types/data-structures/graph/undirected-graph.js +3 -0
  30. package/dist/types/data-structures/graph/undirected-graph.js.map +1 -0
  31. package/dist/types/data-structures/hash/coordinate-map.js +3 -0
  32. package/dist/types/data-structures/hash/coordinate-map.js.map +1 -0
  33. package/dist/types/data-structures/hash/coordinate-set.js +3 -0
  34. package/dist/types/data-structures/hash/coordinate-set.js.map +1 -0
  35. package/dist/types/data-structures/hash/hash-map.js +3 -0
  36. package/dist/types/data-structures/hash/hash-map.js.map +1 -0
  37. package/dist/types/data-structures/hash/hash-table.js +3 -0
  38. package/dist/types/data-structures/hash/hash-table.js.map +1 -0
  39. package/dist/types/data-structures/hash/index.js +3 -0
  40. package/dist/types/data-structures/hash/index.js.map +1 -0
  41. package/dist/types/data-structures/hash/tree-map.js +3 -0
  42. package/dist/types/data-structures/hash/tree-map.js.map +1 -0
  43. package/dist/types/data-structures/hash/tree-set.js +3 -0
  44. package/dist/types/data-structures/hash/tree-set.js.map +1 -0
  45. package/dist/types/data-structures/heap/heap.js.map +1 -0
  46. package/dist/types/data-structures/heap/index.d.ts +1 -0
  47. package/dist/types/data-structures/heap/index.js +18 -0
  48. package/dist/types/data-structures/heap/index.js.map +1 -0
  49. package/dist/types/data-structures/heap/max-heap.js +3 -0
  50. package/dist/types/data-structures/heap/max-heap.js.map +1 -0
  51. package/dist/types/data-structures/heap/min-heap.js +3 -0
  52. package/dist/types/data-structures/heap/min-heap.js.map +1 -0
  53. package/dist/types/data-structures/index.d.ts +8 -13
  54. package/dist/types/data-structures/index.js +8 -11
  55. package/dist/types/data-structures/index.js.map +1 -1
  56. package/dist/types/data-structures/linked-list/doubly-linked-list.js.map +1 -0
  57. package/dist/types/data-structures/linked-list/index.d.ts +2 -0
  58. package/dist/types/data-structures/linked-list/index.js +19 -0
  59. package/dist/types/data-structures/linked-list/index.js.map +1 -0
  60. package/dist/types/data-structures/linked-list/singly-linked-list.js.map +1 -0
  61. package/dist/types/data-structures/linked-list/skip-linked-list.js +3 -0
  62. package/dist/types/data-structures/linked-list/skip-linked-list.js.map +1 -0
  63. package/dist/types/data-structures/matrix/index.d.ts +1 -0
  64. package/dist/types/data-structures/matrix/index.js +18 -0
  65. package/dist/types/data-structures/matrix/index.js.map +1 -0
  66. package/dist/types/data-structures/matrix/matrix.js +3 -0
  67. package/dist/types/data-structures/matrix/matrix.js.map +1 -0
  68. package/dist/types/data-structures/matrix/matrix2d.js +3 -0
  69. package/dist/types/data-structures/matrix/matrix2d.js.map +1 -0
  70. package/dist/types/data-structures/matrix/navigator.js.map +1 -0
  71. package/dist/types/data-structures/matrix/vector2d.js +3 -0
  72. package/dist/types/data-structures/matrix/vector2d.js.map +1 -0
  73. package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
  74. package/dist/types/data-structures/priority-queue/index.js +20 -0
  75. package/dist/types/data-structures/priority-queue/index.js.map +1 -0
  76. package/dist/types/data-structures/priority-queue/max-priority-queue.js +3 -0
  77. package/dist/types/data-structures/priority-queue/max-priority-queue.js.map +1 -0
  78. package/dist/types/data-structures/priority-queue/min-priority-queue.js +3 -0
  79. package/dist/types/data-structures/priority-queue/min-priority-queue.js.map +1 -0
  80. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  81. package/dist/types/data-structures/priority-queue/priority-queue.js +3 -0
  82. package/dist/types/data-structures/priority-queue/priority-queue.js.map +1 -0
  83. package/dist/types/data-structures/queue/deque.d.ts +1 -0
  84. package/dist/types/data-structures/queue/deque.js +3 -0
  85. package/dist/types/data-structures/queue/deque.js.map +1 -0
  86. package/dist/types/data-structures/queue/index.d.ts +2 -0
  87. package/dist/types/data-structures/queue/index.js +19 -0
  88. package/dist/types/data-structures/queue/index.js.map +1 -0
  89. package/dist/types/data-structures/queue/queue.d.ts +1 -0
  90. package/dist/types/data-structures/queue/queue.js +3 -0
  91. package/dist/types/data-structures/queue/queue.js.map +1 -0
  92. package/dist/types/data-structures/stack/index.d.ts +1 -0
  93. package/dist/types/data-structures/stack/index.js +18 -0
  94. package/dist/types/data-structures/stack/index.js.map +1 -0
  95. package/dist/types/data-structures/stack/stack.d.ts +1 -0
  96. package/dist/types/data-structures/stack/stack.js +3 -0
  97. package/dist/types/data-structures/stack/stack.js.map +1 -0
  98. package/dist/types/data-structures/tree/index.d.ts +1 -0
  99. package/dist/types/data-structures/tree/index.js +18 -0
  100. package/dist/types/data-structures/tree/index.js.map +1 -0
  101. package/dist/types/data-structures/tree/tree.d.ts +1 -0
  102. package/dist/types/data-structures/{hash.js → tree/tree.js} +1 -1
  103. package/dist/types/data-structures/tree/tree.js.map +1 -0
  104. package/dist/types/data-structures/trie/index.d.ts +1 -0
  105. package/dist/types/data-structures/trie/index.js +18 -0
  106. package/dist/types/data-structures/trie/index.js.map +1 -0
  107. package/dist/types/data-structures/trie/trie.d.ts +1 -0
  108. package/dist/types/data-structures/trie/trie.js +3 -0
  109. package/dist/types/data-structures/trie/trie.js.map +1 -0
  110. package/dist/types/helpers.d.ts +2 -0
  111. package/dist/utils/utils.d.ts +1 -0
  112. package/dist/utils/utils.js +8 -1
  113. package/dist/utils/utils.js.map +1 -1
  114. package/lib/data-structures/binary-tree/binary-indexed-tree.d.ts +141 -43
  115. package/lib/data-structures/binary-tree/binary-indexed-tree.js +230 -42
  116. package/{dist/types/data-structures → lib/types/data-structures/binary-tree}/avl-tree.d.ts +1 -1
  117. package/lib/types/data-structures/binary-tree/avl-tree.js +1 -0
  118. package/lib/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
  119. package/lib/types/data-structures/binary-tree/binary-indexed-tree.js +1 -0
  120. package/lib/types/data-structures/{binary-tree.d.ts → binary-tree/binary-tree.d.ts} +1 -5
  121. package/lib/types/data-structures/{bst.d.ts → binary-tree/bst.d.ts} +1 -1
  122. package/lib/types/data-structures/binary-tree/index.d.ts +6 -0
  123. package/lib/types/data-structures/binary-tree/index.js +6 -0
  124. package/lib/types/data-structures/{rb-tree.d.ts → binary-tree/rb-tree.d.ts} +1 -1
  125. package/lib/types/data-structures/binary-tree/segment-tree.js +1 -0
  126. package/lib/types/data-structures/{tree-multiset.d.ts → binary-tree/tree-multiset.d.ts} +1 -1
  127. package/lib/types/data-structures/binary-tree/tree-multiset.js +1 -0
  128. package/lib/types/data-structures/graph/abstract-graph.js +1 -0
  129. package/lib/types/data-structures/graph/index.d.ts +3 -0
  130. package/lib/types/data-structures/graph/index.js +3 -0
  131. package/lib/types/data-structures/graph/map-graph.js +1 -0
  132. package/lib/types/data-structures/graph/undirected-graph.d.ts +1 -0
  133. package/lib/types/data-structures/graph/undirected-graph.js +1 -0
  134. package/lib/types/data-structures/hash/coordinate-map.d.ts +1 -0
  135. package/lib/types/data-structures/hash/coordinate-map.js +1 -0
  136. package/lib/types/data-structures/hash/coordinate-set.d.ts +1 -0
  137. package/lib/types/data-structures/hash/coordinate-set.js +1 -0
  138. package/lib/types/data-structures/hash/hash-map.d.ts +1 -0
  139. package/lib/types/data-structures/hash/hash-map.js +1 -0
  140. package/lib/types/data-structures/hash/hash-table.d.ts +1 -0
  141. package/lib/types/data-structures/hash/hash-table.js +1 -0
  142. package/lib/types/data-structures/hash/index.js +1 -0
  143. package/lib/types/data-structures/hash/tree-map.d.ts +1 -0
  144. package/lib/types/data-structures/hash/tree-map.js +1 -0
  145. package/lib/types/data-structures/hash/tree-set.d.ts +1 -0
  146. package/lib/types/data-structures/hash/tree-set.js +1 -0
  147. package/lib/types/data-structures/heap/heap.d.ts +1 -0
  148. package/lib/types/data-structures/heap/heap.js +1 -0
  149. package/lib/types/data-structures/heap/index.d.ts +1 -0
  150. package/lib/types/data-structures/heap/index.js +1 -0
  151. package/lib/types/data-structures/heap/max-heap.d.ts +1 -0
  152. package/lib/types/data-structures/heap/max-heap.js +1 -0
  153. package/lib/types/data-structures/heap/min-heap.d.ts +1 -0
  154. package/lib/types/data-structures/heap/min-heap.js +1 -0
  155. package/lib/types/data-structures/index.d.ts +8 -13
  156. package/lib/types/data-structures/index.js +8 -11
  157. package/lib/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -0
  158. package/lib/types/data-structures/linked-list/doubly-linked-list.js +1 -0
  159. package/lib/types/data-structures/linked-list/index.d.ts +2 -0
  160. package/lib/types/data-structures/linked-list/index.js +2 -0
  161. package/lib/types/data-structures/linked-list/singly-linked-list.d.ts +1 -0
  162. package/lib/types/data-structures/linked-list/singly-linked-list.js +1 -0
  163. package/lib/types/data-structures/linked-list/skip-linked-list.d.ts +1 -0
  164. package/lib/types/data-structures/linked-list/skip-linked-list.js +1 -0
  165. package/lib/types/data-structures/matrix/index.d.ts +1 -0
  166. package/lib/types/data-structures/matrix/index.js +1 -0
  167. package/lib/types/data-structures/matrix/matrix.d.ts +1 -0
  168. package/lib/types/data-structures/matrix/matrix.js +1 -0
  169. package/lib/types/data-structures/matrix/matrix2d.d.ts +1 -0
  170. package/lib/types/data-structures/matrix/matrix2d.js +1 -0
  171. package/lib/types/data-structures/matrix/navigator.js +1 -0
  172. package/lib/types/data-structures/matrix/vector2d.d.ts +1 -0
  173. package/lib/types/data-structures/matrix/vector2d.js +1 -0
  174. package/lib/types/data-structures/priority-queue/index.d.ts +3 -0
  175. package/lib/types/data-structures/priority-queue/index.js +3 -0
  176. package/lib/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
  177. package/lib/types/data-structures/priority-queue/max-priority-queue.js +1 -0
  178. package/lib/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
  179. package/lib/types/data-structures/priority-queue/min-priority-queue.js +1 -0
  180. package/lib/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  181. package/lib/types/data-structures/priority-queue/priority-queue.js +1 -0
  182. package/lib/types/data-structures/queue/deque.d.ts +1 -0
  183. package/lib/types/data-structures/queue/deque.js +1 -0
  184. package/lib/types/data-structures/queue/index.d.ts +2 -0
  185. package/lib/types/data-structures/queue/index.js +2 -0
  186. package/lib/types/data-structures/queue/queue.d.ts +1 -0
  187. package/lib/types/data-structures/queue/queue.js +1 -0
  188. package/lib/types/data-structures/stack/index.d.ts +1 -0
  189. package/lib/types/data-structures/stack/index.js +1 -0
  190. package/lib/types/data-structures/stack/stack.d.ts +1 -0
  191. package/lib/types/data-structures/stack/stack.js +1 -0
  192. package/lib/types/data-structures/tree/index.d.ts +1 -0
  193. package/lib/types/data-structures/tree/index.js +1 -0
  194. package/lib/types/data-structures/tree/tree.d.ts +1 -0
  195. package/lib/types/data-structures/tree/tree.js +1 -0
  196. package/lib/types/data-structures/trie/index.d.ts +1 -0
  197. package/lib/types/data-structures/trie/index.js +1 -0
  198. package/lib/types/data-structures/trie/trie.d.ts +1 -0
  199. package/lib/types/data-structures/trie/trie.js +1 -0
  200. package/lib/types/helpers.d.ts +2 -0
  201. package/lib/utils/utils.d.ts +1 -0
  202. package/lib/utils/utils.js +6 -0
  203. package/package.json +10 -10
  204. package/src/data-structures/binary-tree/binary-indexed-tree.ts +264 -42
  205. package/src/data-structures/binary-tree/binary-tree.ts +2 -3
  206. package/src/data-structures/binary-tree/bst.ts +12 -3
  207. package/src/types/data-structures/{avl-tree.ts → binary-tree/avl-tree.ts} +1 -1
  208. package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
  209. package/src/types/data-structures/{binary-tree.ts → binary-tree/binary-tree.ts} +1 -13
  210. package/src/types/data-structures/{bst.ts → binary-tree/bst.ts} +1 -1
  211. package/src/types/data-structures/binary-tree/index.ts +6 -0
  212. package/src/types/data-structures/{rb-tree.ts → binary-tree/rb-tree.ts} +2 -2
  213. package/src/types/data-structures/{tree-multiset.ts → binary-tree/tree-multiset.ts} +1 -1
  214. package/src/types/data-structures/graph/index.ts +3 -0
  215. package/src/types/data-structures/graph/undirected-graph.ts +1 -0
  216. package/src/types/data-structures/hash/coordinate-map.ts +1 -0
  217. package/src/types/data-structures/hash/coordinate-set.ts +1 -0
  218. package/src/types/data-structures/hash/hash-map.ts +1 -0
  219. package/src/types/data-structures/hash/hash-table.ts +1 -0
  220. package/src/types/data-structures/hash/tree-map.ts +1 -0
  221. package/src/types/data-structures/hash/tree-set.ts +1 -0
  222. package/src/types/data-structures/heap/heap.ts +1 -0
  223. package/src/types/data-structures/heap/index.ts +1 -0
  224. package/src/types/data-structures/heap/max-heap.ts +1 -0
  225. package/src/types/data-structures/heap/min-heap.ts +1 -0
  226. package/src/types/data-structures/index.ts +8 -14
  227. package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -0
  228. package/src/types/data-structures/linked-list/index.ts +2 -0
  229. package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -0
  230. package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
  231. package/src/types/data-structures/matrix/index.ts +1 -0
  232. package/src/types/data-structures/matrix/matrix.ts +1 -0
  233. package/src/types/data-structures/matrix/matrix2d.ts +1 -0
  234. package/src/types/data-structures/matrix/vector2d.ts +1 -0
  235. package/src/types/data-structures/priority-queue/index.ts +3 -0
  236. package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
  237. package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
  238. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  239. package/src/types/data-structures/queue/deque.ts +1 -0
  240. package/src/types/data-structures/queue/index.ts +2 -0
  241. package/src/types/data-structures/queue/queue.ts +1 -0
  242. package/src/types/data-structures/stack/index.ts +1 -0
  243. package/src/types/data-structures/stack/stack.ts +1 -0
  244. package/src/types/data-structures/tree/index.ts +1 -0
  245. package/src/types/data-structures/tree/tree.ts +1 -0
  246. package/src/types/data-structures/trie/index.ts +1 -0
  247. package/src/types/data-structures/trie/trie.ts +1 -0
  248. package/src/types/helpers.ts +4 -1
  249. package/src/utils/utils.ts +7 -0
  250. package/test/config.js +4 -0
  251. package/test/types/index.js +29 -0
  252. package/test/types/utils/big-o.js +2 -0
  253. package/test/types/utils/index.js +29 -0
  254. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +284 -0
  255. package/test/utils/big-o.js +212 -0
  256. package/test/utils/index.js +30 -0
  257. package/test/utils/number.js +14 -0
  258. package/umd/bundle.min.js +1 -1
  259. package/umd/bundle.min.js.map +1 -1
  260. package/dist/types/data-structures/abstract-graph.js.map +0 -1
  261. package/dist/types/data-structures/avl-tree.js.map +0 -1
  262. package/dist/types/data-structures/binary-tree.js.map +0 -1
  263. package/dist/types/data-structures/bst.js.map +0 -1
  264. package/dist/types/data-structures/directed-graph.js.map +0 -1
  265. package/dist/types/data-structures/doubly-linked-list.js.map +0 -1
  266. package/dist/types/data-structures/hash.js.map +0 -1
  267. package/dist/types/data-structures/heap.js.map +0 -1
  268. package/dist/types/data-structures/map-graph.js.map +0 -1
  269. package/dist/types/data-structures/navigator.js.map +0 -1
  270. package/dist/types/data-structures/rb-tree.js.map +0 -1
  271. package/dist/types/data-structures/segment-tree.js.map +0 -1
  272. package/dist/types/data-structures/singly-linked-list.js.map +0 -1
  273. package/dist/types/data-structures/tree-multiset.js.map +0 -1
  274. /package/dist/types/data-structures/{avl-tree.js → binary-tree/avl-tree.js} +0 -0
  275. /package/dist/types/data-structures/{doubly-linked-list.d.ts → binary-tree/binary-indexed-tree.d.ts} +0 -0
  276. /package/dist/types/data-structures/{binary-tree.js → binary-tree/binary-tree.js} +0 -0
  277. /package/dist/types/data-structures/{bst.js → binary-tree/bst.js} +0 -0
  278. /package/dist/types/data-structures/{rb-tree.js → binary-tree/rb-tree.js} +0 -0
  279. /package/dist/types/data-structures/{segment-tree.d.ts → binary-tree/segment-tree.d.ts} +0 -0
  280. /package/dist/types/data-structures/{segment-tree.js → binary-tree/segment-tree.js} +0 -0
  281. /package/dist/types/data-structures/{tree-multiset.js → binary-tree/tree-multiset.js} +0 -0
  282. /package/dist/types/data-structures/{abstract-graph.d.ts → graph/abstract-graph.d.ts} +0 -0
  283. /package/dist/types/data-structures/{abstract-graph.js → graph/abstract-graph.js} +0 -0
  284. /package/dist/types/data-structures/{directed-graph.d.ts → graph/directed-graph.d.ts} +0 -0
  285. /package/dist/types/data-structures/{directed-graph.js → graph/directed-graph.js} +0 -0
  286. /package/dist/types/data-structures/{map-graph.d.ts → graph/map-graph.d.ts} +0 -0
  287. /package/dist/types/data-structures/{map-graph.js → graph/map-graph.js} +0 -0
  288. /package/dist/types/data-structures/{heap.d.ts → graph/undirected-graph.d.ts} +0 -0
  289. /package/dist/types/data-structures/{singly-linked-list.d.ts → hash/coordinate-map.d.ts} +0 -0
  290. /package/{lib/types/data-structures/abstract-graph.js → dist/types/data-structures/hash/coordinate-set.d.ts} +0 -0
  291. /package/{lib/types/data-structures/avl-tree.js → dist/types/data-structures/hash/hash-map.d.ts} +0 -0
  292. /package/{lib/types/data-structures/doubly-linked-list.d.ts → dist/types/data-structures/hash/hash-table.d.ts} +0 -0
  293. /package/dist/types/data-structures/{hash.d.ts → hash/index.d.ts} +0 -0
  294. /package/{lib/types/data-structures/doubly-linked-list.js → dist/types/data-structures/hash/tree-map.d.ts} +0 -0
  295. /package/{lib/types/data-structures/hash.js → dist/types/data-structures/hash/tree-set.d.ts} +0 -0
  296. /package/{lib/types/data-structures → dist/types/data-structures/heap}/heap.d.ts +0 -0
  297. /package/dist/types/data-structures/{heap.js → heap/heap.js} +0 -0
  298. /package/{lib/types/data-structures/heap.js → dist/types/data-structures/heap/max-heap.d.ts} +0 -0
  299. /package/{lib/types/data-structures/map-graph.js → dist/types/data-structures/heap/min-heap.d.ts} +0 -0
  300. /package/{lib/types/data-structures/navigator.js → dist/types/data-structures/linked-list/doubly-linked-list.d.ts} +0 -0
  301. /package/dist/types/data-structures/{doubly-linked-list.js → linked-list/doubly-linked-list.js} +0 -0
  302. /package/{lib/types/data-structures → dist/types/data-structures/linked-list}/singly-linked-list.d.ts +0 -0
  303. /package/dist/types/data-structures/{singly-linked-list.js → linked-list/singly-linked-list.js} +0 -0
  304. /package/{lib/types/data-structures/segment-tree.js → dist/types/data-structures/linked-list/skip-linked-list.d.ts} +0 -0
  305. /package/{lib/types/data-structures/singly-linked-list.js → dist/types/data-structures/matrix/matrix.d.ts} +0 -0
  306. /package/{lib/types/data-structures/tree-multiset.js → dist/types/data-structures/matrix/matrix2d.d.ts} +0 -0
  307. /package/dist/types/data-structures/{navigator.d.ts → matrix/navigator.d.ts} +0 -0
  308. /package/dist/types/data-structures/{navigator.js → matrix/navigator.js} +0 -0
  309. /package/{src/types/data-structures/doubly-linked-list.ts → dist/types/data-structures/matrix/vector2d.d.ts} +0 -0
  310. /package/{src/types/data-structures/heap.ts → dist/types/data-structures/priority-queue/max-priority-queue.d.ts} +0 -0
  311. /package/{src/types/data-structures/singly-linked-list.ts → dist/types/data-structures/priority-queue/min-priority-queue.d.ts} +0 -0
  312. /package/lib/types/data-structures/{binary-tree.js → binary-tree/binary-tree.js} +0 -0
  313. /package/lib/types/data-structures/{bst.js → binary-tree/bst.js} +0 -0
  314. /package/lib/types/data-structures/{rb-tree.js → binary-tree/rb-tree.js} +0 -0
  315. /package/lib/types/data-structures/{segment-tree.d.ts → binary-tree/segment-tree.d.ts} +0 -0
  316. /package/lib/types/data-structures/{abstract-graph.d.ts → graph/abstract-graph.d.ts} +0 -0
  317. /package/lib/types/data-structures/{directed-graph.d.ts → graph/directed-graph.d.ts} +0 -0
  318. /package/lib/types/data-structures/{directed-graph.js → graph/directed-graph.js} +0 -0
  319. /package/lib/types/data-structures/{map-graph.d.ts → graph/map-graph.d.ts} +0 -0
  320. /package/lib/types/data-structures/{hash.d.ts → hash/index.d.ts} +0 -0
  321. /package/lib/types/data-structures/{navigator.d.ts → matrix/navigator.d.ts} +0 -0
  322. /package/src/types/data-structures/{segment-tree.ts → binary-tree/segment-tree.ts} +0 -0
  323. /package/src/types/data-structures/{abstract-graph.ts → graph/abstract-graph.ts} +0 -0
  324. /package/src/types/data-structures/{directed-graph.ts → graph/directed-graph.ts} +0 -0
  325. /package/src/types/data-structures/{map-graph.ts → graph/map-graph.ts} +0 -0
  326. /package/src/types/data-structures/{hash.ts → hash/index.ts} +0 -0
  327. /package/src/types/data-structures/{navigator.ts → matrix/navigator.ts} +0 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './heap';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,17 +1,11 @@
1
1
  export * from './binary-tree';
2
- export * from './bst';
3
- export * from './avl-tree';
4
- export * from './segment-tree';
5
- export * from './tree-multiset';
6
- export * from './abstract-graph';
7
- export * from './map-graph';
8
- export * from './rb-tree';
9
- export * from './directed-graph';
2
+ export * from './graph';
3
+ export * from './linked-list';
10
4
  export * from './heap';
11
- export * from './singly-linked-list';
12
- export * from './doubly-linked-list';
13
- export * from './navigator';
5
+ export * from './matrix';
14
6
  export * from './hash';
15
-
16
- export type MapCallback<N> = (node: N) => any;
17
- export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;
7
+ export * from './priority-queue';
8
+ export * from './queue';
9
+ export * from './stack';
10
+ export * from './tree';
11
+ export * from './trie';
@@ -0,0 +1,2 @@
1
+ export * from './singly-linked-list';
2
+ export * from './doubly-linked-list';
@@ -0,0 +1 @@
1
+ export * from './navigator';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './priority-queue';
2
+ export * from './min-priority-queue';
3
+ export * from './max-priority-queue';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './queue';
2
+ export * from './deque';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './stack';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './tree';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './trie';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,7 @@
1
1
  export type Comparator<T> = (a: T, b: T) => number;
2
2
 
3
- // export enum DFSOrderPattern {'pre' = 'pre', 'in' = 'in', 'post' = 'post'}
4
3
  export type DFSOrderPattern = 'pre' | 'in' | 'post';
4
+
5
+ export type MapCallback<N> = (node: N) => any;
6
+
7
+ export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;
@@ -77,3 +77,10 @@ export const trampolineAsync = (fn: TrlAsyncFn) => {
77
77
  {cont}
78
78
  );
79
79
  };
80
+
81
+ export const getMSB = (value: number): number => {
82
+ if (value <= 0) {
83
+ return 0;
84
+ }
85
+ return 1 << (31 - Math.clz32(value));
86
+ };
package/test/config.js ADDED
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', {value: true});
3
+ exports.isDebugTest = void 0;
4
+ exports.isDebugTest = false;
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = {
10
+ enumerable: true,
11
+ get: function () {
12
+ return m[k];
13
+ }
14
+ };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }
18
+ : function (o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ });
22
+ var __exportStar =
23
+ (this && this.__exportStar) ||
24
+ function (m, exports) {
25
+ for (var p in m)
26
+ if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, '__esModule', {value: true});
29
+ __exportStar(require('./utils'), exports);
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', {value: true});
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = {
10
+ enumerable: true,
11
+ get: function () {
12
+ return m[k];
13
+ }
14
+ };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }
18
+ : function (o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ });
22
+ var __exportStar =
23
+ (this && this.__exportStar) ||
24
+ function (m, exports) {
25
+ for (var p in m)
26
+ if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, '__esModule', {value: true});
29
+ __exportStar(require('./big-o'), exports);
@@ -0,0 +1,284 @@
1
+ import {BinaryIndexedTree} from '../../../../src';
2
+ import {isDebugTest} from '../../../config';
3
+
4
+ const isDebug = isDebugTest;
5
+
6
+ describe('BinaryIndexedTree simple', () => {
7
+ let bit: BinaryIndexedTree;
8
+
9
+ beforeEach(() => {
10
+ //Create a new BinaryIndexedTree instance before each test case
11
+ bit = new BinaryIndexedTree({frequency: 0, max: 10}); // Modify the value of max as needed
12
+ });
13
+
14
+ it('should initialize correctly', () => {
15
+ expect(bit.freq).toBe(0);
16
+ expect(bit.max).toBe(10);
17
+ expect(bit.freqMap).toEqual({0: 0}); // Modify the initialized record value according to the actual situation
18
+ // More initialization checks can be added
19
+ });
20
+
21
+ it('should read a single value correctly', () => {
22
+ // Test the function of reading a single value
23
+ bit.writeSingle(5, 5); //Write test data
24
+ expect(bit.readSingle(5)).toBe(5); // Read and verify
25
+ });
26
+
27
+ it('should update a value correctly', () => {
28
+ // Test the ability to update a single value
29
+ bit.writeSingle(5, 5); //Write test data
30
+ bit.update(5, 2); // update value
31
+ expect(bit.readSingle(5)).toBe(7); // Verify the updated value
32
+ });
33
+
34
+ it('should find lower bound correctly', () => {
35
+ //Test the function of finding the lower bound
36
+ bit.writeSingle(2, 10);
37
+ bit.writeSingle(5, 20);
38
+ bit.writeSingle(8, 30);
39
+ expect(bit.lowerBound(15)).toBe(5); // Find and verify the lower bound
40
+ });
41
+
42
+ it('should find upper bound correctly', () => {
43
+ //Test the function of finding the upper bound
44
+ bit.writeSingle(2, 10);
45
+ bit.writeSingle(5, 20);
46
+ bit.writeSingle(8, 30);
47
+ expect(bit.upperBound(25)).toBe(5); // Find and verify the upper bound
48
+ });
49
+ });
50
+
51
+ describe('BinaryIndexedTree', () => {
52
+ const frequency = 999;
53
+ const max = 10;
54
+ let bit: BinaryIndexedTree;
55
+
56
+ beforeEach(function () {
57
+ bit = new BinaryIndexedTree({frequency, max});
58
+ });
59
+ it('should validate the index', function () {
60
+ expect(() => bit.readSingle(-1)).toThrow('Index out of range');
61
+ expect(() => bit.readSingle(10)).toThrow('Index out of range');
62
+ });
63
+
64
+ it('should read a single frequency correctly', function () {
65
+ for (let i = 0; i < max; i++) {
66
+ expect(bit.readSingle(i)).toBe(frequency);
67
+ }
68
+ });
69
+ it('should validate the index', function () {
70
+ expect(() => bit.update(-1, 100)).toThrow('Index out of range');
71
+ expect(() => bit.update(10, 100)).toThrow('Index out of range');
72
+ });
73
+ it('should frequency and max', function () {
74
+ const frequency = 200;
75
+ const max = 1000;
76
+ const bit = new BinaryIndexedTree({frequency, max});
77
+
78
+ expect(bit.freq).toBe(frequency);
79
+ expect(bit.max).toBe(max);
80
+ });
81
+
82
+ it('should update the frequency with the given delta', function () {
83
+ for (let i = 0; i < max; i++) {
84
+ bit.update(i, i * 2);
85
+ }
86
+ for (let i = 0; i < max; i++) {
87
+ expect(bit.readSingle(i)).toBe(i * 2 + frequency);
88
+ }
89
+ });
90
+ it('should validate the index', function () {
91
+ expect(() => bit.writeSingle(-1, 100)).toThrow('Index out of range');
92
+ expect(() => bit.writeSingle(10, 100)).toThrow('Index out of range');
93
+ });
94
+
95
+ it('should writeSingle to be correctly invoked', function () {
96
+ for (let i = 0; i < max; i++) {
97
+ bit.writeSingle(i, i * 2);
98
+ }
99
+ for (let i = 0; i < max; i++) {
100
+ expect(bit.readSingle(i)).toBe(i * 2);
101
+ }
102
+ });
103
+
104
+ it('should read the frequency', function () {
105
+ for (let c = 0; c <= max; c++) {
106
+ expect(bit.read(c)).toBe(c * frequency);
107
+ }
108
+ });
109
+
110
+ const values = [-5, 0, 5, 10, 95, 100, 1000];
111
+ it('should find the upper-bound index', function () {
112
+ loopUpperBoundTests(bit, values);
113
+ });
114
+
115
+ it('should find the lower-bound index', function () {
116
+ loopLowerBoundTests(bit, values);
117
+ });
118
+ });
119
+
120
+ describe('designated values', function () {
121
+ const array = [1, 8, 6, 10, 7, 9, 0, 2, 6, 3];
122
+ const sumArray = (sum => array.map(value => (sum += value)))(0);
123
+ let bit: BinaryIndexedTree;
124
+
125
+ beforeEach(function () {
126
+ bit = new BinaryIndexedTree({max: array.length});
127
+ array.forEach((value, i) => bit.writeSingle(i, value));
128
+ });
129
+
130
+ describe('readSingle', function () {
131
+ it('should read a single frequency correctly', function () {
132
+ array.forEach((value, i) => {
133
+ expect(bit.readSingle(i)).toBe(array[i]);
134
+ });
135
+ });
136
+ });
137
+
138
+ describe('update', function () {
139
+ it('should update the frequency with the given delta', function () {
140
+ array.forEach((value, i) => bit.update(i, value + i));
141
+ array.forEach((value, i) => {
142
+ expect(bit.readSingle(i)).toBe(array[i] * 2 + i);
143
+ });
144
+ });
145
+ });
146
+
147
+ describe('writeSingle', function () {
148
+ it('should write a single frequency correctly', function () {
149
+ array.forEach((value, i) => bit.writeSingle(i, value + i));
150
+ array.forEach((value, i) => {
151
+ expect(bit.readSingle(i)).toBe(array[i] + i);
152
+ });
153
+ });
154
+ });
155
+
156
+ describe('read', function () {
157
+ it('should read the cumulative frequency correctly', function () {
158
+ expect(bit.read(0)).toBe(0);
159
+ sumArray.forEach((sum, i) => {
160
+ expect(bit.read(i + 1)).toBe(sum);
161
+ });
162
+ });
163
+ });
164
+
165
+ const values = [-5, 0, 15, 25, 43, 53, 100];
166
+
167
+ describe('upperBound', function () {
168
+ it('should find the upper-bound index', function () {
169
+ loopUpperBoundTests(bit, values);
170
+ });
171
+ });
172
+
173
+ describe('lowerBound', function () {
174
+ it('should find the lower-bound index', function () {
175
+ loopLowerBoundTests(bit, values);
176
+ });
177
+ });
178
+ });
179
+
180
+ describe('descending sequence', function () {
181
+ const array = [1, 8, -6, 10, 7, 9, 0, -2, 6, 3];
182
+ let bit: BinaryIndexedTree;
183
+
184
+ beforeEach(function () {
185
+ bit = new BinaryIndexedTree({max: array.length});
186
+ array.forEach((value, i) => bit.writeSingle(i, value));
187
+ });
188
+
189
+ it('should have a correct negativeCount property', function () {
190
+ expect(bit.negativeCount).toBe(2);
191
+ bit.update(2, 6);
192
+ expect(bit.negativeCount).toBe(1);
193
+ bit.update(7, 3);
194
+ expect(bit.negativeCount).toBe(0);
195
+ bit.update(8, -7);
196
+ expect(bit.negativeCount).toBe(1);
197
+ });
198
+
199
+ const values = [-5, 0, 15, 25, 43, 53, 100];
200
+
201
+ describe('upperBound', function () {
202
+ it('should validate the non-descending', function () {
203
+ expect(() => bit.upperBound(20)).toThrow('Must not be descending');
204
+ bit.update(2, 12);
205
+ bit.update(7, 4);
206
+ loopUpperBoundTests(bit, values);
207
+ });
208
+ });
209
+
210
+ describe('BinaryIndexedTree lowerBound', function () {
211
+ it('should validate the non-descending', function () {
212
+ expect(() => bit.lowerBound(20)).toThrow('Sequence is not non-descending');
213
+ bit.update(2, 12);
214
+ bit.update(7, 4);
215
+ loopLowerBoundTests(bit, values);
216
+ });
217
+ });
218
+ });
219
+
220
+ describe('BinaryIndexedTree additional tests', () => {
221
+ it('should handle read method correctly', () => {
222
+ const bit = new BinaryIndexedTree({max: 10});
223
+ bit.writeSingle(2, 10);
224
+ bit.writeSingle(5, 20);
225
+ bit.writeSingle(8, 30);
226
+ expect(bit.read(5)).toBe(10); // Ensure read method accumulates correctly
227
+ });
228
+
229
+ it('should handle consecutive operations', () => {
230
+ const bit = new BinaryIndexedTree({max: 10});
231
+ bit.writeSingle(2, 10);
232
+ bit.update(2, 5);
233
+ expect(bit.readSingle(2)).toBe(15);
234
+ bit.writeSingle(5, 20);
235
+ expect(bit.readSingle(5)).toBe(20);
236
+ expect(bit.lowerBound(15)).toBe(2);
237
+ });
238
+
239
+ it('should handle frequent increment updates', () => {
240
+ const bit = new BinaryIndexedTree({max: 10});
241
+ for (let i = 0; i < 10; i++) {
242
+ bit.update(2, 5);
243
+ }
244
+ expect(bit.readSingle(2)).toBe(50);
245
+ });
246
+
247
+ it('should handle edge cases', () => {
248
+ const bit = new BinaryIndexedTree({max: 10});
249
+ bit.writeSingle(9, 100);
250
+ expect(bit.readSingle(9)).toBe(100);
251
+ expect(bit.lowerBound(200)).toBe(10);
252
+ });
253
+ });
254
+ function loopUpperBoundTests(bit: BinaryIndexedTree, values: number[]) {
255
+ for (const value of values) {
256
+ const index = bit.upperBound(value);
257
+ if (index > 0) {
258
+ expect(bit.read(index)).toBeLessThanOrEqual(value);
259
+ } else {
260
+ expect(index).toBe(0);
261
+ }
262
+ if (index < bit.max) {
263
+ expect(bit.read(index + 1)).toBeGreaterThan(value);
264
+ } else {
265
+ expect(index).toBe(bit.max);
266
+ }
267
+ }
268
+ }
269
+
270
+ function loopLowerBoundTests(bit: BinaryIndexedTree, values: number[]) {
271
+ for (const value of values) {
272
+ const index = bit.lowerBound(value);
273
+ if (index > 0) {
274
+ expect(bit.read(index)).toBeLessThan(value);
275
+ } else {
276
+ expect(index).toBe(0);
277
+ }
278
+ if (index < bit.max) {
279
+ expect(bit.read(index + 1)).toBeGreaterThanOrEqual(value);
280
+ } else {
281
+ expect(index).toBe(bit.max);
282
+ }
283
+ }
284
+ }