Struct stats::Unsorted

source ·
pub struct Unsorted<T> { /* private fields */ }
Expand description

A commutative data structure for lazily sorted sequences of data.

The sort does not occur until statistics need to be computed.

Note that this works on types that do not define a total ordering like f32 and f64. When an ordering is not defined, an arbitrary order is returned.

Implementations§

source§

impl<T: PartialOrd> Unsorted<T>

source

pub fn new() -> Unsorted<T>

Create initial empty state.

source

pub fn add(&mut self, v: T)

Add a new element to the set.

source

pub fn len(&self) -> usize

Return the number of data points.

source§

impl<T: PartialOrd + Eq + Clone> Unsorted<T>

source

pub fn cardinality(&mut self) -> usize

source§

impl<T: PartialOrd + Clone> Unsorted<T>

source

pub fn mode(&mut self) -> Option<T>

Returns the mode of the data.

source

pub fn modes(&mut self) -> (Vec<T>, usize, u32)

Returns the modes of the data.

source

pub fn antimodes(&mut self) -> (Vec<T>, usize, u32)

Returns the antimodes of the data.

source§

impl<T: PartialOrd + ToPrimitive> Unsorted<T>

source

pub fn median(&mut self) -> Option<f64>

Returns the median of the data.

source§

impl<T: PartialOrd + ToPrimitive> Unsorted<T>

source

pub fn mad(&mut self, existing_median: Option<f64>) -> Option<f64>

Returns the MAD of the data.

source§

impl<T: PartialOrd + ToPrimitive> Unsorted<T>

source

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

Returns the quartiles of the data.

Trait Implementations§

source§

impl<T: Clone> Clone for Unsorted<T>

source§

fn clone(&self) -> Unsorted<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: PartialOrd> Commute for Unsorted<T>

source§

fn merge(&mut self, v: Unsorted<T>)

Merges the value other into self.
source§

fn consume<I: Iterator<Item = Self>>(&mut self, other: I)

Merges the values in the iterator into self.
source§

impl<T: Debug> Debug for Unsorted<T>

source§

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

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

impl<T: PartialOrd> Default for Unsorted<T>

source§

fn default() -> Unsorted<T>

Returns the “default value” for a type. Read more
source§

impl<'de, T> Deserialize<'de> for Unsorted<T>
where T: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T: PartialOrd> Extend<T> for Unsorted<T>

source§

fn extend<I: IntoIterator<Item = T>>(&mut self, it: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T: PartialOrd> FromIterator<T> for Unsorted<T>

source§

fn from_iter<I: IntoIterator<Item = T>>(it: I) -> Unsorted<T>

Creates a value from an iterator. Read more
source§

impl<T: PartialEq> PartialEq for Unsorted<T>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for Unsorted<T>
where T: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T: Eq> Eq for Unsorted<T>

source§

impl<T> StructuralPartialEq for Unsorted<T>

Auto Trait Implementations§

§

impl<T> Freeze for Unsorted<T>

§

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

§

impl<T> Send for Unsorted<T>

§

impl<T> Sync for Unsorted<T>

§

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

§

impl<T> UnwindSafe for Unsorted<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> 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.
§

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,

§

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>,

§

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>,

§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,