Trait plotters::coord::ranged1d::DiscreteRanged[][src]

pub trait DiscreteRanged where
    Self: Ranged
{ fn size(&self) -> usize;
fn index_of(&self, value: &Self::ValueType) -> Option<usize>;
fn from_index(&self, index: usize) -> Option<Self::ValueType>; fn values(&self) -> DiscreteValueIter<'_, Self>
    where
        Self: Sized
, { ... }
fn previous(&self, value: &Self::ValueType) -> Option<Self::ValueType> { ... }
fn next(&self, value: &Self::ValueType) -> Option<Self::ValueType> { ... } }
Expand description

The trait indicates the coordinate is discrete This means we can bidirectionally map the range value to 0 to N in which N is the number of distinct values of the range.

This is useful since for a histgoram, this is an abstraction of bucket.

Required methods

fn size(&self) -> usize[src]

Get the number of element in the range Note: we assume that all the ranged discrete coordinate has finite value

  • returns The number of values in the range

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

Map a value to the index

Note: This function doesn’t guareentee return None when the value is out of range. The only way to confirm the value is in the range is to examing the return value isn’t larger than self.size.

  • value: The value to map
  • returns The index of the value

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

Reverse map the index to the value

Note: This function doesn’t guareentee returning None when the index is out of range.

  • value: The index to map
  • returns The value

Provided methods

fn values(&self) -> DiscreteValueIter<'_, Self> where
    Self: Sized
[src]

Return a iterator that iterates over the all possible values

  • returns The value iterator

fn previous(&self, value: &Self::ValueType) -> Option<Self::ValueType>[src]

Returns the previous value in this range

Normally, it’s based on the from_index and index_of function. But for some of the coord spec, it’s possible that we value faster implementation. If this is the case, we can impelemnet the type specific impl for the previous and next.

  • value: The current value
  • returns: The value piror to current value

fn next(&self, value: &Self::ValueType) -> Option<Self::ValueType>[src]

Returns the next value in this range

Normally, it’s based on the from_index and index_of function. But for some of the coord spec, it’s possible that we value faster implementation. If this is the case, we can impelemnet the type specific impl for the previous and next.

  • value: The current value
  • returns: The value next to current value

Implementors

impl DiscreteRanged for RangedCoordi32[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

impl DiscreteRanged for RangedCoordi64[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

impl DiscreteRanged for RangedCoordi128[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

impl DiscreteRanged for RangedCoordu32[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

impl DiscreteRanged for RangedCoordu64[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

impl DiscreteRanged for RangedCoordu128[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

impl DiscreteRanged for RangedCoordusize[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

impl<'a, T: PartialEq> DiscreteRanged for RangedSlice<'a, T>[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &&'a T) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<&'a T>[src]

impl<D> DiscreteRanged for RangedDate<D> where
    D: Datelike + TimeValue + Sub<D, Output = Duration> + Add<Duration, Output = D> + Clone
[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &D) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<D>[src]

impl<D: DiscreteRanged> DiscreteRanged for SegmentedCoord<D>[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, idx: usize) -> Option<Self::ValueType>[src]

impl<P: DiscreteRanged, S: DiscreteRanged> DiscreteRanged for NestedRange<P, S>[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

impl<R: DiscreteRanged> DiscreteRanged for WithKeyPointMethod<R>[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

impl<R: DiscreteRanged> DiscreteRanged for WithKeyPoints<R> where
    R::ValueType: Clone
[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

impl<T: DiscreteRanged> DiscreteRanged for GroupBy<T>[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &Self::ValueType) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<Self::ValueType>[src]

impl<T: Ranged, S: Clone, R: LinspaceRoundingMethod<T::ValueType>> DiscreteRanged for Linspace<T, S, R> where
    T::ValueType: Add<S, Output = T::ValueType> + PartialOrd + Clone
[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &T::ValueType) -> Option<usize>[src]

fn from_index(&self, idx: usize) -> Option<T::ValueType>[src]

impl<T: TimeValue + Clone> DiscreteRanged for Monthly<T> where
    Range<T>: AsRangedCoord<Value = T>, 
[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &T) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<T>[src]

impl<T: TimeValue + Clone> DiscreteRanged for Yearly<T> where
    Range<T>: AsRangedCoord<Value = T>, 
[src]

fn size(&self) -> usize[src]

fn index_of(&self, value: &T) -> Option<usize>[src]

fn from_index(&self, index: usize) -> Option<T>[src]