Struct sampling::histogram::FastSingleIntBinning
source · pub struct FastSingleIntBinning<T> { /* private fields */ }
Expand description
Generic binning meant for any integer type
Implementations§
source§impl FastSingleIntBinning<u8>
impl FastSingleIntBinning<u8>
sourcepub const fn new_inclusive(start: u8, end_inclusive: u8) -> Self
pub const fn new_inclusive(start: u8, end_inclusive: u8) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<u8>
pub const fn range_inclusive(&self) -> RangeInclusive<u8>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = u8>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = u8>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningU8;
let binning = FastBinningU8::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <u8 as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <u8 as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
source§impl FastSingleIntBinning<i8>
impl FastSingleIntBinning<i8>
sourcepub const fn new_inclusive(start: i8, end_inclusive: i8) -> Self
pub const fn new_inclusive(start: i8, end_inclusive: i8) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<i8>
pub const fn range_inclusive(&self) -> RangeInclusive<i8>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = i8>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = i8>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningI8;
let binning = FastBinningI8::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <i8 as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <i8 as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
source§impl FastSingleIntBinning<u16>
impl FastSingleIntBinning<u16>
sourcepub const fn new_inclusive(start: u16, end_inclusive: u16) -> Self
pub const fn new_inclusive(start: u16, end_inclusive: u16) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<u16>
pub const fn range_inclusive(&self) -> RangeInclusive<u16>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = u16>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = u16>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningU16;
let binning = FastBinningU16::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <u16 as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <u16 as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
source§impl FastSingleIntBinning<i16>
impl FastSingleIntBinning<i16>
sourcepub const fn new_inclusive(start: i16, end_inclusive: i16) -> Self
pub const fn new_inclusive(start: i16, end_inclusive: i16) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<i16>
pub const fn range_inclusive(&self) -> RangeInclusive<i16>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = i16>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = i16>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningI16;
let binning = FastBinningI16::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <i16 as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <i16 as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
source§impl FastSingleIntBinning<u32>
impl FastSingleIntBinning<u32>
sourcepub const fn new_inclusive(start: u32, end_inclusive: u32) -> Self
pub const fn new_inclusive(start: u32, end_inclusive: u32) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<u32>
pub const fn range_inclusive(&self) -> RangeInclusive<u32>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = u32>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = u32>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningU32;
let binning = FastBinningU32::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <u32 as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <u32 as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
source§impl FastSingleIntBinning<i32>
impl FastSingleIntBinning<i32>
sourcepub const fn new_inclusive(start: i32, end_inclusive: i32) -> Self
pub const fn new_inclusive(start: i32, end_inclusive: i32) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<i32>
pub const fn range_inclusive(&self) -> RangeInclusive<i32>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = i32>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = i32>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningI32;
let binning = FastBinningI32::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <i32 as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <i32 as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
source§impl FastSingleIntBinning<u64>
impl FastSingleIntBinning<u64>
sourcepub const fn new_inclusive(start: u64, end_inclusive: u64) -> Self
pub const fn new_inclusive(start: u64, end_inclusive: u64) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<u64>
pub const fn range_inclusive(&self) -> RangeInclusive<u64>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = u64>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = u64>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningU64;
let binning = FastBinningU64::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <u64 as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <u64 as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
source§impl FastSingleIntBinning<i64>
impl FastSingleIntBinning<i64>
sourcepub const fn new_inclusive(start: i64, end_inclusive: i64) -> Self
pub const fn new_inclusive(start: i64, end_inclusive: i64) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<i64>
pub const fn range_inclusive(&self) -> RangeInclusive<i64>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = i64>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = i64>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningI64;
let binning = FastBinningI64::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <i64 as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <i64 as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
source§impl FastSingleIntBinning<u128>
impl FastSingleIntBinning<u128>
sourcepub const fn new_inclusive(start: u128, end_inclusive: u128) -> Self
pub const fn new_inclusive(start: u128, end_inclusive: u128) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<u128>
pub const fn range_inclusive(&self) -> RangeInclusive<u128>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = u128>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = u128>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningU128;
let binning = FastBinningU128::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <u128 as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <u128 as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
source§impl FastSingleIntBinning<i128>
impl FastSingleIntBinning<i128>
sourcepub const fn new_inclusive(start: i128, end_inclusive: i128) -> Self
pub const fn new_inclusive(start: i128, end_inclusive: i128) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<i128>
pub const fn range_inclusive(&self) -> RangeInclusive<i128>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = i128>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = i128>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningI128;
let binning = FastBinningI128::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <i128 as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <i128 as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
source§impl FastSingleIntBinning<usize>
impl FastSingleIntBinning<usize>
sourcepub const fn new_inclusive(start: usize, end_inclusive: usize) -> Self
pub const fn new_inclusive(start: usize, end_inclusive: usize) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<usize>
pub const fn range_inclusive(&self) -> RangeInclusive<usize>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = usize>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = usize>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningUSIZE;
let binning = FastBinningUSIZE::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <usize as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <usize as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
source§impl FastSingleIntBinning<isize>
impl FastSingleIntBinning<isize>
sourcepub const fn new_inclusive(start: isize, end_inclusive: isize) -> Self
pub const fn new_inclusive(start: isize, end_inclusive: isize) -> Self
Create a new Binning
- both borders are inclusive
- each bin has width 1
Panics
- if
start
is smaller thanend_inclusive
TODO Think about if this should actually panic or return None
sourcepub const fn range_inclusive(&self) -> RangeInclusive<isize>
pub const fn range_inclusive(&self) -> RangeInclusive<isize>
sourcepub fn single_valued_bin_iter(&self) -> impl Iterator<Item = isize>
pub fn single_valued_bin_iter(&self) -> impl Iterator<Item = isize>
Iterator over all the bins
Since the bins have width 1, a bin can be defined by its corresponding value which we can iterate over.
Example
use sampling::histogram::FastBinningISIZE;
let binning = FastBinningISIZE::new_inclusive(2,5);
let vec: Vec<_> = binning.single_valued_bin_iter().collect();
assert_eq!(&vec, &[2, 3, 4, 5]);
sourcepub fn bins_m1(&self) -> <isize as HasUnsignedVersion>::Unsigned
pub fn bins_m1(&self) -> <isize as HasUnsignedVersion>::Unsigned
The amount of bins -1
- minus 1 because if the bins are going over the entire range of the type, then I cannot represent the number of bins as this type
Example
If we look at an u8 and the range from 0 to 255, then this is 256 bins, which cannot be represented as u8. To combat this, I return bins - 1. This works, because we always have at least 1 bin
Trait Implementations§
source§impl<T: Clone> Clone for FastSingleIntBinning<T>
impl<T: Clone> Clone for FastSingleIntBinning<T>
source§fn clone(&self) -> FastSingleIntBinning<T>
fn clone(&self) -> FastSingleIntBinning<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: Debug> Debug for FastSingleIntBinning<T>
impl<T: Debug> Debug for FastSingleIntBinning<T>
source§impl<'de, T> Deserialize<'de> for FastSingleIntBinning<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for FastSingleIntBinning<T>where
T: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<T: Ord> Ord for FastSingleIntBinning<T>
impl<T: Ord> Ord for FastSingleIntBinning<T>
source§fn cmp(&self, other: &FastSingleIntBinning<T>) -> Ordering
fn cmp(&self, other: &FastSingleIntBinning<T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<T: PartialEq> PartialEq for FastSingleIntBinning<T>
impl<T: PartialEq> PartialEq for FastSingleIntBinning<T>
source§fn eq(&self, other: &FastSingleIntBinning<T>) -> bool
fn eq(&self, other: &FastSingleIntBinning<T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<T: PartialOrd> PartialOrd for FastSingleIntBinning<T>
impl<T: PartialOrd> PartialOrd for FastSingleIntBinning<T>
source§fn partial_cmp(&self, other: &FastSingleIntBinning<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &FastSingleIntBinning<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more