pub struct Category<T>{ /* private fields */ }
Expand description
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 not given when the axis was constructed. 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§
Trait Implementations§
Source§impl<T: Value> Axis for Category<T>
impl<T: Value> Axis for Category<T>
Source§type Coordinate = T
type Coordinate = T
The type representing a location on this axis.
Source§type BinInterval = SingleValueBinInterval<T>
type BinInterval = SingleValueBinInterval<T>
The type of an interval representing the set of Coordinates that correspond to a histogram bin
Source§fn index(&self, coordinate: &Self::Coordinate) -> Option<usize>
fn index(&self, coordinate: &Self::Coordinate) -> Option<usize>
Map from coordinate to bin number.
Returns an option as not all valid coordinates are necessarily contained within a bin.
Source§fn num_bins(&self) -> usize
fn num_bins(&self) -> usize
The number of bins in this axis, including underflow and overflow.
Source§fn bin(&self, index: usize) -> Option<Self::BinInterval>
fn bin(&self, index: usize) -> Option<Self::BinInterval>
Map from bin number to axis to the interval covering the range of coordinates that this bin contains.
Returns an option in case an index >= Axis::num_bins is given.
Source§fn iter(&self) -> Box<dyn Iterator<Item = (usize, Self::BinInterval)> + '_>
fn iter(&self) -> Box<dyn Iterator<Item = (usize, Self::BinInterval)> + '_>
An iterator over bin numbers and bin intervals
Source§impl<'a, T: Value> IntoIterator for &'a Category<T>
impl<'a, T: Value> IntoIterator for &'a Category<T>
impl<T> Eq for Category<T>
impl<T> StructuralPartialEq for Category<T>
Auto Trait Implementations§
impl<T> Freeze for Category<T>
impl<T> RefUnwindSafe for Category<T>where
T: RefUnwindSafe,
impl<T> Send for Category<T>where
T: Send,
impl<T> Sync for Category<T>where
T: Sync,
impl<T> Unpin for Category<T>where
T: Unpin,
impl<T> UnwindSafe for Category<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
Mutably borrows from an owned value. Read more