[−][src]Struct ndhistogram::axis::Category
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
pub fn index(&self, coordinate: &Self::Coordinate) -> Option<usize>
[src]
pub fn numbins(&self) -> usize
[src]
pub fn bin(&self, index: usize) -> Option<Self::BinInterval>
[src]
pub fn indices(&self) -> Box<dyn Iterator<Item = usize>>
[src]
pub fn iter(&self) -> Box<dyn Iterator<Item = (usize, Self::BinInterval)> + '_>
[src]
pub fn bins(&self) -> Box<dyn Iterator<Item = Self::BinInterval> + '_>
[src]
impl<T: Clone> Clone for Category<T> where
T: Value,
[src]
T: Value,
impl<T: Debug> Debug for Category<T> where
T: Value,
[src]
T: Value,
impl<T: Default> Default for Category<T> where
T: Value,
[src]
T: Value,
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?
pub fn into_iter(self) -> Self::IntoIter
[src]
impl<T: PartialEq> PartialEq<Category<T>> for Category<T> where
T: Value,
[src]
T: Value,
pub fn eq(&self, other: &Category<T>) -> bool
[src]
pub fn ne(&self, other: &Category<T>) -> bool
[src]
impl<T> StructuralPartialEq for Category<T> where
T: Value,
[src]
T: Value,
Auto Trait Implementations
impl<T> RefUnwindSafe for Category<T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<T> Send for Category<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for Category<T> where
T: Sync,
[src]
T: Sync,
impl<T> Unpin for Category<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for Category<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,