@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.
- package/LICENSE +28 -0
- package/README.md +75 -0
- package/dist/bit/bit-set.d.ts +84 -0
- package/dist/bit/bit-set.d.ts.map +1 -0
- package/dist/bit/bit-set.js +206 -0
- package/dist/bit/bit-set.js.map +1 -0
- package/dist/bit/bit-vector.d.ts +69 -0
- package/dist/bit/bit-vector.d.ts.map +1 -0
- package/dist/bit/bit-vector.js +172 -0
- package/dist/bit/bit-vector.js.map +1 -0
- package/dist/cache/_lru-store.d.ts +37 -0
- package/dist/cache/_lru-store.d.ts.map +1 -0
- package/dist/cache/_lru-store.js +137 -0
- package/dist/cache/_lru-store.js.map +1 -0
- package/dist/cache/lru-cache.d.ts +90 -0
- package/dist/cache/lru-cache.d.ts.map +1 -0
- package/dist/cache/lru-cache.js +143 -0
- package/dist/cache/lru-cache.js.map +1 -0
- package/dist/cache/lru-map.d.ts +72 -0
- package/dist/cache/lru-map.d.ts.map +1 -0
- package/dist/cache/lru-map.js +100 -0
- package/dist/cache/lru-map.js.map +1 -0
- package/dist/collection/_bounded.d.ts +27 -0
- package/dist/collection/_bounded.d.ts.map +1 -0
- package/dist/collection/_bounded.js +48 -0
- package/dist/collection/_bounded.js.map +1 -0
- package/dist/collection/_capacity-semaphore.d.ts +31 -0
- package/dist/collection/_capacity-semaphore.d.ts.map +1 -0
- package/dist/collection/_capacity-semaphore.js +94 -0
- package/dist/collection/_capacity-semaphore.js.map +1 -0
- package/dist/collection/iasync-collection.d.ts +16 -0
- package/dist/collection/iasync-collection.d.ts.map +1 -0
- package/dist/collection/iasync-collection.js +13 -0
- package/dist/collection/iasync-collection.js.map +1 -0
- package/dist/collection/iasync-searchable.d.ts +9 -0
- package/dist/collection/iasync-searchable.d.ts.map +1 -0
- package/dist/collection/iasync-searchable.js +2 -0
- package/dist/collection/iasync-searchable.js.map +1 -0
- package/dist/collection/ibounded.d.ts +36 -0
- package/dist/collection/ibounded.d.ts.map +1 -0
- package/dist/collection/ibounded.js +8 -0
- package/dist/collection/ibounded.js.map +1 -0
- package/dist/collection/icollection.d.ts +24 -0
- package/dist/collection/icollection.d.ts.map +1 -0
- package/dist/collection/icollection.js +2 -0
- package/dist/collection/icollection.js.map +1 -0
- package/dist/collection/ilossy.d.ts +20 -0
- package/dist/collection/ilossy.d.ts.map +1 -0
- package/dist/collection/ilossy.js +2 -0
- package/dist/collection/ilossy.js.map +1 -0
- package/dist/collection/ireplacing.d.ts +25 -0
- package/dist/collection/ireplacing.d.ts.map +1 -0
- package/dist/collection/ireplacing.js +2 -0
- package/dist/collection/ireplacing.js.map +1 -0
- package/dist/collection/isearchable.d.ts +36 -0
- package/dist/collection/isearchable.d.ts.map +1 -0
- package/dist/collection/isearchable.js +2 -0
- package/dist/collection/isearchable.js.map +1 -0
- package/dist/cursor/ibidirectional-cursor-sequence.d.ts +30 -0
- package/dist/cursor/ibidirectional-cursor-sequence.d.ts.map +1 -0
- package/dist/cursor/ibidirectional-cursor-sequence.js +2 -0
- package/dist/cursor/ibidirectional-cursor-sequence.js.map +1 -0
- package/dist/cursor/ibidirectional-cursor.d.ts +13 -0
- package/dist/cursor/ibidirectional-cursor.d.ts.map +1 -0
- package/dist/cursor/ibidirectional-cursor.js +2 -0
- package/dist/cursor/ibidirectional-cursor.js.map +1 -0
- package/dist/cursor/icursor-sequence.d.ts +48 -0
- package/dist/cursor/icursor-sequence.d.ts.map +1 -0
- package/dist/cursor/icursor-sequence.js +2 -0
- package/dist/cursor/icursor-sequence.js.map +1 -0
- package/dist/cursor/icursor.d.ts +27 -0
- package/dist/cursor/icursor.d.ts.map +1 -0
- package/dist/cursor/icursor.js +2 -0
- package/dist/cursor/icursor.js.map +1 -0
- package/dist/cursor/index-cursor-sequence.d.ts +57 -0
- package/dist/cursor/index-cursor-sequence.d.ts.map +1 -0
- package/dist/cursor/index-cursor-sequence.js +181 -0
- package/dist/cursor/index-cursor-sequence.js.map +1 -0
- package/dist/cursor/irandom-access-cursor.d.ts +16 -0
- package/dist/cursor/irandom-access-cursor.d.ts.map +1 -0
- package/dist/cursor/irandom-access-cursor.js +2 -0
- package/dist/cursor/irandom-access-cursor.js.map +1 -0
- package/dist/deque/blocking-deque.d.ts +36 -0
- package/dist/deque/blocking-deque.d.ts.map +1 -0
- package/dist/deque/blocking-deque.js +101 -0
- package/dist/deque/blocking-deque.js.map +1 -0
- package/dist/deque/bounded-deque.d.ts +58 -0
- package/dist/deque/bounded-deque.d.ts.map +1 -0
- package/dist/deque/bounded-deque.js +103 -0
- package/dist/deque/bounded-deque.js.map +1 -0
- package/dist/deque/deque.d.ts +35 -0
- package/dist/deque/deque.d.ts.map +1 -0
- package/dist/deque/deque.js +62 -0
- package/dist/deque/deque.js.map +1 -0
- package/dist/deque/iasync-deque.d.ts +19 -0
- package/dist/deque/iasync-deque.d.ts.map +1 -0
- package/dist/deque/iasync-deque.js +2 -0
- package/dist/deque/iasync-deque.js.map +1 -0
- package/dist/deque/iasync-lossy-deque.d.ts +11 -0
- package/dist/deque/iasync-lossy-deque.d.ts.map +1 -0
- package/dist/deque/iasync-lossy-deque.js +2 -0
- package/dist/deque/iasync-lossy-deque.js.map +1 -0
- package/dist/deque/ideque-storage.d.ts +6 -0
- package/dist/deque/ideque-storage.d.ts.map +1 -0
- package/dist/deque/ideque-storage.js +2 -0
- package/dist/deque/ideque-storage.js.map +1 -0
- package/dist/deque/ideque.d.ts +72 -0
- package/dist/deque/ideque.d.ts.map +1 -0
- package/dist/deque/ideque.js +2 -0
- package/dist/deque/ideque.js.map +1 -0
- package/dist/deque/ilossy-deque.d.ts +42 -0
- package/dist/deque/ilossy-deque.d.ts.map +1 -0
- package/dist/deque/ilossy-deque.js +2 -0
- package/dist/deque/ilossy-deque.js.map +1 -0
- package/dist/deque/iwaitable-deque.d.ts +42 -0
- package/dist/deque/iwaitable-deque.d.ts.map +1 -0
- package/dist/deque/iwaitable-deque.js +2 -0
- package/dist/deque/iwaitable-deque.js.map +1 -0
- package/dist/disjoint-set/iasync-disjoint-set.d.ts +11 -0
- package/dist/disjoint-set/iasync-disjoint-set.d.ts.map +1 -0
- package/dist/disjoint-set/iasync-disjoint-set.js +2 -0
- package/dist/disjoint-set/iasync-disjoint-set.js.map +1 -0
- package/dist/disjoint-set/idisjoint-set.d.ts +11 -0
- package/dist/disjoint-set/idisjoint-set.d.ts.map +1 -0
- package/dist/disjoint-set/idisjoint-set.js +2 -0
- package/dist/disjoint-set/idisjoint-set.js.map +1 -0
- package/dist/disjoint-set/static-disjoint-set.d.ts +67 -0
- package/dist/disjoint-set/static-disjoint-set.d.ts.map +1 -0
- package/dist/disjoint-set/static-disjoint-set.js +146 -0
- package/dist/disjoint-set/static-disjoint-set.js.map +1 -0
- package/dist/fuzzy/fuzzy-map.d.ts +62 -0
- package/dist/fuzzy/fuzzy-map.d.ts.map +1 -0
- package/dist/fuzzy/fuzzy-map.js +91 -0
- package/dist/fuzzy/fuzzy-map.js.map +1 -0
- package/dist/fuzzy/fuzzy-multi-map.d.ts +62 -0
- package/dist/fuzzy/fuzzy-multi-map.d.ts.map +1 -0
- package/dist/fuzzy/fuzzy-multi-map.js +143 -0
- package/dist/fuzzy/fuzzy-multi-map.js.map +1 -0
- package/dist/graph/directed-graph.d.ts +78 -0
- package/dist/graph/directed-graph.d.ts.map +1 -0
- package/dist/graph/directed-graph.js +165 -0
- package/dist/graph/directed-graph.js.map +1 -0
- package/dist/graph/graph.d.ts +73 -0
- package/dist/graph/graph.d.ts.map +1 -0
- package/dist/graph/graph.js +145 -0
- package/dist/graph/graph.js.map +1 -0
- package/dist/graph/iasync-directed-graph.d.ts +10 -0
- package/dist/graph/iasync-directed-graph.d.ts.map +1 -0
- package/dist/graph/iasync-directed-graph.js +2 -0
- package/dist/graph/iasync-directed-graph.js.map +1 -0
- package/dist/graph/iasync-graph.d.ts +19 -0
- package/dist/graph/iasync-graph.d.ts.map +1 -0
- package/dist/graph/iasync-graph.js +2 -0
- package/dist/graph/iasync-graph.js.map +1 -0
- package/dist/graph/idirected-graph.d.ts +10 -0
- package/dist/graph/idirected-graph.d.ts.map +1 -0
- package/dist/graph/idirected-graph.js +2 -0
- package/dist/graph/idirected-graph.js.map +1 -0
- package/dist/graph/igraph.d.ts +25 -0
- package/dist/graph/igraph.d.ts.map +1 -0
- package/dist/graph/igraph.js +2 -0
- package/dist/graph/igraph.js.map +1 -0
- package/dist/heap/_array-heap.d.ts +12 -0
- package/dist/heap/_array-heap.d.ts.map +1 -0
- package/dist/heap/_array-heap.js +74 -0
- package/dist/heap/_array-heap.js.map +1 -0
- package/dist/heap/binary-heap.d.ts +29 -0
- package/dist/heap/binary-heap.d.ts.map +1 -0
- package/dist/heap/binary-heap.js +83 -0
- package/dist/heap/binary-heap.js.map +1 -0
- package/dist/heap/blocking-binary-heap.d.ts +34 -0
- package/dist/heap/blocking-binary-heap.d.ts.map +1 -0
- package/dist/heap/blocking-binary-heap.js +84 -0
- package/dist/heap/blocking-binary-heap.js.map +1 -0
- package/dist/heap/bounded-binary-heap.d.ts +42 -0
- package/dist/heap/bounded-binary-heap.d.ts.map +1 -0
- package/dist/heap/bounded-binary-heap.js +71 -0
- package/dist/heap/bounded-binary-heap.js.map +1 -0
- package/dist/heap/iasync-heap.d.ts +19 -0
- package/dist/heap/iasync-heap.d.ts.map +1 -0
- package/dist/heap/iasync-heap.js +2 -0
- package/dist/heap/iasync-heap.js.map +1 -0
- package/dist/heap/iasync-lossy-heap.d.ts +9 -0
- package/dist/heap/iasync-lossy-heap.d.ts.map +1 -0
- package/dist/heap/iasync-lossy-heap.js +2 -0
- package/dist/heap/iasync-lossy-heap.js.map +1 -0
- package/dist/heap/iheap-storage.d.ts +5 -0
- package/dist/heap/iheap-storage.d.ts.map +1 -0
- package/dist/heap/iheap-storage.js +2 -0
- package/dist/heap/iheap-storage.js.map +1 -0
- package/dist/heap/iheap.d.ts +51 -0
- package/dist/heap/iheap.d.ts.map +1 -0
- package/dist/heap/iheap.js +2 -0
- package/dist/heap/iheap.js.map +1 -0
- package/dist/heap/ilossy-heap.d.ts +28 -0
- package/dist/heap/ilossy-heap.d.ts.map +1 -0
- package/dist/heap/ilossy-heap.js +2 -0
- package/dist/heap/ilossy-heap.js.map +1 -0
- package/dist/heap/iwaitable-heap.d.ts +27 -0
- package/dist/heap/iwaitable-heap.d.ts.map +1 -0
- package/dist/heap/iwaitable-heap.js +2 -0
- package/dist/heap/iwaitable-heap.js.map +1 -0
- package/dist/index.d.ts +144 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +144 -0
- package/dist/index.js.map +1 -0
- package/dist/interval/iasync-interval-index.d.ts +8 -0
- package/dist/interval/iasync-interval-index.d.ts.map +1 -0
- package/dist/interval/iasync-interval-index.js +2 -0
- package/dist/interval/iasync-interval-index.js.map +1 -0
- package/dist/interval/iinterval-index.d.ts +8 -0
- package/dist/interval/iinterval-index.d.ts.map +1 -0
- package/dist/interval/iinterval-index.js +2 -0
- package/dist/interval/iinterval-index.js.map +1 -0
- package/dist/interval/static-interval-tree.d.ts +65 -0
- package/dist/interval/static-interval-tree.d.ts.map +1 -0
- package/dist/interval/static-interval-tree.js +170 -0
- package/dist/interval/static-interval-tree.js.map +1 -0
- package/dist/list/_bounded-list.d.ts +14 -0
- package/dist/list/_bounded-list.d.ts.map +1 -0
- package/dist/list/_bounded-list.js +23 -0
- package/dist/list/_bounded-list.js.map +1 -0
- package/dist/list/array-list.d.ts +56 -0
- package/dist/list/array-list.d.ts.map +1 -0
- package/dist/list/array-list.js +198 -0
- package/dist/list/array-list.js.map +1 -0
- package/dist/list/blocking-array-list.d.ts +55 -0
- package/dist/list/blocking-array-list.d.ts.map +1 -0
- package/dist/list/blocking-array-list.js +190 -0
- package/dist/list/blocking-array-list.js.map +1 -0
- package/dist/list/blocking-circular-array-list.d.ts +61 -0
- package/dist/list/blocking-circular-array-list.d.ts.map +1 -0
- package/dist/list/blocking-circular-array-list.js +211 -0
- package/dist/list/blocking-circular-array-list.js.map +1 -0
- package/dist/list/blocking-doubly-linked-list.d.ts +59 -0
- package/dist/list/blocking-doubly-linked-list.d.ts.map +1 -0
- package/dist/list/blocking-doubly-linked-list.js +211 -0
- package/dist/list/blocking-doubly-linked-list.js.map +1 -0
- package/dist/list/blocking-linked-list.d.ts +50 -0
- package/dist/list/blocking-linked-list.d.ts.map +1 -0
- package/dist/list/blocking-linked-list.js +172 -0
- package/dist/list/blocking-linked-list.js.map +1 -0
- package/dist/list/bounded-array-list.d.ts +47 -0
- package/dist/list/bounded-array-list.d.ts.map +1 -0
- package/dist/list/bounded-array-list.js +108 -0
- package/dist/list/bounded-array-list.js.map +1 -0
- package/dist/list/bounded-circular-array-list.d.ts +54 -0
- package/dist/list/bounded-circular-array-list.d.ts.map +1 -0
- package/dist/list/bounded-circular-array-list.js +123 -0
- package/dist/list/bounded-circular-array-list.js.map +1 -0
- package/dist/list/bounded-doubly-linked-list.d.ts +52 -0
- package/dist/list/bounded-doubly-linked-list.d.ts.map +1 -0
- package/dist/list/bounded-doubly-linked-list.js +123 -0
- package/dist/list/bounded-doubly-linked-list.js.map +1 -0
- package/dist/list/bounded-linked-list.d.ts +42 -0
- package/dist/list/bounded-linked-list.d.ts.map +1 -0
- package/dist/list/bounded-linked-list.js +97 -0
- package/dist/list/bounded-linked-list.js.map +1 -0
- package/dist/list/circular-array-list.d.ts +77 -0
- package/dist/list/circular-array-list.d.ts.map +1 -0
- package/dist/list/circular-array-list.js +322 -0
- package/dist/list/circular-array-list.js.map +1 -0
- package/dist/list/doubly-linked-list.d.ts +113 -0
- package/dist/list/doubly-linked-list.d.ts.map +1 -0
- package/dist/list/doubly-linked-list.js +453 -0
- package/dist/list/doubly-linked-list.js.map +1 -0
- package/dist/list/iasync-list.d.ts +17 -0
- package/dist/list/iasync-list.d.ts.map +1 -0
- package/dist/list/iasync-list.js +2 -0
- package/dist/list/iasync-list.js.map +1 -0
- package/dist/list/ilist-storage.d.ts +9 -0
- package/dist/list/ilist-storage.d.ts.map +1 -0
- package/dist/list/ilist-storage.js +2 -0
- package/dist/list/ilist-storage.js.map +1 -0
- package/dist/list/ilist.d.ts +118 -0
- package/dist/list/ilist.d.ts.map +1 -0
- package/dist/list/ilist.js +8 -0
- package/dist/list/ilist.js.map +1 -0
- package/dist/list/iwaitable-list.d.ts +47 -0
- package/dist/list/iwaitable-list.d.ts.map +1 -0
- package/dist/list/iwaitable-list.js +2 -0
- package/dist/list/iwaitable-list.js.map +1 -0
- package/dist/list/linked-list.d.ts +102 -0
- package/dist/list/linked-list.d.ts.map +1 -0
- package/dist/list/linked-list.js +377 -0
- package/dist/list/linked-list.js.map +1 -0
- package/dist/map/iasync-map.d.ts +13 -0
- package/dist/map/iasync-map.d.ts.map +1 -0
- package/dist/map/iasync-map.js +2 -0
- package/dist/map/iasync-map.js.map +1 -0
- package/dist/map/iasync-replacing-map.d.ts +8 -0
- package/dist/map/iasync-replacing-map.d.ts.map +1 -0
- package/dist/map/iasync-replacing-map.js +2 -0
- package/dist/map/iasync-replacing-map.js.map +1 -0
- package/dist/map/iasync-sorted-map.d.ts +12 -0
- package/dist/map/iasync-sorted-map.d.ts.map +1 -0
- package/dist/map/iasync-sorted-map.js +2 -0
- package/dist/map/iasync-sorted-map.js.map +1 -0
- package/dist/map/imap.d.ts +20 -0
- package/dist/map/imap.d.ts.map +1 -0
- package/dist/map/imap.js +2 -0
- package/dist/map/imap.js.map +1 -0
- package/dist/map/ireplacing-map.d.ts +19 -0
- package/dist/map/ireplacing-map.d.ts.map +1 -0
- package/dist/map/ireplacing-map.js +2 -0
- package/dist/map/ireplacing-map.js.map +1 -0
- package/dist/map/isorted-map.d.ts +23 -0
- package/dist/map/isorted-map.d.ts.map +1 -0
- package/dist/map/isorted-map.js +2 -0
- package/dist/map/isorted-map.js.map +1 -0
- package/dist/multimap/iasync-multimap.d.ts +16 -0
- package/dist/multimap/iasync-multimap.d.ts.map +1 -0
- package/dist/multimap/iasync-multimap.js +2 -0
- package/dist/multimap/iasync-multimap.js.map +1 -0
- package/dist/multimap/imultimap.d.ts +28 -0
- package/dist/multimap/imultimap.d.ts.map +1 -0
- package/dist/multimap/imultimap.js +2 -0
- package/dist/multimap/imultimap.js.map +1 -0
- package/dist/multimap/inverted-index.d.ts +90 -0
- package/dist/multimap/inverted-index.d.ts.map +1 -0
- package/dist/multimap/inverted-index.js +234 -0
- package/dist/multimap/inverted-index.js.map +1 -0
- package/dist/multimap/multi-map.d.ts +63 -0
- package/dist/multimap/multi-map.d.ts.map +1 -0
- package/dist/multimap/multi-map.js +146 -0
- package/dist/multimap/multi-map.js.map +1 -0
- package/dist/multiset/iasync-multiset.d.ts +13 -0
- package/dist/multiset/iasync-multiset.d.ts.map +1 -0
- package/dist/multiset/iasync-multiset.js +2 -0
- package/dist/multiset/iasync-multiset.js.map +1 -0
- package/dist/multiset/imultiset.d.ts +22 -0
- package/dist/multiset/imultiset.d.ts.map +1 -0
- package/dist/multiset/imultiset.js +2 -0
- package/dist/multiset/imultiset.js.map +1 -0
- package/dist/multiset/multi-set.d.ts +66 -0
- package/dist/multiset/multi-set.d.ts.map +1 -0
- package/dist/multiset/multi-set.js +124 -0
- package/dist/multiset/multi-set.js.map +1 -0
- package/dist/ordered-range/iasync-ordered-range.d.ts +15 -0
- package/dist/ordered-range/iasync-ordered-range.d.ts.map +1 -0
- package/dist/ordered-range/iasync-ordered-range.js +2 -0
- package/dist/ordered-range/iasync-ordered-range.js.map +1 -0
- package/dist/ordered-range/iordered-range.d.ts +28 -0
- package/dist/ordered-range/iordered-range.d.ts.map +1 -0
- package/dist/ordered-range/iordered-range.js +2 -0
- package/dist/ordered-range/iordered-range.js.map +1 -0
- package/dist/priority-queue/blocking-priority-queue.d.ts +37 -0
- package/dist/priority-queue/blocking-priority-queue.d.ts.map +1 -0
- package/dist/priority-queue/blocking-priority-queue.js +87 -0
- package/dist/priority-queue/blocking-priority-queue.js.map +1 -0
- package/dist/priority-queue/bounded-priority-queue.d.ts +45 -0
- package/dist/priority-queue/bounded-priority-queue.d.ts.map +1 -0
- package/dist/priority-queue/bounded-priority-queue.js +71 -0
- package/dist/priority-queue/bounded-priority-queue.js.map +1 -0
- package/dist/priority-queue/iasync-lossy-priority-queue.d.ts +9 -0
- package/dist/priority-queue/iasync-lossy-priority-queue.d.ts.map +1 -0
- package/dist/priority-queue/iasync-lossy-priority-queue.js +2 -0
- package/dist/priority-queue/iasync-lossy-priority-queue.js.map +1 -0
- package/dist/priority-queue/iasync-priority-queue.d.ts +21 -0
- package/dist/priority-queue/iasync-priority-queue.d.ts.map +1 -0
- package/dist/priority-queue/iasync-priority-queue.js +2 -0
- package/dist/priority-queue/iasync-priority-queue.js.map +1 -0
- package/dist/priority-queue/ilossy-priority-queue.d.ts +29 -0
- package/dist/priority-queue/ilossy-priority-queue.d.ts.map +1 -0
- package/dist/priority-queue/ilossy-priority-queue.js +2 -0
- package/dist/priority-queue/ilossy-priority-queue.js.map +1 -0
- package/dist/priority-queue/ipriority-queue.d.ts +71 -0
- package/dist/priority-queue/ipriority-queue.d.ts.map +1 -0
- package/dist/priority-queue/ipriority-queue.js +2 -0
- package/dist/priority-queue/ipriority-queue.js.map +1 -0
- package/dist/priority-queue/iwaitable-priority-queue.d.ts +27 -0
- package/dist/priority-queue/iwaitable-priority-queue.d.ts.map +1 -0
- package/dist/priority-queue/iwaitable-priority-queue.js +2 -0
- package/dist/priority-queue/iwaitable-priority-queue.js.map +1 -0
- package/dist/priority-queue/priority-queue.d.ts +49 -0
- package/dist/priority-queue/priority-queue.d.ts.map +1 -0
- package/dist/priority-queue/priority-queue.js +134 -0
- package/dist/priority-queue/priority-queue.js.map +1 -0
- package/dist/probabilistic/bloom-filter.d.ts +92 -0
- package/dist/probabilistic/bloom-filter.d.ts.map +1 -0
- package/dist/probabilistic/bloom-filter.js +156 -0
- package/dist/probabilistic/bloom-filter.js.map +1 -0
- package/dist/probabilistic/count-min-sketch.d.ts +76 -0
- package/dist/probabilistic/count-min-sketch.d.ts.map +1 -0
- package/dist/probabilistic/count-min-sketch.js +119 -0
- package/dist/probabilistic/count-min-sketch.js.map +1 -0
- package/dist/probabilistic/cuckoo-filter.d.ts +106 -0
- package/dist/probabilistic/cuckoo-filter.d.ts.map +1 -0
- package/dist/probabilistic/cuckoo-filter.js +214 -0
- package/dist/probabilistic/cuckoo-filter.js.map +1 -0
- package/dist/probabilistic/hash32.d.ts +28 -0
- package/dist/probabilistic/hash32.d.ts.map +1 -0
- package/dist/probabilistic/hash32.js +2 -0
- package/dist/probabilistic/hash32.js.map +1 -0
- package/dist/probabilistic/hyper-log-log.d.ts +74 -0
- package/dist/probabilistic/hyper-log-log.d.ts.map +1 -0
- package/dist/probabilistic/hyper-log-log.js +134 -0
- package/dist/probabilistic/hyper-log-log.js.map +1 -0
- package/dist/probabilistic/top-k.d.ts +62 -0
- package/dist/probabilistic/top-k.d.ts.map +1 -0
- package/dist/probabilistic/top-k.js +104 -0
- package/dist/probabilistic/top-k.js.map +1 -0
- package/dist/queue/blocking-queue.d.ts +32 -0
- package/dist/queue/blocking-queue.d.ts.map +1 -0
- package/dist/queue/blocking-queue.js +70 -0
- package/dist/queue/blocking-queue.js.map +1 -0
- package/dist/queue/bounded-queue.d.ts +47 -0
- package/dist/queue/bounded-queue.d.ts.map +1 -0
- package/dist/queue/bounded-queue.js +64 -0
- package/dist/queue/bounded-queue.js.map +1 -0
- package/dist/queue/iasync-lossy-queue.d.ts +15 -0
- package/dist/queue/iasync-lossy-queue.d.ts.map +1 -0
- package/dist/queue/iasync-lossy-queue.js +2 -0
- package/dist/queue/iasync-lossy-queue.js.map +1 -0
- package/dist/queue/iasync-queue.d.ts +17 -0
- package/dist/queue/iasync-queue.d.ts.map +1 -0
- package/dist/queue/iasync-queue.js +2 -0
- package/dist/queue/iasync-queue.js.map +1 -0
- package/dist/queue/ilossy-queue.d.ts +28 -0
- package/dist/queue/ilossy-queue.d.ts.map +1 -0
- package/dist/queue/ilossy-queue.js +2 -0
- package/dist/queue/ilossy-queue.js.map +1 -0
- package/dist/queue/iqueue-storage.d.ts +5 -0
- package/dist/queue/iqueue-storage.d.ts.map +1 -0
- package/dist/queue/iqueue-storage.js +2 -0
- package/dist/queue/iqueue-storage.js.map +1 -0
- package/dist/queue/iqueue.d.ts +41 -0
- package/dist/queue/iqueue.d.ts.map +1 -0
- package/dist/queue/iqueue.js +2 -0
- package/dist/queue/iqueue.js.map +1 -0
- package/dist/queue/iwaitable-queue.d.ts +27 -0
- package/dist/queue/iwaitable-queue.d.ts.map +1 -0
- package/dist/queue/iwaitable-queue.js +2 -0
- package/dist/queue/iwaitable-queue.js.map +1 -0
- package/dist/queue/lossy-queue.d.ts +33 -0
- package/dist/queue/lossy-queue.d.ts.map +1 -0
- package/dist/queue/lossy-queue.js +75 -0
- package/dist/queue/lossy-queue.js.map +1 -0
- package/dist/queue/queue.d.ts +27 -0
- package/dist/queue/queue.d.ts.map +1 -0
- package/dist/queue/queue.js +43 -0
- package/dist/queue/queue.js.map +1 -0
- package/dist/set/enhanced-set.d.ts +68 -0
- package/dist/set/enhanced-set.d.ts.map +1 -0
- package/dist/set/enhanced-set.js +169 -0
- package/dist/set/enhanced-set.js.map +1 -0
- package/dist/set/iasync-replacing-set.d.ts +8 -0
- package/dist/set/iasync-replacing-set.d.ts.map +1 -0
- package/dist/set/iasync-replacing-set.js +2 -0
- package/dist/set/iasync-replacing-set.js.map +1 -0
- package/dist/set/iasync-set.d.ts +16 -0
- package/dist/set/iasync-set.d.ts.map +1 -0
- package/dist/set/iasync-set.js +2 -0
- package/dist/set/iasync-set.js.map +1 -0
- package/dist/set/iasync-sorted-set.d.ts +7 -0
- package/dist/set/iasync-sorted-set.d.ts.map +1 -0
- package/dist/set/iasync-sorted-set.js +2 -0
- package/dist/set/iasync-sorted-set.js.map +1 -0
- package/dist/set/ireplacing-set.d.ts +24 -0
- package/dist/set/ireplacing-set.d.ts.map +1 -0
- package/dist/set/ireplacing-set.js +2 -0
- package/dist/set/ireplacing-set.js.map +1 -0
- package/dist/set/iset.d.ts +30 -0
- package/dist/set/iset.d.ts.map +1 -0
- package/dist/set/iset.js +2 -0
- package/dist/set/iset.js.map +1 -0
- package/dist/set/isorted-set.d.ts +7 -0
- package/dist/set/isorted-set.d.ts.map +1 -0
- package/dist/set/isorted-set.js +2 -0
- package/dist/set/isorted-set.js.map +1 -0
- package/dist/similarity/iasync-similarity-index.d.ts +8 -0
- package/dist/similarity/iasync-similarity-index.d.ts.map +1 -0
- package/dist/similarity/iasync-similarity-index.js +2 -0
- package/dist/similarity/iasync-similarity-index.js.map +1 -0
- package/dist/similarity/isimilarity-index.d.ts +8 -0
- package/dist/similarity/isimilarity-index.d.ts.map +1 -0
- package/dist/similarity/isimilarity-index.js +2 -0
- package/dist/similarity/isimilarity-index.js.map +1 -0
- package/dist/similarity/vp-tree.d.ts +71 -0
- package/dist/similarity/vp-tree.d.ts.map +1 -0
- package/dist/similarity/vp-tree.js +172 -0
- package/dist/similarity/vp-tree.js.map +1 -0
- package/dist/stack/blocking-stack.d.ts +30 -0
- package/dist/stack/blocking-stack.d.ts.map +1 -0
- package/dist/stack/blocking-stack.js +68 -0
- package/dist/stack/blocking-stack.js.map +1 -0
- package/dist/stack/bounded-stack.d.ts +38 -0
- package/dist/stack/bounded-stack.d.ts.map +1 -0
- package/dist/stack/bounded-stack.js +55 -0
- package/dist/stack/bounded-stack.js.map +1 -0
- package/dist/stack/iasync-lossy-stack.d.ts +9 -0
- package/dist/stack/iasync-lossy-stack.d.ts.map +1 -0
- package/dist/stack/iasync-lossy-stack.js +2 -0
- package/dist/stack/iasync-lossy-stack.js.map +1 -0
- package/dist/stack/iasync-stack.d.ts +15 -0
- package/dist/stack/iasync-stack.d.ts.map +1 -0
- package/dist/stack/iasync-stack.js +2 -0
- package/dist/stack/iasync-stack.js.map +1 -0
- package/dist/stack/ilossy-stack.d.ts +28 -0
- package/dist/stack/ilossy-stack.d.ts.map +1 -0
- package/dist/stack/ilossy-stack.js +2 -0
- package/dist/stack/ilossy-stack.js.map +1 -0
- package/dist/stack/istack-storage.d.ts +5 -0
- package/dist/stack/istack-storage.d.ts.map +1 -0
- package/dist/stack/istack-storage.js +2 -0
- package/dist/stack/istack-storage.js.map +1 -0
- package/dist/stack/istack.d.ts +41 -0
- package/dist/stack/istack.d.ts.map +1 -0
- package/dist/stack/istack.js +2 -0
- package/dist/stack/istack.js.map +1 -0
- package/dist/stack/iwaitable-stack.d.ts +26 -0
- package/dist/stack/iwaitable-stack.d.ts.map +1 -0
- package/dist/stack/iwaitable-stack.js +2 -0
- package/dist/stack/iwaitable-stack.js.map +1 -0
- package/dist/stack/stack.d.ts +26 -0
- package/dist/stack/stack.d.ts.map +1 -0
- package/dist/stack/stack.js +42 -0
- package/dist/stack/stack.js.map +1 -0
- package/dist/storage/iindexed-storage.d.ts +8 -0
- package/dist/storage/iindexed-storage.d.ts.map +1 -0
- package/dist/storage/iindexed-storage.js +2 -0
- package/dist/storage/iindexed-storage.js.map +1 -0
- package/dist/storage/ipop-back-storage.d.ts +8 -0
- package/dist/storage/ipop-back-storage.d.ts.map +1 -0
- package/dist/storage/ipop-back-storage.js +2 -0
- package/dist/storage/ipop-back-storage.js.map +1 -0
- package/dist/storage/ipop-front-storage.d.ts +8 -0
- package/dist/storage/ipop-front-storage.d.ts.map +1 -0
- package/dist/storage/ipop-front-storage.js +2 -0
- package/dist/storage/ipop-front-storage.js.map +1 -0
- package/dist/storage/ipush-back-storage.d.ts +7 -0
- package/dist/storage/ipush-back-storage.d.ts.map +1 -0
- package/dist/storage/ipush-back-storage.js +2 -0
- package/dist/storage/ipush-back-storage.js.map +1 -0
- package/dist/storage/ipush-front-storage.d.ts +7 -0
- package/dist/storage/ipush-front-storage.d.ts.map +1 -0
- package/dist/storage/ipush-front-storage.js +2 -0
- package/dist/storage/ipush-front-storage.js.map +1 -0
- package/dist/storage/istorage.d.ts +13 -0
- package/dist/storage/istorage.d.ts.map +1 -0
- package/dist/storage/istorage.js +2 -0
- package/dist/storage/istorage.js.map +1 -0
- package/dist/storage/ring-vector.d.ts +59 -0
- package/dist/storage/ring-vector.d.ts.map +1 -0
- package/dist/storage/ring-vector.js +192 -0
- package/dist/storage/ring-vector.js.map +1 -0
- package/dist/storage/segmented-ring-vector.d.ts +42 -0
- package/dist/storage/segmented-ring-vector.d.ts.map +1 -0
- package/dist/storage/segmented-ring-vector.js +142 -0
- package/dist/storage/segmented-ring-vector.js.map +1 -0
- package/dist/storage/typed-vector.d.ts +67 -0
- package/dist/storage/typed-vector.d.ts.map +1 -0
- package/dist/storage/typed-vector.js +123 -0
- package/dist/storage/typed-vector.js.map +1 -0
- package/dist/substring/generalized-suffix-array.d.ts +43 -0
- package/dist/substring/generalized-suffix-array.d.ts.map +1 -0
- package/dist/substring/generalized-suffix-array.js +100 -0
- package/dist/substring/generalized-suffix-array.js.map +1 -0
- package/dist/substring/iasync-substring-index.d.ts +6 -0
- package/dist/substring/iasync-substring-index.d.ts.map +1 -0
- package/dist/substring/iasync-substring-index.js +2 -0
- package/dist/substring/iasync-substring-index.js.map +1 -0
- package/dist/substring/isubstring-index.d.ts +6 -0
- package/dist/substring/isubstring-index.d.ts.map +1 -0
- package/dist/substring/isubstring-index.js +2 -0
- package/dist/substring/isubstring-index.js.map +1 -0
- package/dist/substring/suffix-array.d.ts +45 -0
- package/dist/substring/suffix-array.d.ts.map +1 -0
- package/dist/substring/suffix-array.js +164 -0
- package/dist/substring/suffix-array.js.map +1 -0
- package/dist/tree/avl-tree.d.ts +43 -0
- package/dist/tree/avl-tree.d.ts.map +1 -0
- package/dist/tree/avl-tree.js +98 -0
- package/dist/tree/avl-tree.js.map +1 -0
- package/dist/tree/binary-search-tree.d.ts +94 -0
- package/dist/tree/binary-search-tree.d.ts.map +1 -0
- package/dist/tree/binary-search-tree.js +303 -0
- package/dist/tree/binary-search-tree.js.map +1 -0
- package/dist/tree/iavl-tree-node.d.ts +6 -0
- package/dist/tree/iavl-tree-node.d.ts.map +1 -0
- package/dist/tree/iavl-tree-node.js +2 -0
- package/dist/tree/iavl-tree-node.js.map +1 -0
- package/dist/tree/isearch-tree.d.ts +14 -0
- package/dist/tree/isearch-tree.d.ts.map +1 -0
- package/dist/tree/isearch-tree.js +2 -0
- package/dist/tree/isearch-tree.js.map +1 -0
- package/dist/trie/iasync-trie.d.ts +9 -0
- package/dist/trie/iasync-trie.d.ts.map +1 -0
- package/dist/trie/iasync-trie.js +2 -0
- package/dist/trie/iasync-trie.js.map +1 -0
- package/dist/trie/itrie.d.ts +9 -0
- package/dist/trie/itrie.d.ts.map +1 -0
- package/dist/trie/itrie.js +2 -0
- package/dist/trie/itrie.js.map +1 -0
- package/dist/trie/trie.d.ts +93 -0
- package/dist/trie/trie.d.ts.map +1 -0
- package/dist/trie/trie.js +190 -0
- package/dist/trie/trie.js.map +1 -0
- 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,C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AO,IAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAE/C;CACD"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { checkCapacity, resolveBoundedCapacity, } 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,CA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AAO,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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IAQf,QAAQ;IAJD,OAAO,CAAmC;IAC1C,aAAa,CAAsC;IAEpE,YACU,QAAQ,GAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EACtD,QAA2B,EAC3B,OAAoC;wBAF3B,QAAQ;QAIjB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;QACrE,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,IAAI,UAAU,EAAuB,CAAC;QAEzE,IAAI,QAAQ,EAAE,CAAC;YACd,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,QAAQ,EAAE,CAAC;gBAC1C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC5C,C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,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,CAAC,OAAO;QACP,MAAM,KAAK,GAAG,IAAI,UAAU,CAAsB,IAAI,CAAC,OAAO,CAAC,CAAC;QAEhE,OAAO,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;YAE5B,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gBACjB,MAAM,KAAK,CAAC,OAAO,EAAyB,CAAC;gBAC7C,MAAM;YACP,CAAC;YAED,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAwB,CAAC;YACjD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,EAAyB,CAAC;YACpD,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;YACnB,WAAW,CAAC,KAAK,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
|