pub struct DecayCounter { /* private fields */ }Expand description
A counter that decays exponentially over time.
Implementations§
Source§impl DecayCounter
impl DecayCounter
pub fn new(half_life: f32) -> Self
pub fn with_initial(value: f32, half_life: f32) -> Self
pub fn increment(&mut self, amount: f32)
pub fn update(&mut self, current_time: f32)
pub fn value(&self) -> f32
pub fn value_at(&self, time: f32) -> f32
pub fn half_life(&self) -> f32
pub fn set_half_life(&mut self, hl: f32)
pub fn reset(&mut self)
pub fn is_negligible(&self, threshold: f32) -> bool
pub fn time_to_reach(&self, target: f32) -> Option<f32>
Sourcepub fn decay_constant(&self) -> f32
pub fn decay_constant(&self) -> f32
Return the decay constant (lambda = ln(2)/half_life).
Trait Implementations§
Source§impl Clone for DecayCounter
impl Clone for DecayCounter
Source§fn clone(&self) -> DecayCounter
fn clone(&self) -> DecayCounter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DecayCounter
impl Debug for DecayCounter
impl Copy for DecayCounter
Auto Trait Implementations§
impl Freeze for DecayCounter
impl RefUnwindSafe for DecayCounter
impl Send for DecayCounter
impl Sync for DecayCounter
impl Unpin for DecayCounter
impl UnsafeUnpin for DecayCounter
impl UnwindSafe for DecayCounter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more