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§

Create initial empty state.

Examples found in repository?
src/unsorted.rs (line 361)
360
361
362
363
364
    fn from_iter<I: IntoIterator<Item = T>>(it: I) -> Unsorted<T> {
        let mut v = Unsorted::new();
        v.extend(it);
        v
    }

Add a new element to the set.

Return the number of data points.

Return true if empty.

Returns the mode of the data.

Examples found in repository?
src/unsorted.rs (line 39)
34
35
36
37
38
39
40
pub fn mode<T, I>(it: I) -> Option<T>
where
    T: PartialOrd + Clone,
    I: Iterator<Item = T>,
{
    it.collect::<Unsorted<T>>().mode()
}

Returns the modes of the data.

Examples found in repository?
src/unsorted.rs (line 64)
59
60
61
62
63
64
65
pub fn modes<T, I>(it: I) -> Vec<T>
where
    T: PartialOrd + Clone,
    I: Iterator<Item = T>,
{
    it.collect::<Unsorted<T>>().modes()
}

Returns the median of the data.

Examples found in repository?
src/unsorted.rs (line 15)
10
11
12
13
14
15
16
pub fn median<I>(it: I) -> Option<f64>
where
    I: Iterator,
    <I as Iterator>::Item: PartialOrd + ToPrimitive,
{
    it.collect::<Unsorted<_>>().median()
}

Returns the quartiles of the data.

Examples found in repository?
src/unsorted.rs (line 26)
21
22
23
24
25
26
27
pub fn quartiles<I>(it: I) -> Option<(f64, f64, f64)>
where
    I: Iterator,
    <I as Iterator>::Item: PartialOrd + ToPrimitive,
{
    it.collect::<Unsorted<_>>().quartiles()
}

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Merges the value other into self.
Merges the values in the iterator into self.
Returns the “default value” for a type. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.