Trait MapValidVec

Source
pub trait MapValidVec<T: IsNone>: Vec1View<T> {
    // Provided methods
    fn vdiff<'a>(
        &'a self,
        n: i32,
        value: Option<T>,
    ) -> Box<dyn TrustedLen<Item = T> + 'a>
       where T: Clone + Sub<Output = T> + Zero + 'a,
             Self: 'a { ... }
    fn vpct_change<'a>(&'a self, n: i32) -> Box<dyn TrustedLen<Item = f64> + 'a>
       where T: Clone + Cast<f64> + 'a,
             Self: 'a { ... }
    fn vrank<O: Vec1<OT>, OT: IsNone>(&self, pct: bool, rev: bool) -> O
       where T: IsNone + PartialEq,
             T::Inner: PartialOrd,
             f64: Cast<OT> { ... }
    fn varg_partition<'a>(
        &'a self,
        kth: usize,
        sort: bool,
        rev: bool,
    ) -> Box<dyn TrustedLen<Item = i32> + 'a>
       where T::Inner: Number,
             T: 'a { ... }
    fn vpartition<'a>(
        &'a self,
        kth: usize,
        sort: bool,
        rev: bool,
    ) -> Box<dyn TrustedLen<Item = T> + 'a>
       where T::Inner: PartialOrd,
             T: 'a { ... }
}
Expand description

Trait for vector-like types that support map operations on valid elements.

This trait provides methods for performing various operations on vectors, such as calculating differences, percentage changes, rankings, and partitions.

Provided Methods§

Source

fn vdiff<'a>( &'a self, n: i32, value: Option<T>, ) -> Box<dyn TrustedLen<Item = T> + 'a>
where T: Clone + Sub<Output = T> + Zero + 'a, Self: 'a,

Calculates the difference between elements in the vector.

§Arguments
  • n - The lag for the difference calculation. Positive values look forward, negative values look backward.
  • value - The value to use for padding when there are not enough elements.
§Returns

A boxed iterator of differences.

Source

fn vpct_change<'a>(&'a self, n: i32) -> Box<dyn TrustedLen<Item = f64> + 'a>
where T: Clone + Cast<f64> + 'a, Self: 'a,

Calculates the percentage change between elements in the vector.

§Arguments
  • n - The lag for the percentage change calculation. Positive values look forward, negative values look backward.
§Returns

A boxed iterator of percentage changes.

Source

fn vrank<O: Vec1<OT>, OT: IsNone>(&self, pct: bool, rev: bool) -> O
where T: IsNone + PartialEq, T::Inner: PartialOrd, f64: Cast<OT>,

Calculates the rank of elements in the vector.

§Arguments
  • pct - If true, returns percentage ranks.
  • rev - If true, ranks in descending order.
§Returns

A vector of ranks.

Source

fn varg_partition<'a>( &'a self, kth: usize, sort: bool, rev: bool, ) -> Box<dyn TrustedLen<Item = i32> + 'a>
where T::Inner: Number, T: 'a,

Returns the indices of the kth smallest elements.

§Arguments
  • kth - The k-th smallest element to find.
  • sort - If true, sort the result.
  • rev - If true, find the kth largest elements instead.
§Returns

A boxed iterator of indices.

Source

fn vpartition<'a>( &'a self, kth: usize, sort: bool, rev: bool, ) -> Box<dyn TrustedLen<Item = T> + 'a>
where T::Inner: PartialOrd, T: 'a,

sort: whether to sort the result by the size of the element

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: IsNone, I: Vec1View<T>> MapValidVec<T> for I