Crates.io | priority-queue-rs |
lib.rs | priority-queue-rs |
version | 0.1.26 |
source | src |
created_at | 2021-04-13 18:11:08.001458 |
updated_at | 2021-05-30 16:51:46.991298 |
description | Priority Queue is more specialized data structure than Queue. Like ordinary queue, priority queue has same method but with a major difference. In Priority queue items are ordered by key value so that item with the lowest value of key is at front and item with the highest value of key is at rear or vice versa. So we're assigned priority to item based on its key value. Lower the value, higher the priority. Following are the principal methods of a Priority Queue. |
homepage | https://github.com/bangbaoshi/priority_queue |
repository | https://github.com/bangbaoshi/priority_queue |
max_upload_size | |
id | 383009 |
size | 9,559 |
Priority Queue is more specialized data structure than Queue. Like ordinary queue, priority queue has same method but with a major difference. In Priority queue items are ordered by key value so that item with the lowest value of key is at front and item with the highest value of key is at rear or vice versa. So we're assigned priority to item based on its key value. Lower the value, higher the priority. Following are the principal methods of a Priority Queue.
fn main() {
let mut queue = PriorityQueue::new();
for priority in 10..10000 {
queue.push(priority, String::from(format!("HelloWorld{}", priority)));
}
if let Some(t) = queue.peek() {
println!("peek {}", t);
}
for priority in 0..10 {
let value = queue.pop();
if let Some(t) = value {
println!("pop {}", t);
}
}
if let Some(t) = queue.peek() {
println!("peek {}", t);
}
}
This library is licensed under MIT license. See LICENSE for details.