@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,45 @@
1
+ import type { DefinedValue, OrderPredicate, Predicate } from "@ac-kit/core";
2
+ import { BoundedOptions, IBounded } from "../collection/ibounded.js";
3
+ import { HeapStorage } from "../heap/iheap-storage.js";
4
+ import type { IPriorityQueue, PriorityEntry } from "./ipriority-queue.js";
5
+ export type BoundedPriorityQueueOptions<T extends DefinedValue, P> = BoundedOptions<HeapStorage<PriorityEntry<T, P>>>;
6
+ /**
7
+ * A priority queue that holds at most `capacity` items and throws once full.
8
+ *
9
+ * @template T The type of elements in the priority queue.
10
+ * @template P The type of priority associated with each element.
11
+ */
12
+ export declare class BoundedPriorityQueue<T extends DefinedValue, P = number> implements IPriorityQueue<T, P>, IBounded {
13
+ readonly precedes: OrderPredicate<P>;
14
+ private readonly inner;
15
+ readonly capacity: number;
16
+ constructor(precedes: OrderPredicate<P> | undefined, iterable: Iterable<[T, P]> | undefined, options: BoundedPriorityQueueOptions<T, P>);
17
+ [Symbol.iterator](): Iterator<T>;
18
+ clear(): void;
19
+ count(): number;
20
+ /**
21
+ * Same as `IPriorityQueue.insert`, but throws once the queue is full.
22
+ *
23
+ * @throws {CollectionCapacityExceededError} If the operation would exceed the
24
+ * queue's capacity.
25
+ * @see IPriorityQueue.insert
26
+ */
27
+ insert(priority: P, item: T): void;
28
+ /**
29
+ * Same as `IPriorityQueue.insertAll`, but throws once the queue is full.
30
+ * Nothing is inserted when it throws — the check is made against the whole
31
+ * batch.
32
+ *
33
+ * @throws {CollectionCapacityExceededError} If the operation would exceed the
34
+ * queue's capacity.
35
+ * @see IPriorityQueue.insertAll
36
+ */
37
+ insertAll(priority: P, items: readonly T[]): void;
38
+ extract(): T | undefined;
39
+ peek(): T | undefined;
40
+ setPriority(item: T, priority: P): boolean;
41
+ /** @see PriorityQueue.remove */
42
+ remove(condition: Predicate<[T, P]>): boolean;
43
+ entries(): IterableIterator<PriorityEntry<T, P>>;
44
+ }
45
+ //# sourceMappingURL=bounded-priority-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-priority-queue.d.ts","sourceRoot":"","sources":["../../src/priority-queue/bounded-priority-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAM5E,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1E,MAAM,MAAM,2BAA2B,CACtC,CAAC,SAAS,YAAY,EACtB,CAAC,IACE,cAAc,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAErD;;;;;GA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apacity, } from "../collection/_bounded.js";
2
+ import { PriorityQueue } from "./priority-queue.js";
3
+ /**
4
+ * A priority queue that holds at most `capacity` items and throws once full.
5
+ *
6
+ * @template T The type of elements in the priority queue.
7
+ * @template P The type of priority associated with each element.
8
+ */
9
+ export class BoundedPriorityQueue {
10
+ precedes;
11
+ inner;
12
+ capacity;
13
+ constructor(precedes = (a, b) => a < b, iterable, options) {
14
+ this.precedes = precedes;
15
+ const items = iterable ? Array.from(iterable) : [];
16
+ this.capacity = resolveBoundedCapacity(items.length, options);
17
+ this.inner = new PriorityQueue(precedes, items, {
18
+ storage: options.storage,
19
+ });
20
+ }
21
+ [Symbol.iterator]() {
22
+ return this.inner[Symbol.iterator]();
23
+ }
24
+ clear() {
25
+ this.inner.clear();
26
+ }
27
+ count() {
28
+ return this.inner.count();
29
+ }
30
+ /**
31
+ * Same as `IPriorityQueue.insert`, but throws once the queue is full.
32
+ *
33
+ * @throws {CollectionCapacityExceededError} If the operation would exceed the
34
+ * queue's capacity.
35
+ * @see IPriorityQueue.insert
36
+ */
37
+ insert(priority, item) {
38
+ checkCapacity(this.inner.count(), 1, this.capacity);
39
+ this.inner.insert(priority, item);
40
+ }
41
+ /**
42
+ * Same as `IPriorityQueue.insertAll`, but throws once the queue is full.
43
+ * Nothing is inserted when it throws — the check is made against the whole
44
+ * batch.
45
+ *
46
+ * @throws {CollectionCapacityExceededError} If the operation would exceed the
47
+ * queue's capacity.
48
+ * @see IPriorityQueue.insertAll
49
+ */
50
+ insertAll(priority, items) {
51
+ checkCapacity(this.inner.count(), items.length, this.capacity);
52
+ this.inner.insertAll(priority, items);
53
+ }
54
+ extract() {
55
+ return this.inner.extract();
56
+ }
57
+ peek() {
58
+ return this.inner.peek();
59
+ }
60
+ setPriority(item, priority) {
61
+ return this.inner.setPriority(item, priority);
62
+ }
63
+ /** @see PriorityQueue.remove */
64
+ remove(condition) {
65
+ return this.inner.remove(condition);
66
+ }
67
+ entries() {
68
+ return this.inner.entries();
69
+ }
70
+ }
71
+ //# sourceMappingURL=bounded-priority-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-priority-queue.js","sourceRoot":"","sources":["../../src/priority-queue/bounded-priority-queue.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,aAAa,EACb,sBAAsB,GACtB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD;;;;;GAKG;AACH,MAAM,OAAO,oBAAoB;IAOtB,QAAQ;IAJD,KAAK,CAAsB;IACnC,QAAQ,CAAS;IAE1B,YACU,QAAQ,GAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EACtD,QAAsC,EACtC,OAA0C;wBAFjC,QAAQ;QAIjB,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAEnD,IAAI,CAAC,QAAQ,GAAG,sBAAsB,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9D,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAO,QAAQ,EAAE,KAAK,EAAE;YACrD,OAAO,EAAE,OAAO,CAAC,OAAO;SACxB,CAAC,CAAC;IACJ,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACtC,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IAED,KAAK;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,QAAW,EAAE,IAAO;QAC1B,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEpD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAW,EAAE,KAAmB;QACzC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE/D,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,OAAO;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;IAED,WAAW,CAAC,IAAO,EAAE,QAAW;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED,gCAAgC;IAChC,MAAM,CAAC,SAA4B;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAED,OAAO;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACD"}
@@ -0,0 +1,9 @@
1
+ import { DefinedValue } from "@ac-kit/core";
2
+ import { ILossy } from "../collection/ilossy.js";
3
+ import { IAsyncPriorityQueue } from "./iasync-priority-queue.js";
4
+ /** The async-backed sibling of {@link ILossyPriorityQueue}. */
5
+ export interface IAsyncLossyPriorityQueue<T extends DefinedValue = DefinedValue, P = number> extends Omit<IAsyncPriorityQueue<T, P>, "insert" | "insertAll">, ILossy {
6
+ insert(priority: P, item: T, signal?: AbortSignal): Promise<readonly T[]>;
7
+ insertAll(priority: P, items: Iterable<T>, signal?: AbortSignal): Promise<readonly T[]>;
8
+ }
9
+ //# sourceMappingURL=iasync-lossy-priority-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iasync-lossy-priority-queue.d.ts","sourceRoot":"","sources":["../../src/priority-queue/iasync-lossy-priority-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,+DAA+D;AAC/D,MAAM,WAAW,wBAAwB,CACxC,CAAC,SAAS,YAAY,GAAG,YAAY,EACrC,CAAC,GAAG,MAAM,CAEV,SAAQ,IAAI,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC,EAAE,MAAM;IACvE,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAE1E,SAAS,CACR,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;CACzB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=iasync-lossy-priority-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iasync-lossy-priority-queue.js","sourceRoot":"","sources":["../../src/priority-queue/iasync-lossy-priority-queue.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import { DefinedValue, OrderPredicate } from "@ac-kit/core";
2
+ import { IAsyncCollection } from "../collection/iasync-collection.js";
3
+ import { PriorityEntry } from "./ipriority-queue.js";
4
+ /**
5
+ * The async-backed sibling of {@link IPriorityQueue}. No
6
+ * `IAsyncBlockingPriorityQueue`: every async-backed method already returns a
7
+ * `Promise`, so the sync world's "throw vs. await" split collapses to one
8
+ * `Promise<void>` shape — a separate blocking sibling would be a redundant,
9
+ * identical type. `precedes` stays synchronous: a pure ordering function over
10
+ * values the caller already holds, not I/O.
11
+ */
12
+ export interface IAsyncPriorityQueue<T extends DefinedValue = DefinedValue, P = number> extends IAsyncCollection<T> {
13
+ readonly precedes: OrderPredicate<P>;
14
+ insert(priority: P, item: T, signal?: AbortSignal): Promise<void>;
15
+ insertAll(priority: P, items: Iterable<T>, signal?: AbortSignal): Promise<void>;
16
+ extract(signal?: AbortSignal): Promise<T | undefined>;
17
+ peek(signal?: AbortSignal): Promise<T | undefined>;
18
+ setPriority(item: T, priority: P, signal?: AbortSignal): Promise<boolean>;
19
+ entries(signal?: AbortSignal): AsyncIterableIterator<PriorityEntry<T, P>>;
20
+ }
21
+ //# sourceMappingURL=iasync-priority-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iasync-priority-queue.d.ts","sourceRoot":"","sources":["../../src/priority-queue/iasync-priority-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB,CACnC,CAAC,SAAS,YAAY,GAAG,YAAY,EACrC,CAAC,GAAG,MAAM,CACT,SAAQ,gBAAgB,CAAC,CAAC,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAErC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElE,SAAS,CACR,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAEtD,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAEnD,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE1E,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CAC1E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=iasync-priority-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iasync-priority-queue.js","sourceRoot":"","sources":["../../src/priority-queue/iasync-priority-queue.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import { DefinedValue } from "@ac-kit/core";
2
+ import { ILossy } from "../collection/ilossy.js";
3
+ import { IPriorityQueue } from "./ipriority-queue.js";
4
+ /**
5
+ * The lossy sibling of {@link IPriorityQueue}: never throws or waits when a
6
+ * bounded priority queue is full, evicting or skipping instead
7
+ * (`overflowPolicy`).
8
+ *
9
+ * `"evict"` drops the root — the same element `extract`/`peek` already expose.
10
+ * To keep the N highest-priority items instead, construct with the inverse
11
+ * ordering.
12
+ */
13
+ export interface ILossyPriorityQueue<T extends DefinedValue = DefinedValue, P = number> extends IPriorityQueue<T, P>, ILossy {
14
+ /**
15
+ * Same as `IPriorityQueue.insert`, but never throws — returns the items
16
+ * dropped to make room (empty if nothing was dropped).
17
+ *
18
+ * @see IPriorityQueue.insert
19
+ */
20
+ insert(priority: P, item: T): readonly T[];
21
+ /**
22
+ * Same as `IPriorityQueue.insertAll`, but never throws — returns the items
23
+ * dropped to make room (empty if nothing was dropped).
24
+ *
25
+ * @see IPriorityQueue.insertAll
26
+ */
27
+ insertAll(priority: P, items: readonly T[]): readonly T[];
28
+ }
29
+ //# sourceMappingURL=ilossy-priority-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ilossy-priority-queue.d.ts","sourceRoot":"","sources":["../../src/priority-queue/ilossy-priority-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB,CACnC,CAAC,SAAS,YAAY,GAAG,YAAY,EACrC,CAAC,GAAG,MAAM,CAEV,SAAQ,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM;IACpC;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;IAE3C;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC;CAC1D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ilossy-priority-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ilossy-priority-queue.js","sourceRoot":"","sources":["../../src/priority-queue/ilossy-priority-queue.ts"],"names":[],"mappings":""}
@@ -0,0 +1,71 @@
1
+ import type { DefinedValue, OrderPredicate } from "@ac-kit/core";
2
+ import { ICollection } from "../collection/icollection.js";
3
+ /** A value paired with the priority it was inserted with. */
4
+ export interface PriorityEntry<T, P> {
5
+ readonly value: T;
6
+ readonly priority: P;
7
+ }
8
+ /**
9
+ * Interface representing a priority queue data type.
10
+ *
11
+ * A priority queue is a collection where each item has a priority associated
12
+ * with it. Items with higher priority are served before items with lower
13
+ * priority.
14
+ *
15
+ * `ICollection<T>`, not `ICollection<[T, P]>` — the priority is part of the
16
+ * ordering, not of the element type. Iteration order is heap order, not
17
+ * priority order; `entries()` is the priority-ordered, priority-carrying read.
18
+ *
19
+ * @template T The type of elements in the priority queue. Anything except
20
+ * `undefined`, which means "no element".
21
+ * @template P The type of priority values.
22
+ */
23
+ export interface IPriorityQueue<T extends DefinedValue = DefinedValue, P = number> extends ICollection<T> {
24
+ /**
25
+ * Strict weak ordering over priorities: `precedes(a, b)` means `a` outranks
26
+ * `b`.
27
+ */
28
+ readonly precedes: OrderPredicate<P>;
29
+ /**
30
+ * Inserts an item with its associated priority into the priority queue.
31
+ *
32
+ * @param priority The priority of the item to insert.
33
+ * @param item The item to insert.
34
+ */
35
+ insert(priority: P, item: T): void;
36
+ /**
37
+ * Inserts every item at the same priority into the priority queue.
38
+ *
39
+ * @param priority The priority shared by all the items to insert.
40
+ * @param items The items to insert.
41
+ */
42
+ insertAll(priority: P, items: readonly T[]): void;
43
+ /**
44
+ * Removes and returns the item with the highest priority from the priority
45
+ * queue.
46
+ *
47
+ * @returns The item with the highest priority, or `undefined` if the queue is
48
+ * empty.
49
+ */
50
+ extract(): T | undefined;
51
+ /**
52
+ * Returns the item with the highest priority without removing it from the
53
+ * queue.
54
+ *
55
+ * @returns The item with the highest priority, or `undefined` if the queue is
56
+ * empty.
57
+ */
58
+ peek(): T | undefined;
59
+ /**
60
+ * Updates the priority of an existing item in the priority queue.
61
+ *
62
+ * @param item The item whose priority is to be updated.
63
+ * @param priority The new priority of the item.
64
+ * @returns `true` if the item was found and its priority updated, `false`
65
+ * otherwise.
66
+ */
67
+ setPriority(item: T, priority: P): boolean;
68
+ /** Every entry, in priority order (highest first). */
69
+ entries(): IterableIterator<PriorityEntry<T, P>>;
70
+ }
71
+ //# sourceMappingURL=ipriority-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ipriority-queue.d.ts","sourceRoot":"","sources":["../../src/priority-queue/ipriority-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,6DAA6D;AAC7D,MAAM,WAAW,aAAa,CAAC,CAAC,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;CACrB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,cAAc,CAC9B,CAAC,SAAS,YAAY,GAAG,YAAY,EACrC,CAAC,GAAG,MAAM,CACT,SAAQ,WAAW,CAAC,CAAC,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAErC;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IAEnC;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC;IAElD;;;;;;OAMG;IACH,OAAO,IAAI,CAAC,GAAG,SAAS,CAAC;IAEzB;;;;;;OAMG;IACH,IAAI,IAAI,CAAC,GAAG,SAAS,CAAC;IAEtB;;;;;;;OAOG;IACH,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC;IAE3C,sDAAsD;IACtD,OAAO,IAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CACjD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ipriority-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ipriority-queue.js","sourceRoot":"","sources":["../../src/priority-queue/ipriority-queue.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import { DefinedValue } from "@ac-kit/core";
2
+ import { IBounded } from "../collection/ibounded.js";
3
+ import { IPriorityQueue } from "./ipriority-queue.js";
4
+ /**
5
+ * The blocking sibling of {@link IBoundedPriorityQueue}: waits for capacity
6
+ * instead of throwing when the queue is full. The inherited `insert` still
7
+ * throws — this adds a way to wait, it does not change the way to fail.
8
+ */
9
+ export interface IWaitablePriorityQueue<T extends DefinedValue = DefinedValue, P = number> extends IPriorityQueue<T, P>, IBounded {
10
+ /**
11
+ * Same as `insert`, but waits for capacity if the operation would exceed it.
12
+ *
13
+ * @param signal Optional abort signal to cancel the operation.
14
+ * @see IPriorityQueue.insert
15
+ */
16
+ waitInsert(priority: P, item: T, signal?: AbortSignal | null): Promise<void>;
17
+ /**
18
+ * Same as `insertAll`, 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 IPriorityQueue.insertAll
24
+ */
25
+ waitInsertAll(priority: P, items: Iterable<T>, signal?: AbortSignal | null): Promise<void>;
26
+ }
27
+ //# sourceMappingURL=iwaitable-priority-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iwaitable-priority-queue.d.ts","sourceRoot":"","sources":["../../src/priority-queue/iwaitable-priority-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,sBAAsB,CACtC,CAAC,SAAS,YAAY,GAAG,YAAY,EACrC,CAAC,GAAG,MAAM,CAEV,SAAQ,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ;IACtC;;;;;OAKG;IACH,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7E;;;;;;;OAOG;IACH,aAAa,CACZ,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GACzB,OAAO,CAAC,IAAI,CAAC,CAAC;CACjB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=iwaitable-priority-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iwaitable-priority-queue.js","sourceRoot":"","sources":["../../src/priority-queue/iwaitable-priority-queue.ts"],"names":[],"mappings":""}
@@ -0,0 +1,49 @@
1
+ import type { DefinedValue, OrderPredicate, Predicate } from "@ac-kit/core";
2
+ import { HeapStorage } from "../heap/iheap-storage.js";
3
+ import { IPriorityQueue, PriorityEntry } from "./ipriority-queue.js";
4
+ export type PriorityQueueOptions<T extends DefinedValue, P> = {
5
+ storage?: HeapStorage<PriorityEntry<T, P>>;
6
+ };
7
+ /**
8
+ * An unbounded priority queue.
9
+ *
10
+ * For a capacity, use `BoundedPriorityQueue` (throws when full) or
11
+ * `BlockingPriorityQueue` (waits).
12
+ *
13
+ * @template T The type of elements in the priority queue.
14
+ * @template P The type of priority associated with each element.
15
+ */
16
+ export declare class PriorityQueue<T extends DefinedValue, P = number> implements IPriorityQueue<T, P> {
17
+ readonly precedes: OrderPredicate<P>;
18
+ private readonly storage;
19
+ private readonly entryPrecedes;
20
+ constructor(precedes?: OrderPredicate<P>, iterable?: Iterable<[T, P]>, options?: PriorityQueueOptions<T, P>);
21
+ [Symbol.iterator](): Iterator<T>;
22
+ clear(): void;
23
+ count(): number;
24
+ insert(priority: P, value: T): void;
25
+ insertAll(priority: P, items: readonly T[]): void;
26
+ extract(): T | undefined;
27
+ peek(): T | undefined;
28
+ setPriority(item: T, priority: P): boolean;
29
+ /**
30
+ * Removes the first entry matching `condition`, restoring the heap property
31
+ * afterward.
32
+ *
33
+ * Not part of `IPriorityQueue` — reaching into the middle of a priority queue
34
+ * by value is a real, occasionally needed capability (e.g. unregistering a
35
+ * previously inserted handler), but not one every consumer needs, matching
36
+ * the extra `removeFirst`-style surface the list classes carry beyond their
37
+ * own slim interfaces.
38
+ *
39
+ * @param condition A predicate over an entry's value and priority.
40
+ * @returns `true` if a matching entry was found and removed.
41
+ */
42
+ remove(condition: Predicate<[T, P]>): boolean;
43
+ /**
44
+ * Drains a copy of the heap in priority order, leaving this queue untouched —
45
+ * the storage's own iteration order is heap order, not priority order.
46
+ */
47
+ entries(): IterableIterator<PriorityEntry<T, P>>;
48
+ }
49
+ //# sourceMappingURL=priority-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priority-queue.d.ts","sourceRoot":"","sources":["../../src/priority-queue/priority-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG5E,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErE,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,IAAI;IAC7D,OAAO,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,aAAa,CACzB,CAAC,SAAS,YAAY,EACtB,CAAC,GAAG,MAAM,CACT,YAAW,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;IAK/B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;IAJrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmC;IAC3D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAsC;IAEpE,YACU,QAAQ,GAAE,cAAc,CAAC,CAAC,CAAmB,EACtD,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,EAYpC;IAEA,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAIhC;IAED,KAAK,IAAI,IAAI,CAEZ;IAED,KAAK,IAAI,MAAM,CAEd;IAED,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAGlC;IAED,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAKhD;IAED,OAAO,IAAI,CAAC,GAAG,SAAS,CAgBvB;IAED,IAAI,IAAI,CAAC,GAAG,SAAS,CAEpB;IAED,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAwBzC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CA0B5C;IAED;;;OAGG;IACF,OAAO,IAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAiBhD;CACD"}
@@ -0,0 +1,134 @@
1
+ import { heapifyAll, heapifyDown, heapifyUp } from "../heap/_array-heap.js";
2
+ import { RingVector } from "../storage/ring-vector.js";
3
+ /**
4
+ * An unbounded priority queue.
5
+ *
6
+ * For a capacity, use `BoundedPriorityQueue` (throws when full) or
7
+ * `BlockingPriorityQueue` (waits).
8
+ *
9
+ * @template T The type of elements in the priority queue.
10
+ * @template P The type of priority associated with each element.
11
+ */
12
+ export class PriorityQueue {
13
+ precedes;
14
+ storage;
15
+ entryPrecedes;
16
+ constructor(precedes = (a, b) => a < b, iterable, options) {
17
+ this.precedes = precedes;
18
+ this.entryPrecedes = (a, b) => this.precedes(a.priority, b.priority);
19
+ this.storage = options?.storage ?? new RingVector();
20
+ if (iterable) {
21
+ for (const [value, priority] of iterable) {
22
+ this.storage.pushBack({ value, priority });
23
+ }
24
+ }
25
+ heapifyAll(this.storage, this.entryPrecedes);
26
+ }
27
+ *[Symbol.iterator]() {
28
+ for (const entry of this.storage) {
29
+ yield entry.value;
30
+ }
31
+ }
32
+ clear() {
33
+ this.storage.clear();
34
+ }
35
+ count() {
36
+ return this.storage.count();
37
+ }
38
+ insert(priority, value) {
39
+ this.storage.pushBack({ value, priority });
40
+ heapifyUp(this.storage, this.storage.count() - 1, this.entryPrecedes);
41
+ }
42
+ insertAll(priority, items) {
43
+ for (let index = 0; index < items.length; index++) {
44
+ this.storage.pushBack({ value: items[index], priority });
45
+ heapifyUp(this.storage, this.storage.count() - 1, this.entryPrecedes);
46
+ }
47
+ }
48
+ extract() {
49
+ const count = this.storage.count();
50
+ if (count === 0) {
51
+ return undefined;
52
+ }
53
+ if (count === 1) {
54
+ return this.storage.popBack()?.value;
55
+ }
56
+ const root = this.storage.get(0);
57
+ const last = this.storage.popBack();
58
+ this.storage.set(0, last);
59
+ heapifyDown(this.storage, 0, this.storage.count(), this.entryPrecedes);
60
+ return root?.value;
61
+ }
62
+ peek() {
63
+ return this.storage.get(0)?.value;
64
+ }
65
+ setPriority(item, priority) {
66
+ for (let index = 0; index < this.storage.count(); index++) {
67
+ const entry = this.storage.get(index);
68
+ if (entry !== undefined && entry.value === item) {
69
+ const previousPriority = entry.priority;
70
+ this.storage.set(index, { value: item, priority });
71
+ if (this.precedes(priority, previousPriority)) {
72
+ heapifyUp(this.storage, index, this.entryPrecedes);
73
+ }
74
+ else {
75
+ heapifyDown(this.storage, index, this.storage.count(), this.entryPrecedes);
76
+ }
77
+ return true;
78
+ }
79
+ }
80
+ return false;
81
+ }
82
+ /**
83
+ * Removes the first entry matching `condition`, restoring the heap property
84
+ * afterward.
85
+ *
86
+ * Not part of `IPriorityQueue` — reaching into the middle of a priority queue
87
+ * by value is a real, occasionally needed capability (e.g. unregistering a
88
+ * previously inserted handler), but not one every consumer needs, matching
89
+ * the extra `removeFirst`-style surface the list classes carry beyond their
90
+ * own slim interfaces.
91
+ *
92
+ * @param condition A predicate over an entry's value and priority.
93
+ * @returns `true` if a matching entry was found and removed.
94
+ */
95
+ remove(condition) {
96
+ for (let index = 0; index < this.storage.count(); index++) {
97
+ const entry = this.storage.get(index);
98
+ if (entry !== undefined && condition(entry.value, entry.priority)) {
99
+ const lastIndex = this.storage.count() - 1;
100
+ if (index === lastIndex) {
101
+ this.storage.popBack();
102
+ }
103
+ else {
104
+ const last = this.storage.popBack();
105
+ this.storage.set(index, last);
106
+ heapifyDown(this.storage, index, this.storage.count(), this.entryPrecedes);
107
+ heapifyUp(this.storage, index, this.entryPrecedes);
108
+ }
109
+ return true;
110
+ }
111
+ }
112
+ return false;
113
+ }
114
+ /**
115
+ * Drains a copy of the heap in priority order, leaving this queue untouched —
116
+ * the storage's own iteration order is heap order, not priority order.
117
+ */
118
+ *entries() {
119
+ const drain = new RingVector(this.storage);
120
+ while (drain.count() > 0) {
121
+ const count = drain.count();
122
+ if (count === 1) {
123
+ yield drain.popBack();
124
+ break;
125
+ }
126
+ const root = drain.get(0);
127
+ const last = drain.popBack();
128
+ drain.set(0, last);
129
+ heapifyDown(drain, 0, drain.count(), this.entryPrecedes);
130
+ yield root;
131
+ }
132
+ }
133
+ }
134
+ //# sourceMappingURL=priority-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priority-queue.js","sourceRoot":"","sources":["../../src/priority-queue/priority-queue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE5E,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAOvD;;;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K,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YACzD,MAAM,IAAI,CAAC;QACZ,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,92 @@
1
+ import type { Hash32 } from "./hash32.js";
2
+ export type BloomFilterOptions<T> = {
3
+ /** See {@link Hash32}: required, and why it cannot be defaulted. */
4
+ hash: Hash32<T>;
5
+ /** How many items the filter is sized for. */
6
+ expectedItems: number;
7
+ /**
8
+ * The false-positive probability to size for, at `expectedItems`. Defaults to
9
+ * `0.01` (1%). Must be in `(0, 1)`.
10
+ */
11
+ falsePositiveRate?: number;
12
+ };
13
+ /**
14
+ * Approximate set membership in a fraction of the space an exact set needs.
15
+ *
16
+ * `has` has **no false negatives and does have false positives**: "no" is
17
+ * certain, "yes" means "probably". That asymmetry is the whole point — it makes
18
+ * a Bloom filter a safe front door for an expensive exact lookup, never a
19
+ * replacement for one.
20
+ *
21
+ * There is no `delete`: clearing a bit would clear it for every other item that
22
+ * happens to hash onto it, turning "no false negatives" into a lie. Use
23
+ * `CuckooFilter` when deletion is needed.
24
+ *
25
+ * Sizing follows the standard derivation from `expectedItems` (n) and
26
+ * `falsePositiveRate` (p): `m = ceil(-n·ln p / (ln 2)²)` bits and `k =
27
+ * round((m/n)·ln 2)` hashes, which is the k that minimises p for that m.
28
+ * Exceeding `expectedItems` does not break the filter, it just raises the real
29
+ * false-positive rate above the one asked for — `estimatedFalsePositiveRate()`
30
+ * reports where it actually stands.
31
+ *
32
+ * The `k` hashes come from two calls to the caller's `hash` combined as `h1 +
33
+ * i·h2` (Kirsch–Mitzenmacher), which is proven to cost nothing in accuracy
34
+ * versus `k` independent hashes.
35
+ *
36
+ * Time complexity: O(k) for `add` and `has`, independent of how many items are
37
+ * held. Space: `m` bits regardless of item size.
38
+ *
39
+ * @template T The item type.
40
+ */
41
+ export declare class BloomFilter<T> {
42
+ private readonly words;
43
+ private readonly hash;
44
+ private added;
45
+ /** Bits in the filter. */
46
+ readonly bitCount: number;
47
+ /** Hashes per operation. */
48
+ readonly hashCount: number;
49
+ constructor(iterable: Iterable<T> | undefined, options: BloomFilterOptions<T>);
50
+ /**
51
+ * How many times `add` was called with an item not already certainly present.
52
+ * An estimate of the set's size, not an exact count.
53
+ */
54
+ count(): number;
55
+ clear(): void;
56
+ /** O(k), with exactly two hash calls regardless of k. */
57
+ add(item: T): void;
58
+ /** O(m·k) in the number of items. */
59
+ addAll(items: Iterable<T>): void;
60
+ /**
61
+ * O(k), with exactly two hash calls regardless of k.
62
+ *
63
+ * @returns `false` means the item is **definitely** absent. `true` means it
64
+ * is probably present — see `estimatedFalsePositiveRate`.
65
+ */
66
+ has(item: T): boolean;
67
+ /**
68
+ * The false-positive probability at the filter's current fill, from the
69
+ * fraction of bits actually set: `(setBits / bitCount) ^ hashCount`.
70
+ *
71
+ * Measured rather than assumed, so it stays honest after more items were
72
+ * added than the filter was sized for. O(bitCount / 32).
73
+ */
74
+ estimatedFalsePositiveRate(): number;
75
+ /**
76
+ * Folds `other` into this filter, so it holds the union of both item sets.
77
+ *
78
+ * Merging is exact — the union of two Bloom filters is the Bloom filter of
79
+ * the union — which is what makes these usable across partitions.
80
+ *
81
+ * @throws {RangeError} If the two filters were not sized identically. Bitwise
82
+ * union is only meaningful between filters with the same geometry.
83
+ */
84
+ merge(other: BloomFilter<T>): void;
85
+ /**
86
+ * Kirsch-Mitzenmacher: two hashes generate k indices with no measurable loss
87
+ * against k independent ones. Both are hoisted by the callers, so a k-hash
88
+ * filter still costs two calls to the caller's `hash`, not 2k.
89
+ */
90
+ private bitAt;
91
+ }
92
+ //# sourceMappingURL=bloom-filter.d.ts.map