use crate::clustering::histogram::Histogram;
pub struct Centroid {
last: Histogram,
next: Histogram,
}
impl Centroid {
pub fn rotate(&mut self) {
self.last.destroy();
std::mem::swap(&mut self.last, &mut self.next);
}
pub fn absorb(&mut self, h: &Histogram) {
self.next.absorb(h);
}
pub fn reveal(&self) -> &Histogram {
&self.last
}
}
impl From<Histogram> for Centroid {
fn from(h: Histogram) -> Self {
Self {
last: h,
next: Histogram::default(),
}
}
}