Add more container functions to support future indexed binary heap
This commit is contained in:
parent
d8fef9b806
commit
d56d2cf117
2 changed files with 18 additions and 2 deletions
|
@ -13,11 +13,25 @@ impl<D: Clone, P: PartialOrd + Clone> Pair<D, P> {
|
||||||
Self { data, priority }
|
Self { data, priority }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the internal data.
|
/// Returns 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.
|
/// 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 {
|
pub fn data(self) -> D {
|
||||||
self.data
|
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<D: Clone, P: PartialOrd + Clone> PartialOrd for Pair<D, P> {
|
impl<D: Clone, P: PartialOrd + Clone> PartialOrd for Pair<D, P> {
|
||||||
|
|
|
@ -48,6 +48,8 @@ impl PartialEq for PyItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Eq for PyItem {}
|
||||||
|
|
||||||
impl Hash for PyItem {
|
impl Hash for PyItem {
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
// TODO: Should warn or fail instead of defaulting to 0
|
// TODO: Should warn or fail instead of defaulting to 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue