use super::Temperature;
pub struct Linear {
temperature: f32,
constant: f32,
stopping: f32,
}
impl Linear {
pub fn new(temperature: f32, constant: f32, stopping_value: f32) -> Self {
Linear {
temperature,
constant,
stopping: stopping_value,
}
}
}
impl<T> Temperature<T> for Linear {
fn update(self, _: &T) -> Self {
Linear::new(
self.temperature - self.constant,
self.constant,
self.stopping,
)
}
fn temperature(&self) -> f32 {
self.temperature
}
fn stop(&self) -> bool {
self.temperature < self.stopping
}
}
pub struct Geometric {
temperature: f32,
constant: f32,
stopping: f32,
}
impl Geometric {
pub fn new(temperature: f32, constant: f32, stopping_value: f32) -> Self {
Geometric {
temperature,
constant,
stopping: stopping_value,
}
}
}
impl<T> Temperature<T> for Geometric {
fn update(self, _: &T) -> Self {
Geometric::new(
self.temperature * self.constant,
self.constant,
self.stopping,
)
}
fn temperature(&self) -> f32 {
self.temperature
}
fn stop(&self) -> bool {
self.temperature < self.stopping
}
}