Struct egui::util::History[][src]

pub struct History<T> { /* fields omitted */ }

This struct tracks recent values of some time series.

One use is to show a log of recent events, or show a graph over recent events.

It has both a maximum length and a maximum storage time. Elements are dropped when either max length or max age is reached.

Time difference between values can be zero, but never negative.

This can be used for things like smoothed averages (for e.g. FPS) or for smoothed velocity (e.g. mouse pointer speed). All times are in seconds.

Implementations

impl<T> History<T> where
    T: Copy
[src]

pub fn new(max_len: usize, max_age: f64) -> Self[src]

pub fn from_max_len_age(max_len: usize, max_age: f64) -> Self[src]

pub fn max_len(&self) -> usize[src]

pub fn max_age(&self) -> f32[src]

pub fn is_empty(&self) -> bool[src]

pub fn len(&self) -> usize[src]

Current number of values kept in history

pub fn total_count(&self) -> u64[src]

Total number of values seen. Includes those that have been discarded due to max_len or max_age.

pub fn latest(&self) -> Option<T>[src]

pub fn latest_mut(&mut self) -> Option<&mut T>[src]

pub fn duration(&self) -> f32[src]

Amount of time contained from start to end in this History.

pub fn iter(&self) -> impl Iterator<Item = (f64, T)> + '_[src]

(time, value) pairs Time difference between values can be zero, but never negative.

pub fn values(&self) -> impl Iterator<Item = T> + '_[src]

pub fn clear(&mut self)[src]

pub fn add(&mut self, now: f64, value: T)[src]

Values must be added with a monotonically increasing time, or at least not decreasing.

pub fn mean_time_interval(&self) -> Option<f32>[src]

Mean time difference between values in this History.

pub fn flush(&mut self, now: f64)[src]

Remove samples that are too old

impl<T> History<T> where
    T: Copy,
    T: Sum,
    T: Div<f32, Output = T>, 
[src]

pub fn sum(&self) -> T[src]

pub fn average(&self) -> Option<T>[src]

impl<T, Vel> History<T> where
    T: Copy,
    T: Sub<Output = Vel>,
    Vel: Div<f32, Output = Vel>, 
[src]

pub fn velocity(&self) -> Option<Vel>[src]

Calculate a smooth velocity (per second) over the entire time span

Trait Implementations

impl<T: Clone> Clone for History<T>[src]

fn clone(&self) -> History<T>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T: Debug> Debug for History<T>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<T> RefUnwindSafe for History<T> where
    T: RefUnwindSafe

impl<T> Send for History<T> where
    T: Send

impl<T> Sync for History<T> where
    T: Sync

impl<T> Unpin for History<T> where
    T: Unpin

impl<T> UnwindSafe for History<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.