Struct Histogram

Source
pub struct Histogram<T>{ /* private fields */ }
Expand description

The Histogram consists of num_intervals intervals between the min and the max value.

Implementations§

Source§

impl<T> Histogram<T>

Source

pub fn new<'a>( elements: Option<&'a Vec<T>>, num_intervals: usize, min: T, max: T, ) -> Result<Histogram<T>, String>
where &'a T: Deref,

§Initializing with Known Boundaries

Creates a Histogram consisting of num_intervals intervals between the values min and max, and inserts the values from the vector of elements into the histogram. Values smaller than min will increment the counter num_less_than_min, while values larger than max will increment the counter num_larger_than_max

§Example
use math::histogram::Histogram;

let histogram =
    Histogram::new(Some(&vec![2, -1, 3, 5, 8]), 5, 0, 10).unwrap();
assert_eq!(histogram.get_boundaries().len(), 6);
assert_eq!(histogram.get_num_less_than_min(), 1);
assert_eq!(histogram.get_num_larger_than_max(), 0);
assert_eq!(histogram.get_min_received(), Some(-1));
assert_eq!(histogram.get_max_received(), Some(8));
Source

pub fn num_intervals(&self) -> usize

Source

pub fn get_ratios(&self) -> Vec<f64>

Source

pub fn new_with_auto_range<'a>( elements: &'a Vec<T>, num_intervals: usize, ) -> Result<Histogram<T>, String>
where &'a T: Deref, T: Ord,

Source

pub fn get_boundaries(&self) -> &Vec<T>

Source

pub fn get_counters(&self) -> &Vec<usize>

Source

pub fn get_num_less_than_min(&self) -> usize

Source

pub fn get_num_larger_than_max(&self) -> usize

Source

pub fn get_min_received(&self) -> Option<T>

Source

pub fn get_max_received(&self) -> Option<T>

Source

pub fn min_boundary(&self) -> T

Source

pub fn max_boundary(&self) -> T

Trait Implementations§

Source§

impl<T> Clone for Histogram<T>

Source§

fn clone(&self) -> Histogram<T>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Collecting<T> for Histogram<T>

Source§

fn collect(&mut self, item: T)

Source§

impl<T> Debug for Histogram<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Display for Histogram<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> PartialEq for Histogram<T>

Source§

fn eq(&self, other: &Histogram<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, T> ToIterator<'a, HistogramIter<'a, T>, (T, T, usize)> for Histogram<T>

Source§

fn to_iter(&'a self) -> HistogramIter<'a, T>

Source§

impl<T> Eq for Histogram<T>

Source§

impl<T> StructuralPartialEq for Histogram<T>

Auto Trait Implementations§

§

impl<T> Freeze for Histogram<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Histogram<T>
where T: RefUnwindSafe,

§

impl<T> Send for Histogram<T>
where T: Send,

§

impl<T> Sync for Histogram<T>
where T: Sync,

§

impl<T> Unpin for Histogram<T>
where T: Unpin,

§

impl<T> UnwindSafe for Histogram<T>
where T: UnwindSafe,

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

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

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V