54 explicit random(std::random_device& random_device);
68 std::default_random_engine
generator() const noexcept;
80 template<typename value_t>
97 template<
typename value_t>
98 value_t
next(value_t max_value)
const {
99 return static_cast<value_t
>(
next(value_t {}, max_value));
118 template<
typename value_t>
119 value_t
next(value_t min_value, value_t max_value)
const {
121 if (min_value == max_value)
return min_value;
127 double next(
double max_value)
const;
128 float next(
float max_value)
const;
130 double next(
double min_value,
double max_value)
const;
131 float next(
float min_value,
float max_value)
const;
137 virtual void next_bytes(std::vector<xtd::byte>& buffer)
const;
148 template<
typename value_t>
157 template<
typename value_t>
160 for (
size_t index = 0; index < buffer_size; index++)
177 mutable std::default_random_engine generator_;
Contains xtd::argument_null_exception exception.
Contains xtd::argument_out_of_range_exception exception.
Contains xtd::box_integer class.
The exception that is thrown when one of the arguments provided to a method is null.
Definition argument_null_exception.h:23
The exception that is thrown when one of the arguments provided to a method is out of range.
Definition argument_out_of_range_exception.h:23
Represents a boxed integer object.
Definition box_integer.h:52
static decimal round(decimal value)
Rounds a double-precision floating-point value to the nearest integral value.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
Represents a pseudo-random number generator, a device that produces a sequence of numbers that meet c...
Definition random.h:40
value_t next(value_t max_value) const
Returns a nonnegative random number less than the specified maximum.
Definition random.h:98
virtual int32 next(int32 min_value, int32 max_value) const
Returns a random number within a specified range.
random(uint32 seed)
Initializes a new instance of the random class, using a specified seed value.
virtual void next_bytes(std::vector< xtd::byte > &buffer) const
Fills the elements of a specified array of bytes with random numbers.
virtual int32 next(int32 max_value) const
Returns a nonnegative random number less than the specified maximum.
virtual void next_bytes(xtd::byte *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.
void next_values(value_t *buffer, size_t buffer_size) const
Fills the elements of a specified array of bytes with random numbers.
Definition random.h:158
random(std::random_device &random_device)
Initializes a new instance of the random class, using a specified random device value.
std::default_random_engine generator() const noexcept
Gets the underlying generator.
virtual int32 next() const
Returns a nonnegative random number.
value_t next(value_t min_value, value_t max_value) const
Returns a random number within a specified range.
Definition random.h:119
void next_values(std::vector< value_t > &buffer) const
Fills the elements of a specified array of bytes with random numbers.
Definition random.h:149
random()
Initializes a new instance of the random class, using a default generated seed value.
virtual double sample() const
Returns a random number between 0.0 and 1.0.
Contains core_export_ keyword.
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
long double decimal
Represents a decimal-precision floating-point number.
Definition decimal.h:23
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.h:23
uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.h:23
Contains xtd::math class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::object class.
Contains xtd::optional type.
Contains xtd::environment class.