diff --git a/src/backing/indexed/binary_heap.rs b/src/backing/indexed/binary_heap.rs deleted file mode 100644 index e5ec273..0000000 --- a/src/backing/indexed/binary_heap.rs +++ /dev/null @@ -1,53 +0,0 @@ -use std::{collections::HashMap, hash::Hash}; - -use crate::backing::{containers::Pair, indexed::IndexedBacking, pure::PureBacking}; - -pub struct IndexedBinaryHeap { - data: Vec>, - indices: HashMap, -} - -impl IndexedBinaryHeap { - pub fn new() -> Self { - Self { - data: Vec::new(), - indices: HashMap::new(), - } - } -} - -impl FromIterator> - for IndexedBinaryHeap -{ - fn from_iter>>(iter: T) -> Self { - todo!() - } -} - -impl PureBacking> - for IndexedBinaryHeap -{ - fn add(&mut self, item: Pair) { - todo!() - } - - fn pop(&mut self) -> Option> { - todo!() - } - - fn len(&self) -> usize { - todo!() - } -} - -impl IndexedBacking - for IndexedBinaryHeap -{ - fn update(&mut self, data: D, priority: P) -> bool { - todo!() - } - - fn remove(&mut self, data: D) -> bool { - todo!() - } -} diff --git a/src/backing/indexed/mod.rs b/src/backing/indexed/mod.rs index 1a39cb0..6579634 100644 --- a/src/backing/indexed/mod.rs +++ b/src/backing/indexed/mod.rs @@ -1,8 +1,4 @@ /// Data structures for the "indexed" min-queues, supporting priority updates and arbitrary removals, but no duplicates -mod binary_heap; - -pub use binary_heap::IndexedBinaryHeap; - use super::{containers::Pair, pure::PureBacking}; /// A data structure usable for backing an "indexed" queue @@ -10,7 +6,7 @@ pub trait IndexedBacking> { /// Update an item's priority - fn update(&mut self, data: D, priority: P) -> bool; + fn update(data: D, priority: P) -> Result<(), ()>; /// Remove an item from the queue - fn remove(&mut self, data: D) -> bool; + fn remove(data: D) -> bool; } diff --git a/src/queue/indexed.rs b/src/queue/indexed.rs index c1f433f..086ad0f 100644 --- a/src/queue/indexed.rs +++ b/src/queue/indexed.rs @@ -1,67 +1,12 @@ -use pyo3::{ - exceptions::{PyIndexError, PyStopIteration}, - prelude::*, - types::PyType, -}; - -use crate::backing::indexed::IndexedBacking; +use pyo3::prelude::*; #[pyclass] -pub struct IndexedQueue { - backing: Box, f64>>, -} +pub struct IndexedQueue {} #[pymethods] impl IndexedQueue { #[new] - #[pyo3(signature = (items=None))] - fn new(items: Option>) -> PyResult { - if let Some(py_object) = items { - todo!() - } else { - todo!() // TBD: Determine best way to make Python object hashable from Rust - } - } - - fn __setitem__(mut self_: PyRefMut<'_, Self>, key: Py, value: Py) { - todo!() - } - - fn __delitem__(mut self_: PyRefMut<'_, Self>, key: Py) { - todo!() - } - - fn __contains__(mut self_: PyRefMut<'_, Self>, key: Py) { - todo!() - } - - /// Enables generic typing - #[classmethod] - fn __class_getitem__(cls_: Bound<'_, PyType>, _key: Py) -> Bound<'_, PyType> { - cls_ - } - - fn __len__(self_: PyRef<'_, Self>) -> usize { - self_.backing.len() - } - - fn __iter__(self_: PyRef<'_, Self>) -> PyRef<'_, Self> { - self_ - } - - fn __next__(mut self_: PyRefMut<'_, Self>) -> PyResult> { - if let Some(item) = self_.backing.pop() { - Ok(item.data()) - } else { - Err(PyErr::new::(())) - } - } - - fn pop(mut self_: PyRefMut<'_, Self>) -> PyResult> { - if let Some(item) = self_.backing.pop() { - Ok(item.data()) - } else { - Err(PyErr::new::(())) - } + fn new() -> Self { + Self {} } }