Struct vosealias::AliasTable
[−]
[src]
pub struct AliasTable<T, F> { /* fields omitted */ }
An alias table, which uses floating point probabilities of type F
and table entries of type
T
.
Methods
impl<T, F> AliasTable<T, F> where
F: PartialOrd + SampleRange,
[src]
F: PartialOrd + SampleRange,
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.
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
impl<T, F> Debug for AliasTable<T, F> where
F: Debug,
[src]
F: Debug,
impl<'a, T, F: 'a> FromIterator<(T, F)> for AliasTable<T, F> where
F: Float + NumCast + One + SampleRange + Sum<F> + Zero,
[src]
F: Float + NumCast + One + SampleRange + Sum<F> + Zero,
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.
impl<'a, T, F> IntoIterator for &'a AliasTable<T, F> where
F: Sized + PartialOrd + SampleRange,
[src]
F: Sized + PartialOrd + SampleRange,
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = AliasTableIterator<'a, T, F, ThreadRng>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Produces an iterator that picks random element from the distribution by calling
calling pick
repeatedly with the thread's RNG.