use CompactVec for all modes

This commit is contained in:
MaxOhn
2023-02-22 13:12:54 +01:00
parent de342f5c3d
commit bd9623d32b
9 changed files with 45 additions and 30 deletions
+7 -1
View File
@@ -10,7 +10,7 @@ pub(crate) struct CompactVec {
}
impl CompactVec {
const ACCEPTABLE_DIFFERENCE: f64 = 1e-7;
const ACCEPTABLE_DIFFERENCE: f64 = 1e-16;
pub(crate) fn new() -> Self {
Self::default()
@@ -54,6 +54,12 @@ impl CompactVec {
nums
}
pub(crate) fn sum(&self) -> f64 {
self.inner
.iter()
.fold(0.0, |sum, entry| sum + entry.value * entry.count as f64)
}
}
#[derive(Copy, Clone, Debug)]