psqueues

Pure priority search queues

Version on this page:0.2.7.3
LTS Haskell 22.37:0.2.8.0@rev:1
Stackage Nightly 2024-10-11:0.2.8.0@rev:1
Latest on Hackage:0.2.8.0@rev:1

See all snapshots psqueues appears in

BSD-3-Clause licensed
Maintained by Jasper Van der Jeugt
This version can be pinned in stack with:psqueues-0.2.7.3@sha256:7213d78598d397255b1861df318d9b5058577f86a9b83a8b652540cbdbc83033,4834

Module documentation for 0.2.7.3

The psqueues package provides Priority Search Queues in three different flavors.

  • OrdPSQ k p v, which uses the Ord k instance to provide fast insertion, deletion and lookup. This implementation is based on Ralf Hinze's A Simple Implementation Technique for Priority Search Queues. Hence, it is similar to the PSQueue library, although it is considerably faster and provides a slightly different API.

  • IntPSQ p v is a far more efficient implementation. It fixes the key type to Int and uses a radix tree (like IntMap) with an additional min-heap property.

  • HashPSQ k p v is a fairly straightforward extension of IntPSQ: it simply uses the keys' hashes as indices in the IntPSQ. If there are any hash collisions, it uses an OrdPSQ to resolve those. The performance of this implementation is comparable to that of IntPSQ, but it is more widely applicable since the keys are not restricted to Int, but rather to any Hashable datatype.

Each of the three implementations provides the same API, so they can be used interchangeably. The benchmarks show how they perform relative to one another, and also compared to the other Priority Search Queue implementations on Hackage: PSQueue and fingertree-psqueue.

Typical applications of Priority Search Queues include:

  • Caches, and more specifically LRU Caches;

  • Schedulers;

  • Pathfinding algorithms, such as Dijkstra's and A*.