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§
Sourcefn value_at_index(&self, index: usize) -> Option<&V>
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.
Sourcefn iter(
&self,
) -> Box<dyn Iterator<Item = Item<<A as Axis>::BinInterval, &'_ V>> + '_>
fn iter( &self, ) -> Box<dyn Iterator<Item = Item<<A as Axis>::BinInterval, &'_ V>> + '_>
Iterator over bin indices, bin interval and bin values.
Sourcefn value_at_index_mut(&mut self, index: usize) -> Option<&mut V>
fn value_at_index_mut(&mut self, index: usize) -> Option<&mut V>
Mutable access to a bin value at a given index.
Sourcefn values_mut(&mut self) -> Box<dyn Iterator<Item = &'_ mut V> + '_>
fn values_mut(&mut self) -> Box<dyn Iterator<Item = &'_ mut V> + '_>
Mutable iterator over bin values.
Provided Methods§
Sourcefn value(&self, coordinate: &A::Coordinate) -> Option<&V>
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.
Sourcefn value_mut(&mut self, coordinate: &A::Coordinate) -> Option<&mut V>
fn value_mut(&mut self, coordinate: &A::Coordinate) -> Option<&mut V>
Mutable access to a bin value at a given coordinate.
Sourcefn fill(&mut self, coordinate: &A::Coordinate)where
V: Fill,
fn fill(&mut self, coordinate: &A::Coordinate)where
V: Fill,
Sourcefn fill_with<D>(&mut self, coordinate: &A::Coordinate, data: D)
fn fill_with<D>(&mut self, coordinate: &A::Coordinate, data: D)
Sourcefn fill_with_weighted<D, W>(
&mut self,
coordinate: &A::Coordinate,
data: D,
weight: W,
)where
V: FillWithWeighted<D, W>,
Self: Sized,
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.