pub trait ScientificSliceRandom<T> {
// Required methods
fn scientific_shuffle<R>(&mut self, rng: &mut Random<R>)
where R: Rng;
fn scientific_choose<R>(&self, rng: &mut Random<R>) -> Option<&T>
where R: Rng;
fn scientific_choose_multiple<R>(
&self,
rng: &mut Random<R>,
amount: usize,
) -> Vec<&T>
where R: Rng;
fn scientific_sample_with_replacement<R>(
&self,
rng: &mut Random<R>,
amount: usize,
) -> Vec<&T>
where R: Rng;
fn scientific_weighted_sample<R, W>(
&self,
rng: &mut Random<R>,
weights: &[W],
amount: usize,
) -> Result<Vec<&T>, String>
where R: Rng,
W: Into<f64> + Copy;
fn scientific_reservoir_sample<R>(
&self,
rng: &mut Random<R>,
k: usize,
) -> Vec<&T>
where R: Rng;
}Expand description
Enhanced slice random operations for scientific computing
Required Methods§
Sourcefn scientific_shuffle<R>(&mut self, rng: &mut Random<R>)where
R: Rng,
fn scientific_shuffle<R>(&mut self, rng: &mut Random<R>)where
R: Rng,
Shuffle the slice in place with enhanced performance
Sourcefn scientific_choose<R>(&self, rng: &mut Random<R>) -> Option<&T>where
R: Rng,
fn scientific_choose<R>(&self, rng: &mut Random<R>) -> Option<&T>where
R: Rng,
Choose a random element with guaranteed uniform distribution
Sourcefn scientific_choose_multiple<R>(
&self,
rng: &mut Random<R>,
amount: usize,
) -> Vec<&T>where
R: Rng,
fn scientific_choose_multiple<R>(
&self,
rng: &mut Random<R>,
amount: usize,
) -> Vec<&T>where
R: Rng,
Choose multiple elements without replacement using optimal algorithms
Sourcefn scientific_sample_with_replacement<R>(
&self,
rng: &mut Random<R>,
amount: usize,
) -> Vec<&T>where
R: Rng,
fn scientific_sample_with_replacement<R>(
&self,
rng: &mut Random<R>,
amount: usize,
) -> Vec<&T>where
R: Rng,
Sample with replacement
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.