[][src]Trait rand_distr::weighted_alias::AliasableWeight

pub trait AliasableWeight: Sized + Copy + SampleUniform + PartialOrd + Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign + Mul<Output = Self> + MulAssign + Div<Output = Self> + DivAssign + Sum {
    pub const MAX: Self;
    pub const ZERO: Self;

    pub fn try_from_u32_lossy(n: u32) -> Option<Self>;

    pub fn sum(values: &[Self]) -> Self { ... }
}

Trait that must be implemented for weights, that are used with WeightedAliasIndex. Currently no guarantees on the correctness of WeightedAliasIndex are given for custom implementations of this trait.

Associated Constants

pub const MAX: Self[src]

Maximum number representable by Self.

pub const ZERO: Self[src]

Element of Self equivalent to 0.

Loading content...

Required methods

pub fn try_from_u32_lossy(n: u32) -> Option<Self>[src]

Produce an instance of Self from a u32 value, or return None if out of range. Loss of precision (where Self is a floating point type) is acceptable.

Loading content...

Provided methods

pub fn sum(values: &[Self]) -> Self[src]

Sums all values in slice values.

Loading content...

Implementations on Foreign Types

impl AliasableWeight for f64[src]

impl AliasableWeight for f32[src]

impl AliasableWeight for usize[src]

impl AliasableWeight for u128[src]

impl AliasableWeight for u64[src]

impl AliasableWeight for u32[src]

impl AliasableWeight for u16[src]

impl AliasableWeight for u8[src]

impl AliasableWeight for isize[src]

impl AliasableWeight for i128[src]

impl AliasableWeight for i64[src]

impl AliasableWeight for i32[src]

impl AliasableWeight for i16[src]

impl AliasableWeight for i8[src]

Loading content...

Implementors

Loading content...