31 lines
499 B
Rust
31 lines
499 B
Rust
|
|
#[derive(Clone,Copy,Debug)]
|
|
pub struct ScoreItem {
|
|
pub index: usize,
|
|
pub value: f64,
|
|
}
|
|
|
|
impl ScoreItem {
|
|
pub fn new(index: usize, value: f64) -> Self {
|
|
Self { index, value }
|
|
}
|
|
pub fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
|
self.value.total_cmp(&other.value)
|
|
}
|
|
pub fn max(self, other: Self) -> Self {
|
|
if self.value > other.value {
|
|
self
|
|
} else {
|
|
other
|
|
}
|
|
}
|
|
pub fn min(self, other: Self) -> Self {
|
|
if self.value > other.value {
|
|
other
|
|
} else {
|
|
self
|
|
}
|
|
}
|
|
}
|
|
|