Update Rust structure to better match proposed Python API
This commit is contained in:
parent
b4ca806d76
commit
ffe6a76241
6 changed files with 18 additions and 18 deletions
12
src/backing/indexed/mod.rs
Normal file
12
src/backing/indexed/mod.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
/// Data structures for the "indexed" min-queues, supporting priority updates and arbitrary removals, but no duplicates
|
||||
use super::{item::Item, pure::PureBacking};
|
||||
|
||||
/// A data structure usable for backing an "indexed" queue
|
||||
pub trait IndexedBacking<D: Clone + Send + Sync, P: Ord + Clone + Send + Sync>:
|
||||
PureBacking<Item<D, P>>
|
||||
{
|
||||
/// Update an item's priority
|
||||
fn update(data: D, priority: P) -> Result<(), ()>;
|
||||
/// Remove an item from the queue
|
||||
fn remove(data: D) -> bool;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
/// Data structures for the "keyed" min-queues, supporting priority updates and arbitrary removals, but no duplicates
|
||||
use super::{item::Item, pure::PureBacking};
|
||||
|
||||
/// A data structure usable for backing a "keyed" queue
|
||||
pub trait KeyedBacking<D: Clone + Send + Sync, P: Ord + Clone + Send + Sync>:
|
||||
PureBacking<Item<D, P>>
|
||||
{
|
||||
/// Update an item's priority
|
||||
fn update(data: D, priority: P) -> Result<(), ()>;
|
||||
/// Remove an item from the queue
|
||||
fn remove(data: D) -> bool;
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
pub mod indexed;
|
||||
pub mod item;
|
||||
pub mod keyed;
|
||||
pub mod pure;
|
||||
|
|
|
@ -2,11 +2,11 @@ pub mod backing;
|
|||
pub mod queue;
|
||||
|
||||
use pyo3::prelude::*;
|
||||
use queue::pure::PureQueue;
|
||||
use queue::keyed::KeyedQueue;
|
||||
|
||||
/// Bindings for the Rust queue implementations
|
||||
#[pymodule]
|
||||
fn pyority_queue(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
||||
m.add_class::<PureQueue>()?;
|
||||
m.add_class::<KeyedQueue>()?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ use crate::backing::{
|
|||
use pyo3::prelude::*;
|
||||
|
||||
#[pyclass]
|
||||
pub struct PureQueue {
|
||||
pub struct KeyedQueue {
|
||||
backing: Box<dyn PureBacking<Item<Py<PyAny>, f64>>>,
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl PureQueue {
|
||||
impl KeyedQueue {
|
||||
#[new]
|
||||
fn new() -> Self {
|
||||
Self {
|
|
@ -1 +1 @@
|
|||
pub mod pure;
|
||||
pub mod keyed;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue