[−][src]Struct oorandom::Rand64
A PRNG producing a 64-bit output.
The current implementation is PCG-XSH-RR
.
Methods
impl Rand64
[src]
pub const DEFAULT_INC: u128
[src]
The default value for increment
.
The value used here is from the PCG default C implementation: http://www.pcg-random.org/download.html
pub fn new(seed: u128) -> Self
[src]
Creates a new PRNG with the given seed and a default increment.
pub fn state(&self) -> (u128, u128)
[src]
Returns the internal state of the PRNG. This allows you to save a PRNG and create a new one that will resume from the same spot in the sequence.
pub fn from_state(state: (u128, u128)) -> Self
[src]
Creates a new PRNG from a saved state from Rand32::state()
.
This is NOT quite the same as new_inc()
because new_inc()
does
a little extra setup work to initialize the state.
pub fn rand_u64(&mut self) -> u64
[src]
Produces a random u64
in the range[0, u64::MAX]
.
pub fn rand_i64(&mut self) -> i64
[src]
Produces a random i64
in the range [i64::MIN, i64::MAX]
.
pub fn rand_float(&mut self) -> f64
[src]
Produces a random f64
in the range [0.0, 1.0)
.
pub fn rand_range(&mut self, range: Range<u64>) -> u64
[src]
Produces a random within the given bounds. Like any Range
,
it includes the lower bound and excludes the upper one.
This should be faster than Self::rand() % end + start
, but the
real advantage is it's more convenient. Requires that
range.end <= range.start
.
Trait Implementations
impl PartialEq<Rand64> for Rand64
[src]
impl Debug for Rand64
[src]
impl Copy for Rand64
[src]
impl Clone for Rand64
[src]
fn clone(&self) -> Rand64
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,