1 个不稳定版本
0.1.0 | 2022年11月25日 |
---|
#2470 在 数据结构
15KB
284 行
优先队列
基于名为《高级算法和数据结构》的书籍的实现。
使用方法
要使用这个crate,只需将以下字符串添加到您的Cargo.toml
quotient-filter = "0.1.0"
// Parameters are capacity and branching factor(default 4).
// It's a vector of pairs behind the scenes, so defined capacity is a good idea.
let mut queue = PriorityQueue::new(Some(20), None);
// The second parameter is the priority
queue.insert_value("My important task", 1)
// Get the highest priority value
let top = queue.top();
// There is also peek which doesn't take the value out of the queue
let peek = queue.peek();
// Check if queue contains
let is_exists = queue.contains(&"The droid that we were searching for");
// Remove
let old_task = queue.remove("Time to go");
// Update its priority
queue.update_priority("Go to gym", 1000);
依赖
~0.4–0.8MB
~19K SLoC