heapix
A lightweight Rust library providing heap-based priority queue data structures with efficient operations, including decrease-key and heap construction.
Features
- Min-Heap (
MinHeap<K>): maintain a priority queue of(item_id, key)pairs, where the smallest key is always at the root. - Efficient operations:
insertin O(log n)get_minin O(1)delete_minin O(log n)decrease_keyin O(log n)build_heapfrom an unsorted list in O(n)
Installation
Add heapix to your Cargo.toml dependencies:
[]
= "0.1"
Or with cargo:
Quick Start
use MinHeap;
API
MinHeap<K>
MinHeap::new() -> MinHeap<K>MinHeap::build_heap(items: Vec<(usize, K)>) -> MinHeap<K>is_empty(&self) -> boolinsert(&mut self, item: (usize, K))get_min(&self) -> Option<&(usize, K)>delete_min(&mut self) -> Option<(usize, K)>decrease_key(&mut self, id: usize, new_key: K)
License
This project is licensed under the MIT License. See the LICENSE file for details.