pub struct AliasTable<T, F> { /* private fields */ }
Expand description
An alias table, which uses floating point probabilities of type F
and table entries of type
T
.
Implementations§
Source§impl<T, F> AliasTable<T, F>where
F: PartialOrd + SampleRange,
impl<T, F> AliasTable<T, F>where
F: PartialOrd + SampleRange,
Sourcepub fn pick<'a, R: Rng>(&'a self, rng: &mut R) -> &'a T
pub fn pick<'a, R: Rng>(&'a self, rng: &mut R) -> &'a T
Pick a random element from the distribution. Samples from the RNG using ind_sample
only.
Sourcepub fn iter<R: Rng>(&self, rng: R) -> AliasTableIterator<'_, T, F, R> ⓘ
pub fn iter<R: Rng>(&self, rng: R) -> AliasTableIterator<'_, T, F, R> ⓘ
Given an RNG, produce an iterator that picks random element from the distribution by
calling pick
repeatedly with the given RNG.
Trait Implementations§
Source§impl<T, F> Debug for AliasTable<T, F>where
F: Debug,
impl<T, F> Debug for AliasTable<T, F>where
F: Debug,
Source§impl<'a, T, F> FromIterator<(T, F)> for AliasTable<T, F>
impl<'a, T, F> FromIterator<(T, F)> for AliasTable<T, F>
Source§fn from_iter<I: IntoIterator<Item = (T, F)>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = (T, F)>>(iter: I) -> Self
Construct an alias table from an iterator. Expects a tuple, where the left-hand element is the distribution’s value, and the right-hand element is the value’s weight in the distribution.
Source§impl<'a, T, F> IntoIterator for &'a AliasTable<T, F>
impl<'a, T, F> IntoIterator for &'a AliasTable<T, F>
Auto Trait Implementations§
impl<T, F> Freeze for AliasTable<T, F>where
F: Freeze,
impl<T, F> RefUnwindSafe for AliasTable<T, F>where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, F> Send for AliasTable<T, F>
impl<T, F> Sync for AliasTable<T, F>
impl<T, F> Unpin for AliasTable<T, F>
impl<T, F> UnwindSafe for AliasTable<T, F>where
F: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more