Pure priority search queues

Version on this page:
LTS Haskell 13.21:
Stackage Nightly 2019-05-18:
Latest on Hackage:

See all snapshots psqueues appears in

BSD-3-Clause licensed
Maintained by Jasper Van der Jeugt

Module documentation for

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*.


- (2019-01-07)
* Relax QuickCheck upper bound to 2.12

- (2018-04-30)
* Export unsafe operations

- (2018-03-14)
* Fix issue with (<>) on 8.4
* Bump QuickCheck dependency to 2.11

- (2018-01-18)
* Fix build on GHC 8.4

- (2017-09-27)
* Add `unsafeMapMonotonic`
* Lower build depends version for hashable
* Move repo to `jaspervdj/psqueues` to enable travis
* Lower build depends version for hashable

* Add an `atMostView` function to all PSQ flavours
* Bump HUnit dependency to 1.6
* Bump QuickCheck dependency to 2.10
* Clean up warnings on newer and older GHC versions

* Bump HUnit dependency to 1.5

* Bump QuickCheck dependency bounds

* Fix benchmark compilation with stack

* Fix import of Traversable on GHC 7.8

* Add Traversable instances

* Bump HUnit dependency bounds

* Bump QuickCheck dependency bounds

* Minor documentation fixes

* Add convenience `deleteMin` function
* Bump `deepseq` dependency to 1.4

* Remove constraints from `size`

* Extend cabal description, include CHANGELOG

* First release: <>
comments powered byDisqus