Add stubs for other queues

This commit is contained in:
Michael Bradley 2025-01-09 00:08:55 +13:00
parent 6e91aef421
commit 6878652583
Signed by: MichaelBradley
SSH key fingerprint: SHA256:cj/YZ5VT+QOKncqSkx+ibKTIn0Obg7OIzwzl9BL8EO8
7 changed files with 38 additions and 5 deletions

View file

@ -1,5 +1,6 @@
/// Data structures for the "pure" min-queues, supporting duplicates but no arbitrary updates /// Data structures for the "pure" min-queues, supporting duplicates but no arbitrary updates
pub mod binary_heap; mod binary_heap;
pub use binary_heap::BinaryHeap;
/// A data structure usable for backing a "pure" queue /// A data structure usable for backing a "pure" queue
pub trait PureBacking<T: Ord + Send + Sync>: Send + Sync { pub trait PureBacking<T: Ord + Send + Sync>: Send + Sync {

View file

@ -2,11 +2,13 @@ pub mod backing;
pub mod queue; pub mod queue;
use pyo3::prelude::*; use pyo3::prelude::*;
use queue::paired::PairedQueue; use queue::{IndexedQueue, PairedQueue, PureQueue};
/// Bindings for the Rust queue implementations /// Bindings for the Rust queue implementations
#[pymodule] #[pymodule]
fn pyority_queue(m: &Bound<'_, PyModule>) -> PyResult<()> { fn pyority_queue(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<PureQueue>()?;
m.add_class::<PairedQueue>()?; m.add_class::<PairedQueue>()?;
m.add_class::<IndexedQueue>()?;
Ok(()) Ok(())
} }

12
src/queue/indexed.rs Normal file
View file

@ -0,0 +1,12 @@
use pyo3::prelude::*;
#[pyclass]
pub struct IndexedQueue {}
#[pymethods]
impl IndexedQueue {
#[new]
fn new() -> Self {
Self {}
}
}

View file

@ -1 +1,7 @@
pub mod paired; mod indexed;
mod paired;
mod pure;
pub use indexed::IndexedQueue;
pub use paired::PairedQueue;
pub use pure::PureQueue;

View file

@ -1,7 +1,7 @@
// A "pure" priority queue that supports duplicates, but not arbitrary deletions or weight updates // A "pure" priority queue that supports duplicates, but not arbitrary deletions or weight updates
use crate::backing::{ use crate::backing::{
item::Item, item::Item,
pure::{binary_heap::BinaryHeap, PureBacking}, pure::{BinaryHeap, PureBacking},
}; };
use pyo3::prelude::*; use pyo3::prelude::*;

12
src/queue/pure.rs Normal file
View file

@ -0,0 +1,12 @@
use pyo3::prelude::*;
#[pyclass]
pub struct PureQueue {}
#[pymethods]
impl PureQueue {
#[new]
fn new() -> Self {
Self {}
}
}

View file

@ -1,6 +1,6 @@
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use pyority_queue::backing::pure::{binary_heap::BinaryHeap, PureBacking}; use pyority_queue::backing::pure::{BinaryHeap, PureBacking};
#[test] #[test]
fn test_pure_binary_heap_manual_creation() { fn test_pure_binary_heap_manual_creation() {