[][src]Struct java_rand::Random

pub struct Random { /* fields omitted */ }

Methods

impl Random[src]

pub fn new(seed: u64) -> Self[src]

pub fn set_seed(&mut self, seed: u64)[src]

Sets the seed to seed. This is equivalent to Random::new

pub fn next(&mut self, bits: u8) -> i32[src]

Steps the RNG, returning up to 48 bits.

Panics

If the amount of requested bits is over 48, this function panics. Use next_i64/next_u64 instead, or multiple calls.

pub fn next_bytes(&mut self, bytes: &mut [u8])[src]

Fills the byte array with random bytes.

pub fn next_i32(&mut self) -> i32[src]

Returns a uniformly distributed signed 32-bit integer.

pub fn next_u32(&mut self) -> u32[src]

Returns a uniformly distributed unsigned 32-bit integer.

pub fn next_i32_bound(&mut self, max: i32) -> i32[src]

Returns a positive random number in the range [0, max), up to 2^31. The range of the return value is represented by the value 0 <= value < max. A maximum of less than 1 is invalid because then no value would satisfy the range.

Panics

If max is less than 1, the function panics.

pub fn next_u32_bound(&mut self, max: u32) -> u32[src]

Returns a positive random number in the range [0, max), up to 2^31. The range of the return value is represented by the value 0 <= value < max. A maximum of 0 is invalid because then no value would satisfy the range. Maximums of 2^31 or greater are not supported in Java.

Panics

If max reinterpreted as a signed 32-bit integer is less than 1, the function panics.

pub fn next_i64(&mut self) -> i64[src]

Returns a uniformly distributed signed 64-bit integer.

pub fn next_u64(&mut self) -> u64[src]

Returns a uniformly distributed unsigned 64-bit integer.

pub fn next_bool(&mut self) -> bool[src]

Returns a boolean value that has an equal chance of being true or false.

pub fn next_f32(&mut self) -> f32[src]

Returns a f32 uniformly distributed between 0.0 and 1.0.

pub fn next_f64(&mut self) -> f64[src]

Returns a f64 uniformly distributed between 0.0 and 1.0.

pub fn next_gaussian(&mut self) -> f64[src]

Returns a gaussian-distributed number with a mean of 0.0 and standard deviation of 1.0.

Trait Implementations

impl Clone for Random[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Random[src]

Auto Trait Implementations

impl Send for Random

impl Sync for Random

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]