prio-queue

Crates.ioprio-queue
lib.rsprio-queue
version0.1.1
sourcesrc
created_at2021-06-12 13:20:18.743355
updated_at2021-06-12 13:31:28.501142
descriptionA simple priority queue implemented as a heap stored in a Vec
homepage
repositoryhttps://gitlab.com/uben0/prio-queue
max_upload_size
id409334
size18,469
uben (uben0)

documentation

https://docs.rs/prio-queue

README

Priority Queue

A simple priority queue implemented in Rust as a binary heap stored in a Vec<T>.

This implementation aims to be simple and more flexible than the one provided by the standard library. It relies on a given function to determine priority between elements. Let you acces the underlying Vec<T> with consistency check or not.

Example

let mut queue = PrioQueue::new(|l, r| l < r);
queue.push(42);
queue.push(32);
queue.push(64);
assert_eq!(queue.pop(), Some(32));
assert_eq!(queue.pop(), Some(42));
assert_eq!(queue.pop(), Some(64));
assert_eq!(queue.pop(), None);

Display

              ╭───────────────9───────────────╮             
      ╭───────26──────╮               ╭───────27──────╮     
  ╭───45──╮       ╭───34──╮       ╭───35──╮       ╭───37──╮ 
╭─59╮   ╭─52╮   ╭─48      57      67      39      80      73
77  61  64  74  96                                          
Commit count: 8

cargo fmt