From d56d2cf117f58df0d6847a386662f45c8be91d5c Mon Sep 17 00:00:00 2001 From: Michael Bradley Date: Fri, 31 Jan 2025 01:01:10 -0500 Subject: [PATCH] Add more container functions to support future indexed binary heap --- src/backing/containers/pair.rs | 18 ++++++++++++++++-- src/backing/containers/py_item.rs | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/backing/containers/pair.rs b/src/backing/containers/pair.rs index d194835..190cd7b 100644 --- a/src/backing/containers/pair.rs +++ b/src/backing/containers/pair.rs @@ -13,11 +13,25 @@ impl Pair { Self { data, priority } } - /// Retrieves the internal data. - /// It would be nicer to implement this using [`From`] or [`Into`], but I don't see a way to do that using generics. + /// Returns the internal data. + /// It might(?) be nicer to implement this using [`From`] or [`Into`], but I don't see a way to do that using generics. pub fn data(self) -> D { self.data } + + pub fn get_data(&self) -> &D { + &self.data + } + + /// Retrieve the priority associated with the data + pub fn get_priority(&self) -> &P { + &self.priority + } + + /// Update the priority associated with the data + pub fn set_priority(&mut self, priority: P) { + self.priority = priority + } } impl PartialOrd for Pair { diff --git a/src/backing/containers/py_item.rs b/src/backing/containers/py_item.rs index 363c853..f67c853 100644 --- a/src/backing/containers/py_item.rs +++ b/src/backing/containers/py_item.rs @@ -48,6 +48,8 @@ impl PartialEq for PyItem { } } +impl Eq for PyItem {} + impl Hash for PyItem { fn hash(&self, state: &mut H) { // TODO: Should warn or fail instead of defaulting to 0