A Rust priority queue with efficient priority change operations, implemented using IndexMap and a heap of indexes.
PriorityQueue is a Rust crate that provides a priority queue data structure with the unique ability to efficiently change the priority of existing elements. It is designed for scenarios where dynamic priority updates are required, offering performance advantages over standard binary heaps for such operations.
Rust developers working on systems that require dynamic priority updates, such as schedulers, network routing algorithms, or real-time simulations, as well as those targeting embedded or no_std environments.
Developers choose this over standard binary heaps because it allows modifying the priority of any element in O(log n) time, compared to O(n) for standard heaps, and offers additional features like double-ended support, custom hasher tuning, and no_std compatibility.
A priority queue for Rust with efficient change function.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows modifying element priority in O(log n) time, vastly outperforming standard binary heaps' O(n) approach, as shown in benchmarks where it's orders of magnitude faster for priority updates.
Includes a DoublePriorityQueue variant that supports popping both minimum and maximum priority elements, useful for bidirectional access in algorithms like schedulers.
Supports alternative hashers like FxHash for speed tuning, with the standard hasher providing DoS protection, enabling developers to balance performance and security based on input control.
Can be used in embedded systems by disabling default features, making it versatile for no_std targets, as highlighted in the README's feature set.
Benchmarks in the README show that push and pop operations are generally slower than std::collections::BinaryHeap, with std binary heap being faster in tests like push_and_pop_std.
The crate has a history of breaking changes in major versions, such as 2.0.0 and 1.0.0, which required code updates for users, as noted in the changelog.
Uses an IndexMap internally for tracking elements, which likely adds memory overhead compared to a simple binary heap, a trade-off for enabling efficient priority updates.