This crate provide a priority queue backed by an hashmap with some efficient methods to change the priority of an element in O(log(N)) time (worst case).
The elements (called Item
s, of type I
) must implement
Hash
and Eq
traits.
This can frequently be achieved by using #[derive(PartialEq, Eq, Hash)]
.
If you implement these yourself, it is important that the following property holds:
k1 == k2 -> hash(k1) == hash(k2)
In other words, if two keys are equal, their hashes must be equal.
The priority P
may be any type that implements
Ord
.
For reverse order remember the standard wrapper
Reverse<T>
Example
use PriorityQueue;