![]() |
xtd - Reference Guide
0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
|
#include <random.h>
Represents a pseudo-random number generator, a device that produces a sequence of numbers that meet certain statistical requirements for randomness.
Inherits xtd::object.
Public Member Functions | |
random () | |
Initializes a new instance of the random class, using a default generated seed value. | |
random (std::random_device &random_device) | |
Initializes a new instance of the random class, using a specified random device value. | |
random (uint32_t seed) | |
Initializes a new instance of the random class, using a specified seed value. | |
virtual int32_t | next () const |
Returns a nonnegative random number. | |
template<typename value_t > | |
value_t | next () const |
Returns a nonnegative random number. | |
virtual int32_t | next (int32_t max_value) const |
Returns a nonnegative random number less than the specified maximum. | |
virtual int32_t | next (int32_t min_value, int32_t max_value) const |
Returns a random number within a specified range. | |
template<typename value_t > | |
value_t | next (value_t max_value) const |
Returns a nonnegative random number less than the specified maximum. | |
template<typename value_t > | |
value_t | next (value_t min_value, value_t max_value) const |
Returns a random number within a specified range. | |
virtual void | next_bytes (std::vector< uint8_t > &buffer) const |
Fills the elements of a specified array of bytes with random numbers. | |
virtual void | next_bytes (uint8_t *buffer, size_t buffer_size) const |
Fills the elements of a specified array of bytes with random numbers. | |
virtual double | next_double () const |
Returns a random number between 0.0 and 1.0. | |
template<typename value_t > | |
void | next_values (std::vector< value_t > &buffer) const |
Fills the elements of a specified array of bytes with random numbers. | |
template<typename value_t > | |
void | next_values (value_t *buffer, size_t buffer_size) const |
Fills the elements of a specified array of bytes with random numbers. | |
![]() | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
virtual size_t | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
template<typename object_t > | |
std::unique_ptr< object_t > | memberwise_clone () const |
Gets the type of the current instance. | |
virtual xtd::ustring | to_string () const noexcept |
Returns a std::string that represents the current object. | |
Protected Member Functions | |
virtual double | sample () const |
Returns a random number between 0.0 and 1.0. | |
Additional Inherited Members | |
![]() | |
static bool | equals (const object &object_a, const object &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
|
inline |
Initializes a new instance of the random class, using a default generated seed value.
|
inlineexplicit |
Initializes a new instance of the random class, using a specified seed value.
seed | A number used to calculate a starting value for the pseudo-random number sequence. |
|
inlineexplicit |
Initializes a new instance of the random class, using a specified random device value.
random_device | A random device value. |
|
inlinevirtual |
Returns a nonnegative random number.
|
inline |
Returns a nonnegative random number.
|
inlinevirtual |
Returns a nonnegative random number less than the specified maximum.
max_value | The exclusive upper bound of the random number to be generated. max_value must be greater than or equal to zero. |
argument_out_of_range_exception | max_value is less than zero. |
|
inlinevirtual |
Returns a random number within a specified range.
min_value | The inclusive lower bound of the random number returned |
max_value | The exclusive upper bound of the random number returned. max_value must be greater than or equal to min_value. |
argument_out_of_range_exception | min_value is greater than max_value. |
|
inline |
Returns a nonnegative random number less than the specified maximum.
max_value | The exclusive upper bound of the random number to be generated. max_value must be greater than or equal to zero. |
argument_out_of_range_exception | max_value is less than zero. |
|
inline |
Returns a random number within a specified range.
min_value | The inclusive lower bound of the random number returned |
max_value | The exclusive upper bound of the random number returned. max_value must be greater than or equal to min_value. |
argument_out_of_range_exception | min_value is greater than max_value. |
|
inlinevirtual |
Fills the elements of a specified array of bytes with random numbers.
buffer | An array of bytes to contain random numbers. |
|
inlinevirtual |
Fills the elements of a specified array of bytes with random numbers.
buffer | An array of bytes to contain random numbers. |
argument_null_exception | buffer is null. |
|
inlinevirtual |
Returns a random number between 0.0 and 1.0.
|
inline |
Fills the elements of a specified array of bytes with random numbers.
buffer | An array of bytes to contain random numbers. |
|
inline |
Fills the elements of a specified array of bytes with random numbers.
buffer | An array of value_t to contain random numbers. |
argument_null_exception | buffer is null. |
|
inlineprotectedvirtual |
Returns a random number between 0.0 and 1.0.