priority-queue-rs

Crates.iopriority-queue-rs
lib.rspriority-queue-rs
version0.1.26
sourcesrc
created_at2021-04-13 18:11:08.001458
updated_at2021-05-30 16:51:46.991298
descriptionPriority 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.
homepagehttps://github.com/bangbaoshi/priority_queue
repositoryhttps://github.com/bangbaoshi/priority_queue
max_upload_size
id383009
size9,559
(bangbaoshi)

documentation

https://github.com/bangbaoshi/priority_queue

README

priority_queue

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.

How To Use

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);
    }
}

License

This library is licensed under MIT license. See LICENSE for details.

Commit count: 33

cargo fmt