package intPQueue

  1. Overview
  2. Docs
A fast and compact priority queue with low integer priorities

Install

dune-project
 Dependency

Authors

Maintainers

Sources

20250925.tar.gz
md5=4083a2898648f400d470671a71077c1b
sha512=d0ded93af26124ac551391e65eab1773db4524326d8a5c3ebdb2b92ec96878b13b456a08ac593aa27a506023030c7dc78fe48d44483dc987a34887c481b655c6

doc/index.html

IntPQueue

This library that offers a fast and compact priority queue whose keys are nonnegative integers.

The priorities must be low integers, because the space occupied by the priority queue is O(n+p), where n is the number of elements in the queue and p is the greatest priority that is ever used.

Furthermore, this priority queue is most efficient under the assumption that the priorities that are passed to add and update are at least as high as the priority of the last element that was returned by extract. This is the case, for example, in Dijkstra's single-source shortest paths algorithm. In this scenario, the time complexity of inserting and extracting n elements is O(n+p). In Dijkstra's algorithm, for example, if the cost of every edge in the graph is 1 then p is O(n) so the time complexity of inserting and extracting n elements is O(n). In other words, every priority queue operation has amortized time complexity O(1).

API

  • IntPQueue.Plain This is a priority queue whose keys are low nonnegative integers.
  • IntPQueue.Boxed This is a priority queue whose keys are low nonnegative integers. It supports removing or updating the priority of a specific element of the queue.

Installation and Usage

Type opam install intPQueue.

In your dune file, add (libraries intPQueue) to the description of your library or executable.