@ac-kit/data 0.1.0

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 (599) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +75 -0
  3. package/dist/bit/bit-set.d.ts +84 -0
  4. package/dist/bit/bit-set.d.ts.map +1 -0
  5. package/dist/bit/bit-set.js +206 -0
  6. package/dist/bit/bit-set.js.map +1 -0
  7. package/dist/bit/bit-vector.d.ts +69 -0
  8. package/dist/bit/bit-vector.d.ts.map +1 -0
  9. package/dist/bit/bit-vector.js +172 -0
  10. package/dist/bit/bit-vector.js.map +1 -0
  11. package/dist/cache/_lru-store.d.ts +37 -0
  12. package/dist/cache/_lru-store.d.ts.map +1 -0
  13. package/dist/cache/_lru-store.js +137 -0
  14. package/dist/cache/_lru-store.js.map +1 -0
  15. package/dist/cache/lru-cache.d.ts +90 -0
  16. package/dist/cache/lru-cache.d.ts.map +1 -0
  17. package/dist/cache/lru-cache.js +143 -0
  18. package/dist/cache/lru-cache.js.map +1 -0
  19. package/dist/cache/lru-map.d.ts +72 -0
  20. package/dist/cache/lru-map.d.ts.map +1 -0
  21. package/dist/cache/lru-map.js +100 -0
  22. package/dist/cache/lru-map.js.map +1 -0
  23. package/dist/collection/_bounded.d.ts +27 -0
  24. package/dist/collection/_bounded.d.ts.map +1 -0
  25. package/dist/collection/_bounded.js +48 -0
  26. package/dist/collection/_bounded.js.map +1 -0
  27. package/dist/collection/_capacity-semaphore.d.ts +31 -0
  28. package/dist/collection/_capacity-semaphore.d.ts.map +1 -0
  29. package/dist/collection/_capacity-semaphore.js +94 -0
  30. package/dist/collection/_capacity-semaphore.js.map +1 -0
  31. package/dist/collection/iasync-collection.d.ts +16 -0
  32. package/dist/collection/iasync-collection.d.ts.map +1 -0
  33. package/dist/collection/iasync-collection.js +13 -0
  34. package/dist/collection/iasync-collection.js.map +1 -0
  35. package/dist/collection/iasync-searchable.d.ts +9 -0
  36. package/dist/collection/iasync-searchable.d.ts.map +1 -0
  37. package/dist/collection/iasync-searchable.js +2 -0
  38. package/dist/collection/iasync-searchable.js.map +1 -0
  39. package/dist/collection/ibounded.d.ts +36 -0
  40. package/dist/collection/ibounded.d.ts.map +1 -0
  41. package/dist/collection/ibounded.js +8 -0
  42. package/dist/collection/ibounded.js.map +1 -0
  43. package/dist/collection/icollection.d.ts +24 -0
  44. package/dist/collection/icollection.d.ts.map +1 -0
  45. package/dist/collection/icollection.js +2 -0
  46. package/dist/collection/icollection.js.map +1 -0
  47. package/dist/collection/ilossy.d.ts +20 -0
  48. package/dist/collection/ilossy.d.ts.map +1 -0
  49. package/dist/collection/ilossy.js +2 -0
  50. package/dist/collection/ilossy.js.map +1 -0
  51. package/dist/collection/ireplacing.d.ts +25 -0
  52. package/dist/collection/ireplacing.d.ts.map +1 -0
  53. package/dist/collection/ireplacing.js +2 -0
  54. package/dist/collection/ireplacing.js.map +1 -0
  55. package/dist/collection/isearchable.d.ts +36 -0
  56. package/dist/collection/isearchable.d.ts.map +1 -0
  57. package/dist/collection/isearchable.js +2 -0
  58. package/dist/collection/isearchable.js.map +1 -0
  59. package/dist/cursor/ibidirectional-cursor-sequence.d.ts +30 -0
  60. package/dist/cursor/ibidirectional-cursor-sequence.d.ts.map +1 -0
  61. package/dist/cursor/ibidirectional-cursor-sequence.js +2 -0
  62. package/dist/cursor/ibidirectional-cursor-sequence.js.map +1 -0
  63. package/dist/cursor/ibidirectional-cursor.d.ts +13 -0
  64. package/dist/cursor/ibidirectional-cursor.d.ts.map +1 -0
  65. package/dist/cursor/ibidirectional-cursor.js +2 -0
  66. package/dist/cursor/ibidirectional-cursor.js.map +1 -0
  67. package/dist/cursor/icursor-sequence.d.ts +48 -0
  68. package/dist/cursor/icursor-sequence.d.ts.map +1 -0
  69. package/dist/cursor/icursor-sequence.js +2 -0
  70. package/dist/cursor/icursor-sequence.js.map +1 -0
  71. package/dist/cursor/icursor.d.ts +27 -0
  72. package/dist/cursor/icursor.d.ts.map +1 -0
  73. package/dist/cursor/icursor.js +2 -0
  74. package/dist/cursor/icursor.js.map +1 -0
  75. package/dist/cursor/index-cursor-sequence.d.ts +57 -0
  76. package/dist/cursor/index-cursor-sequence.d.ts.map +1 -0
  77. package/dist/cursor/index-cursor-sequence.js +181 -0
  78. package/dist/cursor/index-cursor-sequence.js.map +1 -0
  79. package/dist/cursor/irandom-access-cursor.d.ts +16 -0
  80. package/dist/cursor/irandom-access-cursor.d.ts.map +1 -0
  81. package/dist/cursor/irandom-access-cursor.js +2 -0
  82. package/dist/cursor/irandom-access-cursor.js.map +1 -0
  83. package/dist/deque/blocking-deque.d.ts +36 -0
  84. package/dist/deque/blocking-deque.d.ts.map +1 -0
  85. package/dist/deque/blocking-deque.js +101 -0
  86. package/dist/deque/blocking-deque.js.map +1 -0
  87. package/dist/deque/bounded-deque.d.ts +58 -0
  88. package/dist/deque/bounded-deque.d.ts.map +1 -0
  89. package/dist/deque/bounded-deque.js +103 -0
  90. package/dist/deque/bounded-deque.js.map +1 -0
  91. package/dist/deque/deque.d.ts +35 -0
  92. package/dist/deque/deque.d.ts.map +1 -0
  93. package/dist/deque/deque.js +62 -0
  94. package/dist/deque/deque.js.map +1 -0
  95. package/dist/deque/iasync-deque.d.ts +19 -0
  96. package/dist/deque/iasync-deque.d.ts.map +1 -0
  97. package/dist/deque/iasync-deque.js +2 -0
  98. package/dist/deque/iasync-deque.js.map +1 -0
  99. package/dist/deque/iasync-lossy-deque.d.ts +11 -0
  100. package/dist/deque/iasync-lossy-deque.d.ts.map +1 -0
  101. package/dist/deque/iasync-lossy-deque.js +2 -0
  102. package/dist/deque/iasync-lossy-deque.js.map +1 -0
  103. package/dist/deque/ideque-storage.d.ts +6 -0
  104. package/dist/deque/ideque-storage.d.ts.map +1 -0
  105. package/dist/deque/ideque-storage.js +2 -0
  106. package/dist/deque/ideque-storage.js.map +1 -0
  107. package/dist/deque/ideque.d.ts +72 -0
  108. package/dist/deque/ideque.d.ts.map +1 -0
  109. package/dist/deque/ideque.js +2 -0
  110. package/dist/deque/ideque.js.map +1 -0
  111. package/dist/deque/ilossy-deque.d.ts +42 -0
  112. package/dist/deque/ilossy-deque.d.ts.map +1 -0
  113. package/dist/deque/ilossy-deque.js +2 -0
  114. package/dist/deque/ilossy-deque.js.map +1 -0
  115. package/dist/deque/iwaitable-deque.d.ts +42 -0
  116. package/dist/deque/iwaitable-deque.d.ts.map +1 -0
  117. package/dist/deque/iwaitable-deque.js +2 -0
  118. package/dist/deque/iwaitable-deque.js.map +1 -0
  119. package/dist/disjoint-set/iasync-disjoint-set.d.ts +11 -0
  120. package/dist/disjoint-set/iasync-disjoint-set.d.ts.map +1 -0
  121. package/dist/disjoint-set/iasync-disjoint-set.js +2 -0
  122. package/dist/disjoint-set/iasync-disjoint-set.js.map +1 -0
  123. package/dist/disjoint-set/idisjoint-set.d.ts +11 -0
  124. package/dist/disjoint-set/idisjoint-set.d.ts.map +1 -0
  125. package/dist/disjoint-set/idisjoint-set.js +2 -0
  126. package/dist/disjoint-set/idisjoint-set.js.map +1 -0
  127. package/dist/disjoint-set/static-disjoint-set.d.ts +67 -0
  128. package/dist/disjoint-set/static-disjoint-set.d.ts.map +1 -0
  129. package/dist/disjoint-set/static-disjoint-set.js +146 -0
  130. package/dist/disjoint-set/static-disjoint-set.js.map +1 -0
  131. package/dist/fuzzy/fuzzy-map.d.ts +62 -0
  132. package/dist/fuzzy/fuzzy-map.d.ts.map +1 -0
  133. package/dist/fuzzy/fuzzy-map.js +91 -0
  134. package/dist/fuzzy/fuzzy-map.js.map +1 -0
  135. package/dist/fuzzy/fuzzy-multi-map.d.ts +62 -0
  136. package/dist/fuzzy/fuzzy-multi-map.d.ts.map +1 -0
  137. package/dist/fuzzy/fuzzy-multi-map.js +143 -0
  138. package/dist/fuzzy/fuzzy-multi-map.js.map +1 -0
  139. package/dist/graph/directed-graph.d.ts +78 -0
  140. package/dist/graph/directed-graph.d.ts.map +1 -0
  141. package/dist/graph/directed-graph.js +165 -0
  142. package/dist/graph/directed-graph.js.map +1 -0
  143. package/dist/graph/graph.d.ts +73 -0
  144. package/dist/graph/graph.d.ts.map +1 -0
  145. package/dist/graph/graph.js +145 -0
  146. package/dist/graph/graph.js.map +1 -0
  147. package/dist/graph/iasync-directed-graph.d.ts +10 -0
  148. package/dist/graph/iasync-directed-graph.d.ts.map +1 -0
  149. package/dist/graph/iasync-directed-graph.js +2 -0
  150. package/dist/graph/iasync-directed-graph.js.map +1 -0
  151. package/dist/graph/iasync-graph.d.ts +19 -0
  152. package/dist/graph/iasync-graph.d.ts.map +1 -0
  153. package/dist/graph/iasync-graph.js +2 -0
  154. package/dist/graph/iasync-graph.js.map +1 -0
  155. package/dist/graph/idirected-graph.d.ts +10 -0
  156. package/dist/graph/idirected-graph.d.ts.map +1 -0
  157. package/dist/graph/idirected-graph.js +2 -0
  158. package/dist/graph/idirected-graph.js.map +1 -0
  159. package/dist/graph/igraph.d.ts +25 -0
  160. package/dist/graph/igraph.d.ts.map +1 -0
  161. package/dist/graph/igraph.js +2 -0
  162. package/dist/graph/igraph.js.map +1 -0
  163. package/dist/heap/_array-heap.d.ts +12 -0
  164. package/dist/heap/_array-heap.d.ts.map +1 -0
  165. package/dist/heap/_array-heap.js +74 -0
  166. package/dist/heap/_array-heap.js.map +1 -0
  167. package/dist/heap/binary-heap.d.ts +29 -0
  168. package/dist/heap/binary-heap.d.ts.map +1 -0
  169. package/dist/heap/binary-heap.js +83 -0
  170. package/dist/heap/binary-heap.js.map +1 -0
  171. package/dist/heap/blocking-binary-heap.d.ts +34 -0
  172. package/dist/heap/blocking-binary-heap.d.ts.map +1 -0
  173. package/dist/heap/blocking-binary-heap.js +84 -0
  174. package/dist/heap/blocking-binary-heap.js.map +1 -0
  175. package/dist/heap/bounded-binary-heap.d.ts +42 -0
  176. package/dist/heap/bounded-binary-heap.d.ts.map +1 -0
  177. package/dist/heap/bounded-binary-heap.js +71 -0
  178. package/dist/heap/bounded-binary-heap.js.map +1 -0
  179. package/dist/heap/iasync-heap.d.ts +19 -0
  180. package/dist/heap/iasync-heap.d.ts.map +1 -0
  181. package/dist/heap/iasync-heap.js +2 -0
  182. package/dist/heap/iasync-heap.js.map +1 -0
  183. package/dist/heap/iasync-lossy-heap.d.ts +9 -0
  184. package/dist/heap/iasync-lossy-heap.d.ts.map +1 -0
  185. package/dist/heap/iasync-lossy-heap.js +2 -0
  186. package/dist/heap/iasync-lossy-heap.js.map +1 -0
  187. package/dist/heap/iheap-storage.d.ts +5 -0
  188. package/dist/heap/iheap-storage.d.ts.map +1 -0
  189. package/dist/heap/iheap-storage.js +2 -0
  190. package/dist/heap/iheap-storage.js.map +1 -0
  191. package/dist/heap/iheap.d.ts +51 -0
  192. package/dist/heap/iheap.d.ts.map +1 -0
  193. package/dist/heap/iheap.js +2 -0
  194. package/dist/heap/iheap.js.map +1 -0
  195. package/dist/heap/ilossy-heap.d.ts +28 -0
  196. package/dist/heap/ilossy-heap.d.ts.map +1 -0
  197. package/dist/heap/ilossy-heap.js +2 -0
  198. package/dist/heap/ilossy-heap.js.map +1 -0
  199. package/dist/heap/iwaitable-heap.d.ts +27 -0
  200. package/dist/heap/iwaitable-heap.d.ts.map +1 -0
  201. package/dist/heap/iwaitable-heap.js +2 -0
  202. package/dist/heap/iwaitable-heap.js.map +1 -0
  203. package/dist/index.d.ts +144 -0
  204. package/dist/index.d.ts.map +1 -0
  205. package/dist/index.js +144 -0
  206. package/dist/index.js.map +1 -0
  207. package/dist/interval/iasync-interval-index.d.ts +8 -0
  208. package/dist/interval/iasync-interval-index.d.ts.map +1 -0
  209. package/dist/interval/iasync-interval-index.js +2 -0
  210. package/dist/interval/iasync-interval-index.js.map +1 -0
  211. package/dist/interval/iinterval-index.d.ts +8 -0
  212. package/dist/interval/iinterval-index.d.ts.map +1 -0
  213. package/dist/interval/iinterval-index.js +2 -0
  214. package/dist/interval/iinterval-index.js.map +1 -0
  215. package/dist/interval/static-interval-tree.d.ts +65 -0
  216. package/dist/interval/static-interval-tree.d.ts.map +1 -0
  217. package/dist/interval/static-interval-tree.js +170 -0
  218. package/dist/interval/static-interval-tree.js.map +1 -0
  219. package/dist/list/_bounded-list.d.ts +14 -0
  220. package/dist/list/_bounded-list.d.ts.map +1 -0
  221. package/dist/list/_bounded-list.js +23 -0
  222. package/dist/list/_bounded-list.js.map +1 -0
  223. package/dist/list/array-list.d.ts +56 -0
  224. package/dist/list/array-list.d.ts.map +1 -0
  225. package/dist/list/array-list.js +198 -0
  226. package/dist/list/array-list.js.map +1 -0
  227. package/dist/list/blocking-array-list.d.ts +55 -0
  228. package/dist/list/blocking-array-list.d.ts.map +1 -0
  229. package/dist/list/blocking-array-list.js +190 -0
  230. package/dist/list/blocking-array-list.js.map +1 -0
  231. package/dist/list/blocking-circular-array-list.d.ts +61 -0
  232. package/dist/list/blocking-circular-array-list.d.ts.map +1 -0
  233. package/dist/list/blocking-circular-array-list.js +211 -0
  234. package/dist/list/blocking-circular-array-list.js.map +1 -0
  235. package/dist/list/blocking-doubly-linked-list.d.ts +59 -0
  236. package/dist/list/blocking-doubly-linked-list.d.ts.map +1 -0
  237. package/dist/list/blocking-doubly-linked-list.js +211 -0
  238. package/dist/list/blocking-doubly-linked-list.js.map +1 -0
  239. package/dist/list/blocking-linked-list.d.ts +50 -0
  240. package/dist/list/blocking-linked-list.d.ts.map +1 -0
  241. package/dist/list/blocking-linked-list.js +172 -0
  242. package/dist/list/blocking-linked-list.js.map +1 -0
  243. package/dist/list/bounded-array-list.d.ts +47 -0
  244. package/dist/list/bounded-array-list.d.ts.map +1 -0
  245. package/dist/list/bounded-array-list.js +108 -0
  246. package/dist/list/bounded-array-list.js.map +1 -0
  247. package/dist/list/bounded-circular-array-list.d.ts +54 -0
  248. package/dist/list/bounded-circular-array-list.d.ts.map +1 -0
  249. package/dist/list/bounded-circular-array-list.js +123 -0
  250. package/dist/list/bounded-circular-array-list.js.map +1 -0
  251. package/dist/list/bounded-doubly-linked-list.d.ts +52 -0
  252. package/dist/list/bounded-doubly-linked-list.d.ts.map +1 -0
  253. package/dist/list/bounded-doubly-linked-list.js +123 -0
  254. package/dist/list/bounded-doubly-linked-list.js.map +1 -0
  255. package/dist/list/bounded-linked-list.d.ts +42 -0
  256. package/dist/list/bounded-linked-list.d.ts.map +1 -0
  257. package/dist/list/bounded-linked-list.js +97 -0
  258. package/dist/list/bounded-linked-list.js.map +1 -0
  259. package/dist/list/circular-array-list.d.ts +77 -0
  260. package/dist/list/circular-array-list.d.ts.map +1 -0
  261. package/dist/list/circular-array-list.js +322 -0
  262. package/dist/list/circular-array-list.js.map +1 -0
  263. package/dist/list/doubly-linked-list.d.ts +113 -0
  264. package/dist/list/doubly-linked-list.d.ts.map +1 -0
  265. package/dist/list/doubly-linked-list.js +453 -0
  266. package/dist/list/doubly-linked-list.js.map +1 -0
  267. package/dist/list/iasync-list.d.ts +17 -0
  268. package/dist/list/iasync-list.d.ts.map +1 -0
  269. package/dist/list/iasync-list.js +2 -0
  270. package/dist/list/iasync-list.js.map +1 -0
  271. package/dist/list/ilist-storage.d.ts +9 -0
  272. package/dist/list/ilist-storage.d.ts.map +1 -0
  273. package/dist/list/ilist-storage.js +2 -0
  274. package/dist/list/ilist-storage.js.map +1 -0
  275. package/dist/list/ilist.d.ts +118 -0
  276. package/dist/list/ilist.d.ts.map +1 -0
  277. package/dist/list/ilist.js +8 -0
  278. package/dist/list/ilist.js.map +1 -0
  279. package/dist/list/iwaitable-list.d.ts +47 -0
  280. package/dist/list/iwaitable-list.d.ts.map +1 -0
  281. package/dist/list/iwaitable-list.js +2 -0
  282. package/dist/list/iwaitable-list.js.map +1 -0
  283. package/dist/list/linked-list.d.ts +102 -0
  284. package/dist/list/linked-list.d.ts.map +1 -0
  285. package/dist/list/linked-list.js +377 -0
  286. package/dist/list/linked-list.js.map +1 -0
  287. package/dist/map/iasync-map.d.ts +13 -0
  288. package/dist/map/iasync-map.d.ts.map +1 -0
  289. package/dist/map/iasync-map.js +2 -0
  290. package/dist/map/iasync-map.js.map +1 -0
  291. package/dist/map/iasync-replacing-map.d.ts +8 -0
  292. package/dist/map/iasync-replacing-map.d.ts.map +1 -0
  293. package/dist/map/iasync-replacing-map.js +2 -0
  294. package/dist/map/iasync-replacing-map.js.map +1 -0
  295. package/dist/map/iasync-sorted-map.d.ts +12 -0
  296. package/dist/map/iasync-sorted-map.d.ts.map +1 -0
  297. package/dist/map/iasync-sorted-map.js +2 -0
  298. package/dist/map/iasync-sorted-map.js.map +1 -0
  299. package/dist/map/imap.d.ts +20 -0
  300. package/dist/map/imap.d.ts.map +1 -0
  301. package/dist/map/imap.js +2 -0
  302. package/dist/map/imap.js.map +1 -0
  303. package/dist/map/ireplacing-map.d.ts +19 -0
  304. package/dist/map/ireplacing-map.d.ts.map +1 -0
  305. package/dist/map/ireplacing-map.js +2 -0
  306. package/dist/map/ireplacing-map.js.map +1 -0
  307. package/dist/map/isorted-map.d.ts +23 -0
  308. package/dist/map/isorted-map.d.ts.map +1 -0
  309. package/dist/map/isorted-map.js +2 -0
  310. package/dist/map/isorted-map.js.map +1 -0
  311. package/dist/multimap/iasync-multimap.d.ts +16 -0
  312. package/dist/multimap/iasync-multimap.d.ts.map +1 -0
  313. package/dist/multimap/iasync-multimap.js +2 -0
  314. package/dist/multimap/iasync-multimap.js.map +1 -0
  315. package/dist/multimap/imultimap.d.ts +28 -0
  316. package/dist/multimap/imultimap.d.ts.map +1 -0
  317. package/dist/multimap/imultimap.js +2 -0
  318. package/dist/multimap/imultimap.js.map +1 -0
  319. package/dist/multimap/inverted-index.d.ts +90 -0
  320. package/dist/multimap/inverted-index.d.ts.map +1 -0
  321. package/dist/multimap/inverted-index.js +234 -0
  322. package/dist/multimap/inverted-index.js.map +1 -0
  323. package/dist/multimap/multi-map.d.ts +63 -0
  324. package/dist/multimap/multi-map.d.ts.map +1 -0
  325. package/dist/multimap/multi-map.js +146 -0
  326. package/dist/multimap/multi-map.js.map +1 -0
  327. package/dist/multiset/iasync-multiset.d.ts +13 -0
  328. package/dist/multiset/iasync-multiset.d.ts.map +1 -0
  329. package/dist/multiset/iasync-multiset.js +2 -0
  330. package/dist/multiset/iasync-multiset.js.map +1 -0
  331. package/dist/multiset/imultiset.d.ts +22 -0
  332. package/dist/multiset/imultiset.d.ts.map +1 -0
  333. package/dist/multiset/imultiset.js +2 -0
  334. package/dist/multiset/imultiset.js.map +1 -0
  335. package/dist/multiset/multi-set.d.ts +66 -0
  336. package/dist/multiset/multi-set.d.ts.map +1 -0
  337. package/dist/multiset/multi-set.js +124 -0
  338. package/dist/multiset/multi-set.js.map +1 -0
  339. package/dist/ordered-range/iasync-ordered-range.d.ts +15 -0
  340. package/dist/ordered-range/iasync-ordered-range.d.ts.map +1 -0
  341. package/dist/ordered-range/iasync-ordered-range.js +2 -0
  342. package/dist/ordered-range/iasync-ordered-range.js.map +1 -0
  343. package/dist/ordered-range/iordered-range.d.ts +28 -0
  344. package/dist/ordered-range/iordered-range.d.ts.map +1 -0
  345. package/dist/ordered-range/iordered-range.js +2 -0
  346. package/dist/ordered-range/iordered-range.js.map +1 -0
  347. package/dist/priority-queue/blocking-priority-queue.d.ts +37 -0
  348. package/dist/priority-queue/blocking-priority-queue.d.ts.map +1 -0
  349. package/dist/priority-queue/blocking-priority-queue.js +87 -0
  350. package/dist/priority-queue/blocking-priority-queue.js.map +1 -0
  351. package/dist/priority-queue/bounded-priority-queue.d.ts +45 -0
  352. package/dist/priority-queue/bounded-priority-queue.d.ts.map +1 -0
  353. package/dist/priority-queue/bounded-priority-queue.js +71 -0
  354. package/dist/priority-queue/bounded-priority-queue.js.map +1 -0
  355. package/dist/priority-queue/iasync-lossy-priority-queue.d.ts +9 -0
  356. package/dist/priority-queue/iasync-lossy-priority-queue.d.ts.map +1 -0
  357. package/dist/priority-queue/iasync-lossy-priority-queue.js +2 -0
  358. package/dist/priority-queue/iasync-lossy-priority-queue.js.map +1 -0
  359. package/dist/priority-queue/iasync-priority-queue.d.ts +21 -0
  360. package/dist/priority-queue/iasync-priority-queue.d.ts.map +1 -0
  361. package/dist/priority-queue/iasync-priority-queue.js +2 -0
  362. package/dist/priority-queue/iasync-priority-queue.js.map +1 -0
  363. package/dist/priority-queue/ilossy-priority-queue.d.ts +29 -0
  364. package/dist/priority-queue/ilossy-priority-queue.d.ts.map +1 -0
  365. package/dist/priority-queue/ilossy-priority-queue.js +2 -0
  366. package/dist/priority-queue/ilossy-priority-queue.js.map +1 -0
  367. package/dist/priority-queue/ipriority-queue.d.ts +71 -0
  368. package/dist/priority-queue/ipriority-queue.d.ts.map +1 -0
  369. package/dist/priority-queue/ipriority-queue.js +2 -0
  370. package/dist/priority-queue/ipriority-queue.js.map +1 -0
  371. package/dist/priority-queue/iwaitable-priority-queue.d.ts +27 -0
  372. package/dist/priority-queue/iwaitable-priority-queue.d.ts.map +1 -0
  373. package/dist/priority-queue/iwaitable-priority-queue.js +2 -0
  374. package/dist/priority-queue/iwaitable-priority-queue.js.map +1 -0
  375. package/dist/priority-queue/priority-queue.d.ts +49 -0
  376. package/dist/priority-queue/priority-queue.d.ts.map +1 -0
  377. package/dist/priority-queue/priority-queue.js +134 -0
  378. package/dist/priority-queue/priority-queue.js.map +1 -0
  379. package/dist/probabilistic/bloom-filter.d.ts +92 -0
  380. package/dist/probabilistic/bloom-filter.d.ts.map +1 -0
  381. package/dist/probabilistic/bloom-filter.js +156 -0
  382. package/dist/probabilistic/bloom-filter.js.map +1 -0
  383. package/dist/probabilistic/count-min-sketch.d.ts +76 -0
  384. package/dist/probabilistic/count-min-sketch.d.ts.map +1 -0
  385. package/dist/probabilistic/count-min-sketch.js +119 -0
  386. package/dist/probabilistic/count-min-sketch.js.map +1 -0
  387. package/dist/probabilistic/cuckoo-filter.d.ts +106 -0
  388. package/dist/probabilistic/cuckoo-filter.d.ts.map +1 -0
  389. package/dist/probabilistic/cuckoo-filter.js +214 -0
  390. package/dist/probabilistic/cuckoo-filter.js.map +1 -0
  391. package/dist/probabilistic/hash32.d.ts +28 -0
  392. package/dist/probabilistic/hash32.d.ts.map +1 -0
  393. package/dist/probabilistic/hash32.js +2 -0
  394. package/dist/probabilistic/hash32.js.map +1 -0
  395. package/dist/probabilistic/hyper-log-log.d.ts +74 -0
  396. package/dist/probabilistic/hyper-log-log.d.ts.map +1 -0
  397. package/dist/probabilistic/hyper-log-log.js +134 -0
  398. package/dist/probabilistic/hyper-log-log.js.map +1 -0
  399. package/dist/probabilistic/top-k.d.ts +62 -0
  400. package/dist/probabilistic/top-k.d.ts.map +1 -0
  401. package/dist/probabilistic/top-k.js +104 -0
  402. package/dist/probabilistic/top-k.js.map +1 -0
  403. package/dist/queue/blocking-queue.d.ts +32 -0
  404. package/dist/queue/blocking-queue.d.ts.map +1 -0
  405. package/dist/queue/blocking-queue.js +70 -0
  406. package/dist/queue/blocking-queue.js.map +1 -0
  407. package/dist/queue/bounded-queue.d.ts +47 -0
  408. package/dist/queue/bounded-queue.d.ts.map +1 -0
  409. package/dist/queue/bounded-queue.js +64 -0
  410. package/dist/queue/bounded-queue.js.map +1 -0
  411. package/dist/queue/iasync-lossy-queue.d.ts +15 -0
  412. package/dist/queue/iasync-lossy-queue.d.ts.map +1 -0
  413. package/dist/queue/iasync-lossy-queue.js +2 -0
  414. package/dist/queue/iasync-lossy-queue.js.map +1 -0
  415. package/dist/queue/iasync-queue.d.ts +17 -0
  416. package/dist/queue/iasync-queue.d.ts.map +1 -0
  417. package/dist/queue/iasync-queue.js +2 -0
  418. package/dist/queue/iasync-queue.js.map +1 -0
  419. package/dist/queue/ilossy-queue.d.ts +28 -0
  420. package/dist/queue/ilossy-queue.d.ts.map +1 -0
  421. package/dist/queue/ilossy-queue.js +2 -0
  422. package/dist/queue/ilossy-queue.js.map +1 -0
  423. package/dist/queue/iqueue-storage.d.ts +5 -0
  424. package/dist/queue/iqueue-storage.d.ts.map +1 -0
  425. package/dist/queue/iqueue-storage.js +2 -0
  426. package/dist/queue/iqueue-storage.js.map +1 -0
  427. package/dist/queue/iqueue.d.ts +41 -0
  428. package/dist/queue/iqueue.d.ts.map +1 -0
  429. package/dist/queue/iqueue.js +2 -0
  430. package/dist/queue/iqueue.js.map +1 -0
  431. package/dist/queue/iwaitable-queue.d.ts +27 -0
  432. package/dist/queue/iwaitable-queue.d.ts.map +1 -0
  433. package/dist/queue/iwaitable-queue.js +2 -0
  434. package/dist/queue/iwaitable-queue.js.map +1 -0
  435. package/dist/queue/lossy-queue.d.ts +33 -0
  436. package/dist/queue/lossy-queue.d.ts.map +1 -0
  437. package/dist/queue/lossy-queue.js +75 -0
  438. package/dist/queue/lossy-queue.js.map +1 -0
  439. package/dist/queue/queue.d.ts +27 -0
  440. package/dist/queue/queue.d.ts.map +1 -0
  441. package/dist/queue/queue.js +43 -0
  442. package/dist/queue/queue.js.map +1 -0
  443. package/dist/set/enhanced-set.d.ts +68 -0
  444. package/dist/set/enhanced-set.d.ts.map +1 -0
  445. package/dist/set/enhanced-set.js +169 -0
  446. package/dist/set/enhanced-set.js.map +1 -0
  447. package/dist/set/iasync-replacing-set.d.ts +8 -0
  448. package/dist/set/iasync-replacing-set.d.ts.map +1 -0
  449. package/dist/set/iasync-replacing-set.js +2 -0
  450. package/dist/set/iasync-replacing-set.js.map +1 -0
  451. package/dist/set/iasync-set.d.ts +16 -0
  452. package/dist/set/iasync-set.d.ts.map +1 -0
  453. package/dist/set/iasync-set.js +2 -0
  454. package/dist/set/iasync-set.js.map +1 -0
  455. package/dist/set/iasync-sorted-set.d.ts +7 -0
  456. package/dist/set/iasync-sorted-set.d.ts.map +1 -0
  457. package/dist/set/iasync-sorted-set.js +2 -0
  458. package/dist/set/iasync-sorted-set.js.map +1 -0
  459. package/dist/set/ireplacing-set.d.ts +24 -0
  460. package/dist/set/ireplacing-set.d.ts.map +1 -0
  461. package/dist/set/ireplacing-set.js +2 -0
  462. package/dist/set/ireplacing-set.js.map +1 -0
  463. package/dist/set/iset.d.ts +30 -0
  464. package/dist/set/iset.d.ts.map +1 -0
  465. package/dist/set/iset.js +2 -0
  466. package/dist/set/iset.js.map +1 -0
  467. package/dist/set/isorted-set.d.ts +7 -0
  468. package/dist/set/isorted-set.d.ts.map +1 -0
  469. package/dist/set/isorted-set.js +2 -0
  470. package/dist/set/isorted-set.js.map +1 -0
  471. package/dist/similarity/iasync-similarity-index.d.ts +8 -0
  472. package/dist/similarity/iasync-similarity-index.d.ts.map +1 -0
  473. package/dist/similarity/iasync-similarity-index.js +2 -0
  474. package/dist/similarity/iasync-similarity-index.js.map +1 -0
  475. package/dist/similarity/isimilarity-index.d.ts +8 -0
  476. package/dist/similarity/isimilarity-index.d.ts.map +1 -0
  477. package/dist/similarity/isimilarity-index.js +2 -0
  478. package/dist/similarity/isimilarity-index.js.map +1 -0
  479. package/dist/similarity/vp-tree.d.ts +71 -0
  480. package/dist/similarity/vp-tree.d.ts.map +1 -0
  481. package/dist/similarity/vp-tree.js +172 -0
  482. package/dist/similarity/vp-tree.js.map +1 -0
  483. package/dist/stack/blocking-stack.d.ts +30 -0
  484. package/dist/stack/blocking-stack.d.ts.map +1 -0
  485. package/dist/stack/blocking-stack.js +68 -0
  486. package/dist/stack/blocking-stack.js.map +1 -0
  487. package/dist/stack/bounded-stack.d.ts +38 -0
  488. package/dist/stack/bounded-stack.d.ts.map +1 -0
  489. package/dist/stack/bounded-stack.js +55 -0
  490. package/dist/stack/bounded-stack.js.map +1 -0
  491. package/dist/stack/iasync-lossy-stack.d.ts +9 -0
  492. package/dist/stack/iasync-lossy-stack.d.ts.map +1 -0
  493. package/dist/stack/iasync-lossy-stack.js +2 -0
  494. package/dist/stack/iasync-lossy-stack.js.map +1 -0
  495. package/dist/stack/iasync-stack.d.ts +15 -0
  496. package/dist/stack/iasync-stack.d.ts.map +1 -0
  497. package/dist/stack/iasync-stack.js +2 -0
  498. package/dist/stack/iasync-stack.js.map +1 -0
  499. package/dist/stack/ilossy-stack.d.ts +28 -0
  500. package/dist/stack/ilossy-stack.d.ts.map +1 -0
  501. package/dist/stack/ilossy-stack.js +2 -0
  502. package/dist/stack/ilossy-stack.js.map +1 -0
  503. package/dist/stack/istack-storage.d.ts +5 -0
  504. package/dist/stack/istack-storage.d.ts.map +1 -0
  505. package/dist/stack/istack-storage.js +2 -0
  506. package/dist/stack/istack-storage.js.map +1 -0
  507. package/dist/stack/istack.d.ts +41 -0
  508. package/dist/stack/istack.d.ts.map +1 -0
  509. package/dist/stack/istack.js +2 -0
  510. package/dist/stack/istack.js.map +1 -0
  511. package/dist/stack/iwaitable-stack.d.ts +26 -0
  512. package/dist/stack/iwaitable-stack.d.ts.map +1 -0
  513. package/dist/stack/iwaitable-stack.js +2 -0
  514. package/dist/stack/iwaitable-stack.js.map +1 -0
  515. package/dist/stack/stack.d.ts +26 -0
  516. package/dist/stack/stack.d.ts.map +1 -0
  517. package/dist/stack/stack.js +42 -0
  518. package/dist/stack/stack.js.map +1 -0
  519. package/dist/storage/iindexed-storage.d.ts +8 -0
  520. package/dist/storage/iindexed-storage.d.ts.map +1 -0
  521. package/dist/storage/iindexed-storage.js +2 -0
  522. package/dist/storage/iindexed-storage.js.map +1 -0
  523. package/dist/storage/ipop-back-storage.d.ts +8 -0
  524. package/dist/storage/ipop-back-storage.d.ts.map +1 -0
  525. package/dist/storage/ipop-back-storage.js +2 -0
  526. package/dist/storage/ipop-back-storage.js.map +1 -0
  527. package/dist/storage/ipop-front-storage.d.ts +8 -0
  528. package/dist/storage/ipop-front-storage.d.ts.map +1 -0
  529. package/dist/storage/ipop-front-storage.js +2 -0
  530. package/dist/storage/ipop-front-storage.js.map +1 -0
  531. package/dist/storage/ipush-back-storage.d.ts +7 -0
  532. package/dist/storage/ipush-back-storage.d.ts.map +1 -0
  533. package/dist/storage/ipush-back-storage.js +2 -0
  534. package/dist/storage/ipush-back-storage.js.map +1 -0
  535. package/dist/storage/ipush-front-storage.d.ts +7 -0
  536. package/dist/storage/ipush-front-storage.d.ts.map +1 -0
  537. package/dist/storage/ipush-front-storage.js +2 -0
  538. package/dist/storage/ipush-front-storage.js.map +1 -0
  539. package/dist/storage/istorage.d.ts +13 -0
  540. package/dist/storage/istorage.d.ts.map +1 -0
  541. package/dist/storage/istorage.js +2 -0
  542. package/dist/storage/istorage.js.map +1 -0
  543. package/dist/storage/ring-vector.d.ts +59 -0
  544. package/dist/storage/ring-vector.d.ts.map +1 -0
  545. package/dist/storage/ring-vector.js +192 -0
  546. package/dist/storage/ring-vector.js.map +1 -0
  547. package/dist/storage/segmented-ring-vector.d.ts +42 -0
  548. package/dist/storage/segmented-ring-vector.d.ts.map +1 -0
  549. package/dist/storage/segmented-ring-vector.js +142 -0
  550. package/dist/storage/segmented-ring-vector.js.map +1 -0
  551. package/dist/storage/typed-vector.d.ts +67 -0
  552. package/dist/storage/typed-vector.d.ts.map +1 -0
  553. package/dist/storage/typed-vector.js +123 -0
  554. package/dist/storage/typed-vector.js.map +1 -0
  555. package/dist/substring/generalized-suffix-array.d.ts +43 -0
  556. package/dist/substring/generalized-suffix-array.d.ts.map +1 -0
  557. package/dist/substring/generalized-suffix-array.js +100 -0
  558. package/dist/substring/generalized-suffix-array.js.map +1 -0
  559. package/dist/substring/iasync-substring-index.d.ts +6 -0
  560. package/dist/substring/iasync-substring-index.d.ts.map +1 -0
  561. package/dist/substring/iasync-substring-index.js +2 -0
  562. package/dist/substring/iasync-substring-index.js.map +1 -0
  563. package/dist/substring/isubstring-index.d.ts +6 -0
  564. package/dist/substring/isubstring-index.d.ts.map +1 -0
  565. package/dist/substring/isubstring-index.js +2 -0
  566. package/dist/substring/isubstring-index.js.map +1 -0
  567. package/dist/substring/suffix-array.d.ts +45 -0
  568. package/dist/substring/suffix-array.d.ts.map +1 -0
  569. package/dist/substring/suffix-array.js +164 -0
  570. package/dist/substring/suffix-array.js.map +1 -0
  571. package/dist/tree/avl-tree.d.ts +43 -0
  572. package/dist/tree/avl-tree.d.ts.map +1 -0
  573. package/dist/tree/avl-tree.js +98 -0
  574. package/dist/tree/avl-tree.js.map +1 -0
  575. package/dist/tree/binary-search-tree.d.ts +94 -0
  576. package/dist/tree/binary-search-tree.d.ts.map +1 -0
  577. package/dist/tree/binary-search-tree.js +303 -0
  578. package/dist/tree/binary-search-tree.js.map +1 -0
  579. package/dist/tree/iavl-tree-node.d.ts +6 -0
  580. package/dist/tree/iavl-tree-node.d.ts.map +1 -0
  581. package/dist/tree/iavl-tree-node.js +2 -0
  582. package/dist/tree/iavl-tree-node.js.map +1 -0
  583. package/dist/tree/isearch-tree.d.ts +14 -0
  584. package/dist/tree/isearch-tree.d.ts.map +1 -0
  585. package/dist/tree/isearch-tree.js +2 -0
  586. package/dist/tree/isearch-tree.js.map +1 -0
  587. package/dist/trie/iasync-trie.d.ts +9 -0
  588. package/dist/trie/iasync-trie.d.ts.map +1 -0
  589. package/dist/trie/iasync-trie.js +2 -0
  590. package/dist/trie/iasync-trie.js.map +1 -0
  591. package/dist/trie/itrie.d.ts +9 -0
  592. package/dist/trie/itrie.d.ts.map +1 -0
  593. package/dist/trie/itrie.js +2 -0
  594. package/dist/trie/itrie.js.map +1 -0
  595. package/dist/trie/trie.d.ts +93 -0
  596. package/dist/trie/trie.d.ts.map +1 -0
  597. package/dist/trie/trie.js +190 -0
  598. package/dist/trie/trie.js.map +1 -0
  599. package/package.json +63 -0
