pub trait Histogram<A: Axis, V> {
    // Required methods
    fn axes(&self) -> &A;
    fn value_at_index(&self, index: usize) -> Option<&V>;
    fn values(&self) -> Box<dyn Iterator<Item = &'_ V> + '_>;
    fn iter(
        &self
    ) -> Box<dyn Iterator<Item = Item<<A as Axis>::BinInterval, &'_ V>> + '_>;
    fn value_at_index_mut(&mut self, index: usize) -> Option<&mut V>;
    fn values_mut(&mut self) -> Box<dyn Iterator<Item = &'_ mut V> + '_>;
    fn iter_mut(
        &mut self
    ) -> Box<dyn Iterator<Item = Item<<A as Axis>::BinInterval, &'_ mut V>> + '_>;

    // Provided methods
    fn value(&self, coordinate: &A::Coordinate) -> Option<&V> { ... }
    fn value_mut(&mut self, coordinate: &A::Coordinate) -> Option<&mut V> { ... }
    fn fill(&mut self, coordinate: &A::Coordinate)
       where V: Fill { ... }
    fn fill_with<D>(&mut self, coordinate: &A::Coordinate, data: D)
       where V: FillWith<D>,
             Self: Sized { ... }
    fn fill_with_weighted<D, W>(
        &mut self,
        coordinate: &A::Coordinate,
        data: D,
        weight: W
    )
       where V: FillWithWeighted<D, W>,
             Self: Sized { ... }
}
Expand description

A common interface for an ND histograms.

Implementations of this trait should handle storing the histogram bin values and provide methods to fill and read those values.

The most commonly used implementation is VecHistogram. See crate::ndhistogram for examples of its use.

Required Methods§

source

fn axes(&self) -> &A

The histogram Axes that map coordinates to bin numbers.

source

fn value_at_index(&self, index: usize) -> Option<&V>

Read a bin value given an index. Return an Option as the given index may not be valid for this histogram.

source

fn values(&self) -> Box<dyn Iterator<Item = &'_ V> + '_>

Iterator over bin values.

source

fn iter( &self ) -> Box<dyn Iterator<Item = Item<<A as Axis>::BinInterval, &'_ V>> + '_>

Iterator over bin indices, bin interval and bin values.

source

fn value_at_index_mut(&mut self, index: usize) -> Option<&mut V>

Mutable access to a bin value at a given index.

source

fn values_mut(&mut self) -> Box<dyn Iterator<Item = &'_ mut V> + '_>

Mutable iterator over bin values.

source

fn iter_mut( &mut self ) -> Box<dyn Iterator<Item = Item<<A as Axis>::BinInterval, &'_ mut V>> + '_>

Mutable iterator over bin indices, bin interval and bin values.

Provided Methods§

source

fn value(&self, coordinate: &A::Coordinate) -> Option<&V>

Read a bin value given a coordinate. Returns an Option as the given coordinate may not be mapped to a bin.

source

fn value_mut(&mut self, coordinate: &A::Coordinate) -> Option<&mut V>

Mutable access to a bin value at a given coordinate.

source

fn fill(&mut self, coordinate: &A::Coordinate)where V: Fill,

Fill the histogram bin value at coordinate with unit weight. If the Axes do not cover that coordinate, do nothing. See Fill.

source

fn fill_with<D>(&mut self, coordinate: &A::Coordinate, data: D)where V: FillWith<D>, Self: Sized,

Fill the histogram bin value at coordinate with some data. If the Axes do not cover that coordinate, do nothing. See FillWith.

source

fn fill_with_weighted<D, W>( &mut self, coordinate: &A::Coordinate, data: D, weight: W )where V: FillWithWeighted<D, W>, Self: Sized,

Fill the histogram bin value at coordinate with some data. If the Axes do not cover that coordinate, do nothing. See FillWithWeighted.

Implementors§

source§

impl<A: Axis, V> Histogram<A, V> for VecHistogram<A, V>

source§

impl<A: Axis, V: Default> Histogram<A, V> for HashHistogram<A, V>