Struct java_rand::Random
[−]
[src]
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) -> u64[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 Debug for Random[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more