@hackage psqueues0.1.0.0
Pure priority search queues
Categories
License
BSD-3-Clause
Maintainer
haskell@better.com
Links
Versions
Installation
Dependencies (4)
Dependents (51)
@cardano/ouroboros-network, @hackage/timer-wheel, @cardano/io-sim, @hackage/aern2-fun, @hackage/muesli, @hackage/quic, Show all…
A priority search queue manages a set of triples of the form
(key, priority, value) and allows for efficient lookup by key, and
efficient lookup and removal of the element with minimal priority. This
package contains three, performant implementations of priority search
queues, which differ in the requirements on the type of keys.
IntPSQs are the most efficient structure, but require the keys to be of typeInt.OrdPSQs just require the key to implement theOrdtypeclass, but are the slowest structures of the three.HashPSQs require the key to implement both theOrdandHashabletypeclasses. They use anIntMapover the hash of the keys combined with aOrdPSQto manage collisions. Except for keys with a very fast comparison and small smapsHashPSQs are faster thanOrdPSQs.
Typical use cases for priority search queues are LRU caches, where the priority is the time of the last access, and timeout management, where the priority is the time at which the timeout should trigger.