Get basic incomplete Python queue API working
This commit is contained in:
parent
661e1d220a
commit
0995e6db90
8 changed files with 69 additions and 45 deletions
25
src/queue/pure.rs
Normal file
25
src/queue/pure.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
// 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 PureQueue {
|
||||
backing: Box<dyn PureBacking<Item<Py<PyAny>, f64>>>,
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl PureQueue {
|
||||
#[new]
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
backing: Box::new(BinaryHeap::new()),
|
||||
}
|
||||
}
|
||||
|
||||
fn __len__(self_: PyRef<'_, Self>) -> usize {
|
||||
self_.backing.len()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue