pyority_queue/src/queue/paired.rs

25 lines
543 B
Rust

// A "pure" priority queue that supports duplicates, but not arbitrary deletions or weight updates
use crate::backing::{
item::Item,
pure::{binary_heap::BinaryHeap, PureBacking},
};
use pyo3::prelude::*;
#[pyclass]
pub struct PairedQueue {
backing: Box<dyn PureBacking<Item<Py<PyAny>, f64>>>,
}
#[pymethods]
impl PairedQueue {
#[new]
fn new() -> Self {
Self {
backing: Box::new(BinaryHeap::new()),
}
}
fn __len__(self_: PyRef<'_, Self>) -> usize {
self_.backing.len()
}
}