use std::cmp::Ordering;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone)]
pub struct PriorityQueueItem<K, V> {
pub cost: K,
pub value: V,
}
impl<K: Ord, V: Ord> PartialOrd for PriorityQueueItem<K, V> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<K: Ord, V: Ord> Ord for PriorityQueueItem<K, V> {
fn cmp(&self, other: &Self) -> Ordering {
let ord = other.cost.cmp(&self.cost);
if ord != Ordering::Equal {
return ord;
}
self.value.cmp(&other.value)
}
}