pub trait Binning<T> {
// Required methods
fn get_bin_index<V: Borrow<T>>(&self, val: V) -> Option<usize>;
fn get_bin_len(&self) -> usize;
fn bin_iter(&self) -> Box<dyn Iterator<Item = Bin<T>>>;
fn is_inside<V: Borrow<T>>(&self, val: V) -> bool;
fn not_inside<V: Borrow<T>>(&self, val: V) -> bool;
fn first_border(&self) -> T;
fn last_border(&self) -> T;
fn last_border_is_inclusive(&self) -> bool;
fn distance<V: Borrow<T>>(&self, val: V) -> f64;
}
Expand description
Implements Binning
- Part of a histogram, but without the capability of counting stuff
Note
- Currently binning is not used in this lib. But I plan to Refactor the histograms in the next breaking release such that one only has to implement Binning and can create a histogram from that
Required Methods§
sourcefn get_bin_index<V: Borrow<T>>(&self, val: V) -> Option<usize>
fn get_bin_index<V: Borrow<T>>(&self, val: V) -> Option<usize>
convert val to the respective binning index
sourcefn get_bin_len(&self) -> usize
fn get_bin_len(&self) -> usize
Get the number of underlying bins
- note: if more than usize::MAX bins are there, usize::MAX is returned
sourcefn bin_iter(&self) -> Box<dyn Iterator<Item = Bin<T>>>
fn bin_iter(&self) -> Box<dyn Iterator<Item = Bin<T>>>
Iterates over all bins
- Note: Most (currently all) implementations use more efficient representations of the bins underneath, but are capable of returning the bins in this representation on request
- Also look if the Binning you use implements another method for the bin borders, e.g.,
single_valued_bin_iter
, as that is more efficient
sourcefn not_inside<V: Borrow<T>>(&self, val: V) -> bool
fn not_inside<V: Borrow<T>>(&self, val: V) -> bool
Opposite of is_inside
sourcefn first_border(&self) -> T
fn first_border(&self) -> T
get the left most border (inclusive)
sourcefn last_border(&self) -> T
fn last_border(&self) -> T
- get last border from the right
- Note: this border might be inclusive or exclusive
sourcefn last_border_is_inclusive(&self) -> bool
fn last_border_is_inclusive(&self) -> bool
True if last border is inclusive, false otherwise
- For most usecases this will return a constant value, as this is likely only dependent on the underlying type and not on something that changes dynamically
sourcefn distance<V: Borrow<T>>(&self, val: V) -> f64
fn distance<V: Borrow<T>>(&self, val: V) -> f64
calculates some sort of absolute distance to the nearest valid bin
- any invalid numbers (like NAN or INFINITY) should have the highest distance possible
- if a value corresponds to a valid bin, the distance should be zero
Object Safety§
This trait is not object safe.