Crates.io | rusty-priority-queue |
lib.rs | rusty-priority-queue |
version | 0.1.0 |
source | src |
created_at | 2022-11-25 16:37:59.773517 |
updated_at | 2022-11-25 16:37:59.773517 |
description | A priority queue implementation. |
homepage | |
repository | https://github.com/batuhan-aydin/rusty-structures/tree/main/rusty-priority-queue |
max_upload_size | |
id | 722872 |
size | 15,824 |
An implemantation of priority queue. Based on the book named Advanced Algorithms and Data Structures.
To use this crate, simply add the following string to your 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);