Struct rand_sequence::RandomSequenceBuilder
source · pub struct RandomSequenceBuilder<T>where
T: PrimInt + WrappingAdd + WrappingSub,
Montgomery<T>: Reducer<T>,{
pub seed_base: T,
pub seed_offset: T,
pub init_base: T,
pub init_offset: T,
pub prime: T,
pub intermediate_xor: T,
}
Expand description
The configuration for RandomSequence, a random unique sequence generator.
These variables define the entire sequence and should not be modified with the exception of
seed_base
and seed_offset
during initialisation.
The builder defines the internal properties of the sequence, and serialization includes all of the properties to preserve the sequence between crate versions which may change the fixed values between minor versions.
Crate versioning will bump:
- Minor version: when the hard coded parameters are updated in favour of better ones. It is safe to serialize the RandomSequenceBuilder between minor versions.
- Major version: when the sequence generation logic fundamentally changes the sequence, meaning it would be potentially unsafe to serialize the RandomSequenceBuilder between major crate version changes.
Fields§
§seed_base: T
§seed_offset: T
§init_base: T
A value used as an xor during initialisation for start_index = f(seed_base, init_base)
to
deterministically pseudo-randomise it.
init_offset: T
A value used as an xor during initialisation for offset = f(seed_offset, init_offset)
to
deterministically pseudo-randomise it.
prime: T
Should be the largest prime number that fits in type T
and satisfied prime = 3 mod 4
.
intermediate_xor: T
A value that provides some noise from the xor to generate a pseudo-uniform distribution.
Implementations§
source§impl<T> RandomSequenceBuilder<T>where
T: PrimInt + WrappingAdd + WrappingSub,
Montgomery<T>: Reducer<T>,
impl<T> RandomSequenceBuilder<T>where T: PrimInt + WrappingAdd + WrappingSub, Montgomery<T>: Reducer<T>,
sourcepub unsafe fn from_spec(
seed_base: T,
seed_offset: T,
init_base: T,
init_offset: T,
prime: T,
intermediate_xor: T
) -> Self
pub unsafe fn from_spec( seed_base: T, seed_offset: T, init_base: T, init_offset: T, prime: T, intermediate_xor: T ) -> Self
Initialise a config from stored settings. Not recommended unless you know what you’re doing, or these values have been taken from an already serialized RandomSequenceBuilder.
Prefer [RandomSequenceBuilderInit::new] instead.
Trait Implementations§
source§impl<T> Clone for RandomSequenceBuilder<T>where
T: PrimInt + WrappingAdd + WrappingSub + Clone,
Montgomery<T>: Reducer<T>,
impl<T> Clone for RandomSequenceBuilder<T>where T: PrimInt + WrappingAdd + WrappingSub + Clone, Montgomery<T>: Reducer<T>,
source§fn clone(&self) -> RandomSequenceBuilder<T>
fn clone(&self) -> RandomSequenceBuilder<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 for RandomSequenceBuilder<T>where
T: PrimInt + WrappingAdd + WrappingSub + Debug,
Montgomery<T>: Reducer<T>,
impl<T> Debug for RandomSequenceBuilder<T>where T: PrimInt + WrappingAdd + WrappingSub + Debug, Montgomery<T>: Reducer<T>,
source§impl<T> From<RandomSequenceBuilder<T>> for RandomSequence<T>where
T: PrimInt + WrappingAdd + WrappingSub,
Montgomery<T>: Reducer<T>,
impl<T> From<RandomSequenceBuilder<T>> for RandomSequence<T>where T: PrimInt + WrappingAdd + WrappingSub, Montgomery<T>: Reducer<T>,
source§fn from(value: RandomSequenceBuilder<T>) -> Self
fn from(value: RandomSequenceBuilder<T>) -> Self
source§impl<T> IntoIterator for RandomSequenceBuilder<T>where
T: PrimInt + WrappingAdd + WrappingSub,
Montgomery<T>: Reducer<T>,
impl<T> IntoIterator for RandomSequenceBuilder<T>where T: PrimInt + WrappingAdd + WrappingSub, Montgomery<T>: Reducer<T>,
source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
Build a RandomSequence iterator from this config.
§type IntoIter = RandomSequence<T>
type IntoIter = RandomSequence<T>
source§impl<T> PartialEq for RandomSequenceBuilder<T>where
T: PrimInt + WrappingAdd + WrappingSub + PartialEq,
Montgomery<T>: Reducer<T>,
impl<T> PartialEq for RandomSequenceBuilder<T>where T: PrimInt + WrappingAdd + WrappingSub + PartialEq, Montgomery<T>: Reducer<T>,
source§fn eq(&self, other: &RandomSequenceBuilder<T>) -> bool
fn eq(&self, other: &RandomSequenceBuilder<T>) -> bool
self
and other
values to be equal, and is used
by ==
.