@@ -0,0 +1,62 @@
1
+ import { RingVector } from "../storage/ring-vector.js";
2
+ /**
3
+ * An unbounded double-ended queue.
4
+ *
5
+ * Backed by {@link RingVector} — one flat wrap-around array, so both ends are
6
+ * O(1) with no per-element node allocation. `DoublyLinkedList` also satisfies
7
+ * `DequeStorage` and is the right choice when elements must survive being
8
+ * spliced out of the middle; it is not the right default.
9
+ *
10
+ * For a capacity, use `BoundedDeque` (throws when full) or `BlockingDeque`
11
+ * (waits).
12
+ *
13
+ * @template T The type of elements in the deque.
14
+ */
15
+ export class Deque {
16
+ storage;
17
+ constructor(iterable, options) {
18
+ if (options?.storage) {
19
+ this.storage = options.storage;
20
+ if (iterable) {
21
+ this.storage.pushBackAll(iterable);
22
+ }
23
+ }
24
+ else {
25
+ this.storage = new RingVector(iterable);
26
+ }
27
+ }
28
+ [Symbol.iterator]() {
29
+ return this.storage[Symbol.iterator]();
30
+ }
31
+ clear() {
32
+ this.storage.clear();
33
+ }
34
+ count() {
35
+ return this.storage.count();
36
+ }
37
+ unshift(item) {
38
+ this.storage.pushFront(item);
39
+ }
40
+ unshiftAll(items) {
41
+ this.storage.pushFrontAll(items);
42
+ }
43
+ push(item) {
44
+ this.storage.pushBack(item);
45
+ }
46
+ pushAll(items) {
47
+ this.storage.pushBackAll(items);
48
+ }
49
+ shift() {
50
+ return this.storage.popFront();
51
+ }
52
+ pop() {
53
+ return this.storage.popBack();
54
+ }
55
+ front() {
56
+ return this.storage.front();
57
+ }
58
+ back() {
59
+ return this.storage.back();
60
+ }
61
+ }
62
+ //# sourceMappingURL=deque.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deque.js","sourceRoot":"","sources":["../../src/deque/deque.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAQvD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,KAAK;IACA,OAAO,CAAmB;IAE3C,YAAY,QAAsB,EAAE,OAAyB;QAC5D,IAAI,OAAO,EAAE,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YAE/B,IAAI,QAAQ,EAAE,CAAC;gBACd,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAI,QAAQ,CAAC,CAAC;QAC5C,CAAC;IACF,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxC,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,KAAK;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,CAAC,IAAO;QACd,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,UAAU,CAAC,KAAmB;QAC7B,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,IAAO;QACX,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,CAAC,KAAmB;QAC1B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,KAAK;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IAChC,CAAC;IAED,GAAG;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;CACD"}
@@ -0,0 +1,19 @@
1
+ import { DefinedValue } from "@ac-kit/core";
2
+ import { IAsyncCollection } from "../collection/iasync-collection.js";
3
+ /**
4
+ * The async-backed sibling of {@link IDeque}. No `IAsyncBlockingDeque`: every
5
+ * async-backed method already returns a `Promise`, so the sync world's "throw
6
+ * vs. await" split collapses to one `Promise<void>` shape — a separate blocking
7
+ * sibling would be a redundant, identical type.
8
+ */
9
+ export interface IAsyncDeque<T extends DefinedValue = DefinedValue> extends IAsyncCollection<T> {
10
+ unshift(item: T, signal?: AbortSignal): Promise<void>;
11
+ unshiftAll(items: Iterable<T>, signal?: AbortSignal): Promise<void>;
12
+ push(item: T, signal?: AbortSignal): Promise<void>;
13
+ pushAll(items: Iterable<T>, signal?: AbortSignal): Promise<void>;
14
+ shift(signal?: AbortSignal): Promise<T | undefined>;
15
+ pop(signal?: AbortSignal): Promise<T | undefined>;
16
+ front(signal?: AbortSignal): Promise<T | undefined>;
17
+ back(signal?: AbortSignal): Promise<T | undefined>;
18
+ }
19
+ //# sourceMappingURL=iasync-deque.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iasync-deque.d.ts","sourceRoot":"","sources":["../../src/deque/iasync-deque.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,WAAW,WAAW,CAC3B,CAAC,SAAS,YAAY,GAAG,YAAY,CACpC,SAAQ,gBAAgB,CAAC,CAAC,CAAC;IAC5B,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAEpD,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAElD,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAEpD,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CACnD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=iasync-deque.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iasync-deque.js","sourceRoot":"","sources":["../../src/deque/iasync-deque.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { DefinedValue } from "@ac-kit/core";
2
+ import { ILossy } from "../collection/ilossy.js";
3
+ import { IAsyncDeque } from "./iasync-deque.js";
4
+ /** The async-backed sibling of {@link ILossyDeque}. */
5
+ export interface IAsyncLossyDeque<T extends DefinedValue = DefinedValue> extends Omit<IAsyncDeque<T>, "unshift" | "unshiftAll" | "push" | "pushAll">, ILossy {
6
+ unshift(item: T, signal?: AbortSignal): Promise<readonly T[]>;
7
+ unshiftAll(items: Iterable<T>, signal?: AbortSignal): Promise<readonly T[]>;
8
+ push(item: T, signal?: AbortSignal): Promise<readonly T[]>;
9
+ pushAll(items: Iterable<T>, signal?: AbortSignal): Promise<readonly T[]>;
10
+ }
11
+ //# sourceMappingURL=iasync-lossy-deque.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iasync-lossy-deque.d.ts","sourceRoot":"","sources":["../../src/deque/iasync-lossy-deque.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,uDAAuD;AACvD,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,CACtE,SACC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC,EACnE,MAAM;IACP,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAE9D,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAE5E,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAE3D,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;CACzE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=iasync-lossy-deque.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iasync-lossy-deque.js","sourceRoot":"","sources":["../../src/deque/iasync-lossy-deque.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { DefinedValue } from "@ac-kit/core";
2
+ import { IQueueStorage } from "../queue/iqueue-storage.js";
3
+ import { IPopBackStorage } from "../storage/ipop-back-storage.js";
4
+ import { IPushFrontStorage } from "../storage/ipush-front-storage.js";
5
+ export type IDequeStorage<T extends DefinedValue> = IQueueStorage<T> & IPopBackStorage<T> & IPushFrontStorage<T>;
6
+ //# sourceMappingURL=ideque-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ideque-storage.d.ts","sourceRoot":"","sources":["../../src/deque/ideque-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,YAAY,IAAI,aAAa,CAAC,CAAC,CAAC,GACnE,eAAe,CAAC,CAAC,CAAC,GAClB,iBAAiB,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ideque-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ideque-storage.js","sourceRoot":"","sources":["../../src/deque/ideque-storage.ts"],"names":[],"mappings":""}
@@ -0,0 +1,72 @@
1
+ import type { DefinedValue } from "@ac-kit/core";
2
+ import { ICollection } from "../collection/icollection.js";
3
+ /**
4
+ * Interface representing a double-ended queue (deque) data type.
5
+ *
6
+ * A deque is a generalized version of a queue that allows insertion and removal
7
+ * of items from both ends.
8
+ *
9
+ * @template T The type of elements in the deque. Anything except `undefined`,
10
+ * which means "no element".
11
+ */
12
+ export interface IDeque<T extends DefinedValue = DefinedValue> extends ICollection<T> {
13
+ /**
14
+ * Adds an item to the front of the deque.
15
+ *
16
+ * @param item The item to add to the front of the deque.
17
+ */
18
+ unshift(item: T): void;
19
+ /**
20
+ * Adds every item to the front of the deque.
21
+ *
22
+ * The items keep their relative order, so the _first_ element of the array
23
+ * becomes the new front — `Array.prototype.unshift` semantics.
24
+ *
25
+ * @param items The items to add to the front of the deque.
26
+ */
27
+ unshiftAll(items: readonly T[]): void;
28
+ /**
29
+ * Adds an item to the back of the deque.
30
+ *
31
+ * @param item The item to add to the back of the deque.
32
+ */
33
+ push(item: T): void;
34
+ /**
35
+ * Adds every item to the back of the deque.
36
+ *
37
+ * The items keep their relative order, so the last element of the array
38
+ * becomes the new back — `Array.prototype.push` semantics.
39
+ *
40
+ * @param items The items to add to the back of the deque.
41
+ */
42
+ pushAll(items: readonly T[]): void;
43
+ /**
44
+ * Removes and returns the item at the front of the deque.
45
+ *
46
+ * @returns The item at the front of the deque, or `undefined` if the deque is
47
+ * empty.
48
+ */
49
+ shift(): T | undefined;
50
+ /**
51
+ * Removes and returns the item at the back of the deque.
52
+ *
53
+ * @returns The item at the back of the deque, or `undefined` if the deque is
54
+ * empty.
55
+ */
56
+ pop(): T | undefined;
57
+ /**
58
+ * Returns the item at the front of the deque without removing it.
59
+ *
60
+ * @returns The item at the front of the deque, or `undefined` if the deque is
61
+ * empty.
62
+ */
63
+ front(): T | undefined;
64
+ /**
65
+ * Returns the item at the back of the deque without removing it.
66
+ *
67
+ * @returns The item at the back of the deque, or `undefined` if the deque is
68
+ * empty.
69
+ */
70
+ back(): T | undefined;
71
+ }
72
+ //# sourceMappingURL=ideque.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ideque.d.ts","sourceRoot":"","sources":["../../src/deque/ideque.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,WAAW,MAAM,CACtB,CAAC,SAAS,YAAY,GAAG,YAAY,CACpC,SAAQ,WAAW,CAAC,CAAC,CAAC;IACvB;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IAEvB;;;;;;;OAOG;IACH,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC;IAEtC;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IAEpB;;;;;;;OAOG;IACH,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC;IAEnC;;;;;OAKG;IACH,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAEvB;;;;;OAKG;IACH,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;IAErB;;;;;OAKG;IACH,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAEvB;;;;;OAKG;IACH,IAAI,IAAI,CAAC,GAAG,SAAS,CAAC;CACtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ideque.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ideque.js","sourceRoot":"","sources":["../../src/deque/ideque.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ import { DefinedValue } from "@ac-kit/core";
2
+ import { ILossy } from "../collection/ilossy.js";
3
+ import { IDeque } from "./ideque.js";
4
+ /**
5
+ * The lossy sibling of {@link IDeque}: never throws or waits when a bounded
6
+ * deque is full, evicting or skipping instead (`overflowPolicy`).
7
+ *
8
+ * `"evict"` drops the end opposite the insertion — `push` (back) drops the
9
+ * front, `unshift` (front) drops the back — mirroring Python's
10
+ * `deque(maxlen=N)` and Boost's `circular_buffer`.
11
+ */
12
+ export interface ILossyDeque<T extends DefinedValue = DefinedValue> extends IDeque<T>, ILossy {
13
+ /**
14
+ * Same as `IDeque.unshift`, but never throws — returns the items dropped from
15
+ * the back to make room (empty if nothing was dropped).
16
+ *
17
+ * @see IDeque.unshift
18
+ */
19
+ unshift(item: T): readonly T[];
20
+ /**
21
+ * Same as `IDeque.unshiftAll`, but never throws — returns the items dropped
22
+ * from the back to make room (empty if nothing was dropped).
23
+ *
24
+ * @see IDeque.unshiftAll
25
+ */
26
+ unshiftAll(items: readonly T[]): readonly T[];
27
+ /**
28
+ * Same as `IDeque.push`, but never throws — returns the items dropped from
29
+ * the front to make room (empty if nothing was dropped).
30
+ *
31
+ * @see IDeque.push
32
+ */
33
+ push(item: T): readonly T[];
34
+ /**
35
+ * Same as `IDeque.pushAll`, but never throws — returns the items dropped from
36
+ * the front to make room (empty if nothing was dropped).
37
+ *
38
+ * @see IDeque.pushAll
39
+ */
40
+ pushAll(items: readonly T[]): readonly T[];
41
+ }
42
+ //# sourceMappingURL=ilossy-deque.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ilossy-deque.d.ts","sourceRoot":"","sources":["../../src/deque/ilossy-deque.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,CACjE,SAAQ,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM;IACzB;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;IAE/B;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC;IAE9C;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;IAE5B;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC;CAC3C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ilossy-deque.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ilossy-deque.js","sourceRoot":"","sources":["../../src/deque/ilossy-deque.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ import { DefinedValue } from "@ac-kit/core";
2
+ import { IBounded } from "../collection/ibounded.js";
3
+ import { IDeque } from "./ideque.js";
4
+ /**
5
+ * The blocking sibling of {@link IDeque}: waits for capacity when the deque is
6
+ * full. The inherited `unshift`/`push` throws — this adds a way to wait, it
7
+ * does not change the way to fail.
8
+ */
9
+ export interface IWaitableDeque<T extends DefinedValue = DefinedValue> extends IDeque<T>, IBounded {
10
+ /**
11
+ * Same as `unshift`, but waits for capacity if the operation would exceed it.
12
+ *
13
+ * @param signal Optional abort signal to cancel the operation.
14
+ * @see IDeque.unshift
15
+ */
16
+ waitUnshift(item: T, signal?: AbortSignal | null): Promise<void>;
17
+ /**
18
+ * Same as `unshiftAll`, but waits for capacity if the operation would exceed
19
+ * it. The whole batch lands at once, never interleaved with another
20
+ * waiter's.
21
+ *
22
+ * @param signal Optional abort signal to cancel the operation.
23
+ * @see IDeque.unshiftAll
24
+ */
25
+ waitUnshiftAll(items: Iterable<T>, signal?: AbortSignal | null): Promise<void>;
26
+ /**
27
+ * Same as `push`, but waits for capacity if the operation would exceed it.
28
+ *
29
+ * @param signal Optional abort signal to cancel the operation.
30
+ * @see IDeque.push
31
+ */
32
+ waitPush(item: T, signal?: AbortSignal | null): Promise<void>;
33
+ /**
34
+ * Same as `pushAll`, but waits for capacity if the operation would exceed it.
35
+ * The whole batch lands at once, never interleaved with another waiter's.
36
+ *
37
+ * @param signal Optional abort signal to cancel the operation.
38
+ * @see IDeque.pushAll
39
+ */
40
+ waitPushAll(items: Iterable<T>, signal?: AbortSignal | null): Promise<void>;
41
+ }
42
+ //# sourceMappingURL=iwaitable-deque.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iwaitable-deque.d.ts","sourceRoot":"","sources":["../../src/deque/iwaitable-deque.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,CACpE,SAAQ,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ;IAC3B;;;;;OAKG;IACH,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjE;;;;;;;OAOG;IACH,cAAc,CACb,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GACzB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9D;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=iwaitable-deque.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iwaitable-deque.js","sourceRoot":"","sources":["../../src/deque/iwaitable-deque.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { DefinedValue } from "@ac-kit/core";
2
+ /** The async-backed sibling of {@link IDisjointSet}. */
3
+ export interface IAsyncDisjointSet<T extends DefinedValue = DefinedValue> {
4
+ setCount(signal?: AbortSignal): Promise<number>;
5
+ makeSet(item: T, signal?: AbortSignal): Promise<void>;
6
+ makeSets(items: Iterable<T>, signal?: AbortSignal): Promise<void>;
7
+ find(item: T, signal?: AbortSignal): Promise<T | undefined>;
8
+ union(a: T, b: T, signal?: AbortSignal): Promise<boolean>;
9
+ connected(a: T, b: T, signal?: AbortSignal): Promise<boolean>;
10
+ }
11
+ //# sourceMappingURL=iasync-disjoint-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iasync-disjoint-set.d.ts","sourceRoot":"","sources":["../../src/disjoint-set/iasync-disjoint-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,wDAAwD;AACxD,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5D,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=iasync-disjoint-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iasync-disjoint-set.js","sourceRoot":"","sources":["../../src/disjoint-set/iasync-disjoint-set.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { DefinedValue } from "@ac-kit/core";
2
+ /** Union-find over items of type `T`. */
3
+ export interface IDisjointSet<T extends DefinedValue = DefinedValue> {
4
+ setCount(): number;
5
+ makeSet(item: T): void;
6
+ makeSets(items: Iterable<T>): void;
7
+ find(item: T): T | undefined;
8
+ union(a: T, b: T): boolean;
9
+ connected(a: T, b: T): boolean;
10
+ }
11
+ //# sourceMappingURL=idisjoint-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idisjoint-set.d.ts","sourceRoot":"","sources":["../../src/disjoint-set/idisjoint-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,yCAAyC;AACzC,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY;IAClE,QAAQ,IAAI,MAAM,CAAC;IACnB,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACnC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC7B,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;IAC3B,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;CAC/B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=idisjoint-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idisjoint-set.js","sourceRoot":"","sources":["../../src/disjoint-set/idisjoint-set.ts"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
1
+ import { DefinedValue } from "@ac-kit/core";
2
+ import type { IDisjointSet } from "./idisjoint-set.js";
3
+ /**
4
+ * Union-find: tracks a partition of items into disjoint sets, answering "are
5
+ * these two in the same set" and merging two sets, both in near-constant time.
6
+ *
7
+ * "Static" names the shape of the problem, not the API — sets only ever merge,
8
+ * never split, which is what allows the flattening that makes it fast. Items
9
+ * may be added at any time.
10
+ *
11
+ * Both optimisations are present: **path compression** on `find` (every node
12
+ * walked is re-pointed straight at the root) and **union by rank** (the
13
+ * shallower tree is hung under the deeper one). Together they give O(α(n))
14
+ * amortised per operation, where α is the inverse Ackermann function — at most
15
+ * 4 for any n that fits in memory, so constant in practice.
16
+ *
17
+ * Items are compared by `SameValueZero`, native `Map` semantics.
18
+ *
19
+ * @template T The item type.
20
+ */
21
+ export declare class StaticDisjointSet<T extends DefinedValue = DefinedValue> implements IDisjointSet<T> {
22
+ private readonly indices;
23
+ private readonly items;
24
+ private readonly parents;
25
+ /**
26
+ * Upper bound on tree height, not an exact height: path compression lowers
27
+ * the real one.
28
+ */
29
+ private readonly ranks;
30
+ private sets;
31
+ constructor(iterable?: Iterable<T>);
32
+ /** The number of disjoint sets, not the number of items. O(1). */
33
+ setCount(): number;
34
+ /** The number of items across every set. O(1). */
35
+ count(): number;
36
+ /** Adds `item` as a set of its own. A no-op if it is already known. O(1). */
37
+ makeSet(item: T): void;
38
+ /** O(m) in the number of items. */
39
+ makeSets(items: Iterable<T>): void;
40
+ /** Whether `item` belongs to any set. O(1). */
41
+ has(item: T): boolean;
42
+ /**
43
+ * The representative of `item`'s set — the same value for every member, and
44
+ * stable until the set is merged into another.
45
+ *
46
+ * @returns The representative, or `undefined` if `item` was never added.
47
+ */
48
+ find(item: T): T | undefined;
49
+ /**
50
+ * Merges the sets holding `a` and `b`. Either operand not yet known is added
51
+ * first, so building a partition from a stream of pairs needs no separate
52
+ * `makeSet` pass; isolated items still do.
53
+ *
54
+ * @returns `true` if two distinct sets were merged, `false` if `a` and `b`
55
+ * were already in the same one.
56
+ */
57
+ union(a: T, b: T): boolean;
58
+ /**
59
+ * Whether `a` and `b` are in the same set. A query, so an unknown item is
60
+ * simply not connected to anything rather than being added.
61
+ */
62
+ connected(a: T, b: T): boolean;
63
+ /** Each set as its own array of members, in no particular order. O(n). */
64
+ groups(): IterableIterator<readonly T[]>;
65
+ private findRoot;
66
+ }
67
+ //# sourceMappingURL=static-disjoint-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-disjoint-set.d.ts","sourceRoot":"","sources":["../../src/disjoint-set/static-disjoint-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,iBAAiB,CAC7B,CAAC,SAAS,YAAY,GAAG,YAAY,CACpC,YAAW,YAAY,CAAC,CAAC,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAChD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IAEtC,OAAO,CAAC,IAAI,CAAK;IAEjB,YAAY,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAIjC;IAED,kEAAkE;IAClE,QAAQ,IAAI,MAAM,CAEjB;IAED,kDAAkD;IAClD,KAAK,IAAI,MAAM,CAEd;IAED,6EAA6E;IAC7E,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAYrB;IAED,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAIjC;IAED,+CAA+C;IAC/C,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAEpB;IAED;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAI3B;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CA0BzB;IAED;;;OAGG;IACH,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAS7B;IAED,0EAA0E;IACzE,MAAM,IAAI,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC,CAexC;IAED,OAAO,CAAC,QAAQ;CAmBhB"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Union-find: tracks a partition of items into disjoint sets, answering "are
3
+ * these two in the same set" and merging two sets, both in near-constant time.
4
+ *
5
+ * "Static" names the shape of the problem, not the API — sets only ever merge,
6
+ * never split, which is what allows the flattening that makes it fast. Items
7
+ * may be added at any time.
8
+ *
9
+ * Both optimisations are present: **path compression** on `find` (every node
10
+ * walked is re-pointed straight at the root) and **union by rank** (the
11
+ * shallower tree is hung under the deeper one). Together they give O(α(n))
12
+ * amortised per operation, where α is the inverse Ackermann function — at most
13
+ * 4 for any n that fits in memory, so constant in practice.
14
+ *
15
+ * Items are compared by `SameValueZero`, native `Map` semantics.
16
+ *
17
+ * @template T The item type.
18
+ */
19
+ export class StaticDisjointSet {
20
+ indices = new Map();
21
+ items = [];
22
+ parents = [];
23
+ /**
24
+ * Upper bound on tree height, not an exact height: path compression lowers
25
+ * the real one.
26
+ */
27
+ ranks = [];
28
+ sets = 0;
29
+ constructor(iterable) {
30
+ if (iterable) {
31
+ this.makeSets(iterable);
32
+ }
33
+ }
34
+ /** The number of disjoint sets, not the number of items. O(1). */
35
+ setCount() {
36
+ return this.sets;
37
+ }
38
+ /** The number of items across every set. O(1). */
39
+ count() {
40
+ return this.items.length;
41
+ }
42
+ /** Adds `item` as a set of its own. A no-op if it is already known. O(1). */
43
+ makeSet(item) {
44
+ if (this.indices.has(item)) {
45
+ return;
46
+ }
47
+ const index = this.items.length;
48
+ this.indices.set(item, index);
49
+ this.items.push(item);
50
+ this.parents.push(index);
51
+ this.ranks.push(0);
52
+ this.sets++;
53
+ }
54
+ /** O(m) in the number of items. */
55
+ makeSets(items) {
56
+ for (const item of items) {
57
+ this.makeSet(item);
58
+ }
59
+ }
60
+ /** Whether `item` belongs to any set. O(1). */
61
+ has(item) {
62
+ return this.indices.has(item);
63
+ }
64
+ /**
65
+ * The representative of `item`'s set — the same value for every member, and
66
+ * stable until the set is merged into another.
67
+ *
68
+ * @returns The representative, or `undefined` if `item` was never added.
69
+ */
70
+ find(item) {
71
+ const index = this.indices.get(item);
72
+ return index === undefined ? undefined : this.items[this.findRoot(index)];
73
+ }
74
+ /**
75
+ * Merges the sets holding `a` and `b`. Either operand not yet known is added
76
+ * first, so building a partition from a stream of pairs needs no separate
77
+ * `makeSet` pass; isolated items still do.
78
+ *
79
+ * @returns `true` if two distinct sets were merged, `false` if `a` and `b`
80
+ * were already in the same one.
81
+ */
82
+ union(a, b) {
83
+ this.makeSet(a);
84
+ this.makeSet(b);
85
+ let rootA = this.findRoot(this.indices.get(a));
86
+ let rootB = this.findRoot(this.indices.get(b));
87
+ if (rootA === rootB) {
88
+ return false;
89
+ }
90
+ // Hang the shallower tree under the deeper one, so the result is no deeper
91
+ // than the deeper input unless the two were equal.
92
+ if (this.ranks[rootA] < this.ranks[rootB]) {
93
+ [rootA, rootB] = [rootB, rootA];
94
+ }
95
+ this.parents[rootB] = rootA;
96
+ if (this.ranks[rootA] === this.ranks[rootB]) {
97
+ this.ranks[rootA]++;
98
+ }
99
+ this.sets--;
100
+ return true;
101
+ }
102
+ /**
103
+ * Whether `a` and `b` are in the same set. A query, so an unknown item is
104
+ * simply not connected to anything rather than being added.
105
+ */
106
+ connected(a, b) {
107
+ const indexA = this.indices.get(a);
108
+ const indexB = this.indices.get(b);
109
+ if (indexA === undefined || indexB === undefined) {
110
+ return false;
111
+ }
112
+ return this.findRoot(indexA) === this.findRoot(indexB);
113
+ }
114
+ /** Each set as its own array of members, in no particular order. O(n). */
115
+ *groups() {
116
+ const groups = new Map();
117
+ for (let index = 0; index < this.items.length; index++) {
118
+ const root = this.findRoot(index);
119
+ const group = groups.get(root);
120
+ if (group === undefined) {
121
+ groups.set(root, [this.items[index]]);
122
+ }
123
+ else {
124
+ group.push(this.items[index]);
125
+ }
126
+ }
127
+ yield* groups.values();
128
+ }
129
+ findRoot(index) {
130
+ const { parents } = this;
131
+ let root = index;
132
+ while (parents[root] !== root) {
133
+ root = parents[root];
134
+ }
135
+ // Path compression, iterative: a recursive walk would blow the stack on a
136
+ // long chain, which is exactly the shape this exists to flatten.
137
+ let cursor = index;
138
+ while (parents[cursor] !== root) {
139
+ const next = parents[cursor];
140
+ parents[cursor] = root;
141
+ cursor = next;
142
+ }
143
+ return root;
144
+ }
145
+ }
146
+ //# sourceMappingURL=static-disjoint-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-disjoint-set.js","sourceRoot":"","sources":["../../src/disjoint-set/static-disjoint-set.ts"],"names":[],"mappings":"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"}