Crate priq

source · []
Expand description

Priority queue (min/max heap) using raw binary heap.

PriorityQueue is build on using raw array for efficient performance.

There are two major reasons what makes this PriorityQueue different from other binary heap implementations currently available:

1 - Allows data ordering to scores with PartialOrd. - Every other min-max heap requires total ordering of scores (e.g. should implement Ord trait). This can be an issue, for example, when you want to order items based on a float scores, which doesn’t implement Ord trait. - You can read about Rust’s implementation or Ord, PartialOrd and what’s the different here

2 - Separation of score and item you wish to store. - This frees enforcement for associated items to implement any ordering. - Makes easier to evaluate items’ order.

3 - Equal scoring items are stored at first available free space. - This gives performance boost for large number of entries.

4 - Easy to use!

You can read more about this crate on my blog

Structs

A Min-Max Heap with designated arguments for score and associated item!