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
+ {"version":3,"file":"deque.js","sourceRoot":"","sources":["../../../../src/types/data-structures/queue/deque.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './queue';
2
+ export * from './deque';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./queue"), exports);
18
+ __exportStar(require("./deque"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/data-structures/queue/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,0CAAwB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../../src/types/data-structures/queue/queue.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './stack';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./stack"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/data-structures/stack/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=stack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../../src/types/data-structures/stack/stack.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './tree';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./tree"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/data-structures/tree/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=hash.js.map
3
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../../src/types/data-structures/tree/tree.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './trie';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./trie"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/data-structures/trie/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=trie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trie.js","sourceRoot":"","sources":["../../../../src/types/data-structures/trie/trie.ts"],"names":[],"mappings":""}
@@ -1,2 +1,4 @@
1
1
  export type Comparator<T> = (a: T, b: T) => number;
2
2
  export type DFSOrderPattern = 'pre' | 'in' | 'post';
3
+ export type MapCallback<N> = (node: N) => any;
4
+ export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;
@@ -17,3 +17,4 @@ export declare const trampoline: (fn: TrlFn) => ((...args: [...Parameters<TrlFn>
17
17
  export declare const trampolineAsync: (fn: TrlAsyncFn) => ((...args: [...Parameters<TrlAsyncFn>]) => Promise<any>) & {
18
18
  cont: (...args: [...Parameters<TrlAsyncFn>]) => Thunk;
19
19
  };
20
+ export declare const getMSB: (value: number) => number;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.trampolineAsync = exports.trampoline = exports.toThunk = exports.isThunk = exports.THUNK_SYMBOL = exports.arrayRemove = exports.uuidV4 = void 0;
12
+ exports.getMSB = exports.trampolineAsync = exports.trampoline = exports.toThunk = exports.isThunk = exports.THUNK_SYMBOL = exports.arrayRemove = exports.uuidV4 = void 0;
13
13
  const uuidV4 = function () {
14
14
  return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {
15
15
  const r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
@@ -64,4 +64,11 @@ const trampolineAsync = (fn) => {
64
64
  }), { cont });
65
65
  };
66
66
  exports.trampolineAsync = trampolineAsync;
67
+ const getMSB = (value) => {
68
+ if (value <= 0) {
69
+ return 0;
70
+ }
71
+ return 1 << (31 - Math.clz32(value));
72
+ };
73
+ exports.getMSB = getMSB;
67
74
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AASO,MAAM,MAAM,GAAG;IACpB,OAAO,sCAAsC,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC;QACvE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAChC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QACrC,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AANW,QAAA,MAAM,UAMjB;AAEK,MAAM,WAAW,GAAG,UAAa,KAAU,EAAE,SAA0D;IAC5G,IAAI,CAAC,GAAG,CAAC,CAAC,EACR,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,OAAO,EAAE,CAAC,GAAG,GAAG,EAAE;QAChB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE;YAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YAC3C,GAAG,EAAE,CAAC;SACP;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAfW,QAAA,WAAW,eAetB;AAEW,QAAA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AC,EAAc,EAAE,EAAE;IAChD,MAAM,IAAI,GAAG,CAAC,GAAG,IAAiC,EAAE,EAAE,CAAC,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAElF,OAAO,MAAM,CAAC,MAAM,CAClB,CAAO,GAAG,IAAiC,EAAE,EAAE;QAC7C,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAE/B,OAAO,IAAA,eAAO,EAAC,MAAM,CAAC,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;YACtD,MAAM,GAAG,MAAM,MAAM,EAAE,CAAC;SACzB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAA,EACD,EAAC,IAAI,EAAC,CACP,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,eAAe,mBAe1B;AAEK,MAAM,MAAM,GAAG,CAAC,KAAa,EAAU,EAAE;IAC9C,IAAI,KAAK,IAAI,CAAC,EAAE;QACd,OAAO,CAAC,CAAC;KACV;IACD,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AACvC,CAAC,CAAC;AALW,QAAA,MAAM,UAKjB"}
@@ -1,46 +1,144 @@
1
- /**
2
- * data-structure-typed
3
- *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
- * @license MIT License
7
- */
8
1
  export declare class BinaryIndexedTree {
2
+ protected readonly _freq: number;
3
+ protected readonly _max: number;
9
4
  /**
10
- * The constructor initializes an array with a specified length and fills it with zeros.
11
- * @param {number} n - The parameter `n` represents the size of the array that will be used to store the sum tree. The
12
- * sum tree is a binary tree data structure used to efficiently calculate the sum of a range of elements in an array.
13
- * The size of the sum tree array is `n + 1` because
14
- */
15
- constructor(n: number);
16
- private _sumTree;
17
- get sumTree(): number[];
18
- static lowBit(x: number): number;
19
- /**
20
- * The update function updates the values in a binary indexed tree by adding a delta value to the specified index and
21
- * its ancestors.
22
- * @param {number} i - The parameter `i` represents the index of the element in the `_sumTree` array that needs to be
23
- * updated.
24
- * @param {number} delta - The "delta" parameter represents the change in value that needs to be added to the element
25
- * at index "i" in the "_sumTree" array.
26
- */
27
- update(i: number, delta: number): void;
28
- /**
29
- * The function calculates the prefix sum of an array using a binary indexed tree.
30
- * @param {number} i - The parameter "i" in the function "getPrefixSum" represents the index of the element in the
31
- * array for which we want to calculate the prefix sum.
32
- * @returns The function `getPrefixSum` returns the prefix sum of the elements in the binary indexed tree up to index
33
- * `i`.
34
- */
35
- getPrefixSum(i: number): number;
36
- /**
37
- * The function `getRangeSum` calculates the sum of a range of numbers in an array.
38
- * @param {number} start - The start parameter is the starting index of the range for which we want to calculate the
39
- * sum.
40
- * @param {number} end - The "end" parameter represents the ending index of the range for which we want to calculate
41
- * the sum.
42
- * @returns the sum of the elements in the range specified by the start and end indices.
43
- */
44
- getRangeSum(start: number, end: number): number;
45
- protected _setSumTree(value: number[]): void;
5
+ * The constructor initializes the properties of an object, including default frequency, maximum
6
+ * value, a freqMap data structure, the most significant bit, and the count of negative frequencies.
7
+ * @param - - `frequency`: The default frequency value. It is optional and has a default
8
+ * value of 0.
9
+ */
10
+ constructor({ frequency, max }: {
11
+ frequency?: number;
12
+ max: number;
13
+ });
14
+ protected _freqMap: Record<number, number>;
15
+ get freqMap(): Record<number, number>;
16
+ set freqMap(value: Record<number, number>);
17
+ protected _msb: number;
18
+ get msb(): number;
19
+ set msb(value: number);
20
+ protected _negativeCount: number;
21
+ get negativeCount(): number;
22
+ set negativeCount(value: number);
23
+ get freq(): number;
24
+ get max(): number;
25
+ /**
26
+ * The function "readSingle" reads a single number from a specified index.
27
+ * @param {number} index - The `index` parameter is a number that represents the index of an element in a
28
+ * collection or array.
29
+ * @returns a number.
30
+ */
31
+ readSingle(index: number): number;
32
+ /**
33
+ * The "update" function updates the value at a given index by adding a delta and triggers a callback
34
+ * to notify of the change.
35
+ * @param {number} position - The `index` parameter represents the index of the element that needs to be
36
+ * updated in the data structure.
37
+ * @param {number} change - The "delta" parameter represents the change in value that needs to be
38
+ * applied to the frequency at the specified index.
39
+ */
40
+ update(position: number, change: number): void;
41
+ /**
42
+ * The function "writeSingle" checks the index and writes a single value with a given frequency.
43
+ * @param {number} index - The `index` parameter is a number that represents the index of an element. It
44
+ * is used to identify the specific element that needs to be written.
45
+ * @param {number} freq - The `freq` parameter represents the frequency value that needs to be
46
+ * written.
47
+ */
48
+ writeSingle(index: number, freq: number): void;
49
+ /**
50
+ * The read function takes a count parameter, checks if it is an integer, and returns the result of
51
+ * calling the _read function with the count parameter clamped between 0 and the maximum value.
52
+ * @param {number} count - The `count` parameter is a number that represents the number of items to
53
+ * read.
54
+ * @returns a number.
55
+ */
56
+ read(count: number): number;
57
+ /**
58
+ * The function returns the lower bound of a non-descending sequence that sums up to a given number.
59
+ * @param {number} sum - The `sum` parameter is a number that represents the target sum that we want
60
+ * to find in the sequence.
61
+ * @returns The lowerBound function is returning a number.
62
+ */
63
+ lowerBound(sum: number): number;
64
+ /**
65
+ * The upperBound function returns the index of the first element in a sequence that is greater than
66
+ * or equal to a given sum.
67
+ * @param {number} sum - The "sum" parameter is a number that represents the target sum that we want
68
+ * to find in the sequence.
69
+ * @returns The upperBound function is returning a number.
70
+ */
71
+ upperBound(sum: number): number;
72
+ /**
73
+ * The function returns the value of a specific index in a freqMap data structure, or a default value if
74
+ * the index is not found.
75
+ * @param {number} index - The `index` parameter is a number that represents the index of a node in a
76
+ * freqMap data structure.
77
+ * @returns a number.
78
+ */
79
+ protected _getFrequency(index: number): number;
80
+ /**
81
+ * The function _updateFrequency adds a delta value to the element at the specified index in the freqMap array.
82
+ * @param {number} index - The index parameter is a number that represents the index of the freqMap
83
+ * element that needs to be updated.
84
+ * @param {number} delta - The `delta` parameter represents the change in value that needs to be
85
+ * added to the freqMap at the specified `index`.
86
+ */
87
+ protected _updateFrequency(index: number, delta: number): void;
88
+ /**
89
+ * The function checks if the given index is valid and within the range.
90
+ * @param {number} index - The parameter "index" is of type number and represents the index value
91
+ * that needs to be checked.
92
+ */
93
+ protected _checkIndex(index: number): void;
94
+ /**
95
+ * The function calculates the sum of elements in an array up to a given index using a binary indexed
96
+ * freqMap.
97
+ * @param {number} index - The `index` parameter is a number that represents the index of an element in a
98
+ * data structure.
99
+ * @returns a number.
100
+ */
101
+ protected _readSingle(index: number): number;
102
+ /**
103
+ * The function `_updateNegativeCount` updates a counter based on changes in frequency values.
104
+ * @param {number} freqCur - The current frequency value.
105
+ * @param {number} freqNew - The freqNew parameter represents the new frequency value.
106
+ */
107
+ protected _updateNegativeCount(freqCur: number, freqNew: number): void;
108
+ /**
109
+ * The `_update` function updates the values in a binary indexed freqMap starting from a given index and
110
+ * propagating the changes to its parent nodes.
111
+ * @param {number} index - The `index` parameter is a number that represents the index of the element in
112
+ * the data structure that needs to be updated.
113
+ * @param {number} delta - The `delta` parameter represents the change in value that needs to be
114
+ * applied to the elements in the data structure.
115
+ */
116
+ protected _update(index: number, delta: number): void;
117
+ /**
118
+ * The `_writeSingle` function updates the frequency at a specific index and triggers a callback if
119
+ * the frequency has changed.
120
+ * @param {number} index - The `index` parameter is a number that represents the index of the element
121
+ * being modified or accessed.
122
+ * @param {number} freq - The `freq` parameter represents the new frequency value that needs to be
123
+ * written to the specified index `index`.
124
+ */
125
+ protected _writeSingle(index: number, freq: number): void;
126
+ /**
127
+ * The `_read` function calculates the sum of values in a binary freqMap up to a given count.
128
+ * @param {number} count - The `count` parameter is a number that represents the number of elements
129
+ * to read from the freqMap.
130
+ * @returns the sum of the values obtained from calling the `_getFrequency` method for each index in the
131
+ * range from `count` to 1.
132
+ */
133
+ protected _read(count: number): number;
134
+ /**
135
+ * The function `_binarySearch` performs a binary search to find the largest number that satisfies a given
136
+ * condition.
137
+ * @param {number} sum - The sum parameter is a number that represents the target sum value.
138
+ * @param before - The `before` parameter is a function that takes two numbers `x` and `y` as
139
+ * arguments and returns a boolean value. It is used to determine if `x` is less than or equal to
140
+ * `y`. The purpose of this function is to compare two numbers and determine their order.
141
+ * @returns the value of the variable "left".
142
+ */
143
+ protected _binarySearch(sum: number, before: (x: number, y: number) => boolean): number;
46
144
  }