[][src]Struct ndhistogram::axis::Category

pub struct Category<T> where
    T: Value, 
{ /* fields omitted */ }

An axis to represent a set of discrete values or categories with an overflow bin.

This axis also includes an overflow bin, to include "other" values. See CategoryNoFlow for a variant that includes no overflow bin.

Example

use ndhistogram::axis::{Axis, Category, SingleValueBinInterval};
let colors = Category::new(vec!["red", "blue", "pink", "yellow", "black"]);
assert_eq!(colors.index(&"red"), Some(0));
assert_eq!(colors.index(&"green"), Some(5));
assert_eq!(colors.bin(1), Some(SingleValueBinInterval::new("blue")));
assert_eq!(colors.bin(5), Some(SingleValueBinInterval::overflow()));

Implementations

impl<T: Value> Category<T>[src]

pub fn new<I: IntoIterator<Item = T>>(values: I) -> Self[src]

Factory method to create a category axis without an overflow bin.

Takes an iterator over a set of values that represent each category. All other values will be mapped to the overflow bin.

Trait Implementations

impl<T: Value> Axis for Category<T>[src]

type Coordinate = T

The type representing a location on this axis.

type BinInterval = SingleValueBinInterval<T>

The type of an interval representing the set of Coordinates that correspond to a histogram bin

impl<T: Clone> Clone for Category<T> where
    T: Value, 
[src]

impl<T: Debug> Debug for Category<T> where
    T: Value, 
[src]

impl<T: Default> Default for Category<T> where
    T: Value, 
[src]

impl<T: Display + Value> Display for Category<T>[src]

impl<'a, T: Value> IntoIterator for &'a Category<T>[src]

type Item = (usize, <Category<T> as Axis>::BinInterval)

The type of the elements being iterated over.

type IntoIter = Box<dyn Iterator<Item = Self::Item> + 'a>

Which kind of iterator are we turning this into?

impl<T: PartialEq> PartialEq<Category<T>> for Category<T> where
    T: Value, 
[src]

impl<T> StructuralPartialEq for Category<T> where
    T: Value, 
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Category<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for Category<T> where
    T: Send
[src]

impl<T> Sync for Category<T> where
    T: Sync
[src]

impl<T> Unpin for Category<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Category<T> where
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.