use binary heap with a type that doesn't implement Ord?
I'm creating a cli board game and I'm writing a simple minimax to play the game. Before evaluating the moves possible from a position, I want to sort them from best to worst and I thought to use a binary heap instead of pushing everything into a vector and then sort it.
- Is there a struct in std like BinaryHeap<T> where T doesn't have to implement ord and instead you assign each value a "priority value"?
- Is there a general struct in std that represents value with priority?:
struct Prioritized<T> {
priority: u32,
value: T
}
impl<T> PartialEq for Prioritized<T> {
fn eq(&self, other: &Self) -> bool {
self.priority.eq(&other.priority)
}
}
impl<T> Eq for Prioritized<T> {}
impl<T> PartialOrd for Prioritized<T> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.priority.partial_cmp(&other.priority)
}
}
impl<T> Ord for Prioritized<T> {
fn cmp(&self, other: &Self) -> Ordering {
self.priority.cmp(&other.priority)
}
}