Skip to main content

SeriesBuf

Struct SeriesBuf 

Source
pub struct SeriesBuf { /* private fields */ }
Expand description

a time series for line_chart: (t, value) points in a ring that keeps the newest capacity (a full buffer drops its oldest point on push). Times never decrease (push refuses an earlier one, so every lookup is a binary search); a value that is not finite (NaN) is a gap where the line breaks. ver() changes with every change: a chart redraws only then.

Implementations§

Source§

impl SeriesBuf

Source

pub fn new(capacity: usize) -> SeriesBuf

an empty series that keeps the newest capacity points (at least one)

Source

pub fn push(&mut self, t: f64, v: f64) -> bool

append a point (t: the time, or any x that never decreases; v NaN: a gap); false (nothing added) when t is not finite or earlier than the last point’s

Source

pub fn clear(&mut self)

remove every point

Source

pub fn len(&self) -> usize

the number of points

Source

pub fn is_empty(&self) -> bool

no points

Source

pub fn capacity(&self) -> usize

the most points it keeps

Source

pub fn ver(&self) -> u32

changes with every push and clear (equal versions: equal points)

Source

pub fn get(&self, i: usize) -> Option<(f64, f64)>

the i-th point, the oldest first

Source

pub fn first(&self) -> Option<(f64, f64)>

the oldest point

Source

pub fn last(&self) -> Option<(f64, f64)>

the newest point

Source

pub fn iter( &self, ) -> impl DoubleEndedIterator<Item = (f64, f64)> + ExactSizeIterator + '_

the points, the oldest first

Source

pub fn lower_bound(&self, t: f64) -> usize

the index of the first point at t or later (len() when there is none)

Source

pub fn nearest(&self, t: f64) -> Option<usize>

the index of the point with a finite value nearest to t (of two as near the earlier)

Source

pub fn min_max(&self) -> Option<(f64, f64)>

the smallest and the largest finite value (None without one); looks at every point

Source

pub fn min_max_in(&self, t0: f64, t1: f64) -> Option<(f64, f64)>

the smallest and the largest finite value of the points with t0 <= t <= t1

Source

pub fn columns(&self, t0: f64, t1: f64, n: usize) -> Vec<SeriesCol>

the points with t0 <= t <= t1 in n columns of equal width (t1 belongs to the last): per column the range of its values, its first and its last value. Columns without a point with a value are left out; the work is one pass over the points, the result at most n entries (plus one per gap)

Trait Implementations§

Source§

impl Clone for SeriesBuf

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SeriesBuf

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.