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>
impl<T: PartialOrd> Unsorted<T>
pub fn is_empty(&self) -> bool
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrink capacity to fit current data
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create with specific capacity
Sourcepub fn push_ascending(&mut self, value: T)
pub fn push_ascending(&mut self, value: T)
Add a value assuming it’s greater than all existing values
Source§impl<T: PartialOrd + PartialEq + Clone> Unsorted<T>
impl<T: PartialOrd + PartialEq + Clone> Unsorted<T>
Sourcepub fn cardinality(&mut self, sorted: bool, parallel_threshold: usize) -> u64
pub fn cardinality(&mut self, sorted: bool, parallel_threshold: usize) -> u64
Returns the cardinality of the data.
Set sorted
to true
if the data is already sorted.
Set parallel_threshold
to 0
to force sequential processing.
Set parallel_threshold
to 1
to use the default parallel threshold (10_000
).
Set parallel_threshold
to 2
to force parallel processing.
Set parallel_threshold
to any other value to use a custom parallel threshold
greater than the default threshold of 10_000
.
Source§impl<T: PartialOrd + Clone> Unsorted<T>
impl<T: PartialOrd + Clone> Unsorted<T>
Source§impl<T: PartialOrd + ToPrimitive> Unsorted<T>
impl<T: PartialOrd + ToPrimitive> Unsorted<T>
Source§impl<T: PartialOrd + ToPrimitive> Unsorted<T>
impl<T: PartialOrd + ToPrimitive> Unsorted<T>
Source§impl<T: PartialOrd + ToPrimitive> Unsorted<T>
impl<T: PartialOrd + ToPrimitive> Unsorted<T>
Source§impl<T: PartialOrd + Clone> Unsorted<T>
impl<T: PartialOrd + Clone> Unsorted<T>
Sourcepub fn custom_percentiles(&mut self, percentiles: &[u8]) -> Option<Vec<T>>
pub fn custom_percentiles(&mut self, percentiles: &[u8]) -> Option<Vec<T>>
Returns the requested percentiles of the data.
Uses the nearest-rank method to compute percentiles. Each returned value is an actual value from the dataset.
§Arguments
percentiles
- A slice of u8 values representing percentiles to compute (0-100)
§Returns
None
if the data is empty or if any percentile is > 100Some(Vec<T>)
containing percentile values in the same order as requested
§Example
use stats::Unsorted;
let mut data = Unsorted::new();
data.extend(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
let percentiles = vec![25, 50, 75];
let results = data.custom_percentiles(&percentiles).unwrap();
assert_eq!(results, vec![3, 5, 8]);
Trait Implementations§
Source§impl<T: PartialOrd> Commute for Unsorted<T>
impl<T: PartialOrd> Commute for Unsorted<T>
Source§impl<T: PartialOrd> Default for Unsorted<T>
impl<T: PartialOrd> Default for Unsorted<T>
Source§impl<'de, T> Deserialize<'de> for Unsorted<T>where
T: Deserialize<'de>,
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>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T: PartialOrd> Extend<T> for Unsorted<T>
impl<T: PartialOrd> Extend<T> for Unsorted<T>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, it: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, it: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<T: PartialOrd> FromIterator<T> for Unsorted<T>
impl<T: PartialOrd> FromIterator<T> for Unsorted<T>
impl<T: Eq> Eq for Unsorted<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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