DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
DotNetDupe::System::Random Class Reference

Represents a pseudo-random number generator, which is an algorithm that produces a sequence of numbers that meet certain statistical requirements for randomness. More...

#include <Random.h>

Inheritance diagram for DotNetDupe::System::Random:

Public Member Functions

 Random ()
 Initializes a new instance of the Random class, using a time-dependent default seed value.
 Random (int seed)
 Initializes a new instance of the Random class, using the specified seed value.
virtual int Next ()
 Returns a non-negative random integer.
virtual int Next (int maxValue)
 Returns a non-negative random integer that is less than the specified maximum.
virtual int Next (int minValue, int maxValue)
 Returns a random integer that is within a specified range.
virtual void NextBytes (unsigned char *buffer, int bufferSize)
 Fills the elements of a specified array of bytes with random numbers.
virtual double NextDouble ()
 Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
Public Member Functions inherited from DotNetDupe::System::Object
virtual ~Object ()=default
 Virtual destructor ensuring polymorphic cleanup.
virtual bool Equals (const Object &obj) const
 Determines whether the specified Object is equal to the current Object.
virtual int GetHashCode () const
 Serves as the default hash function.
bool operator== (const Object &obj) const
 Determines reference equality between two objects.
char * ToStringA () const
 Returns narrow-character string representation.
wchar_t * ToStringW () const
 Returns wide-character string representation.

Additional Inherited Members

Static Public Member Functions inherited from DotNetDupe::System::Object
static bool Equals (const Object &obj1, const Object &obj2)
 Static helper determining whether two object instances are equal.

Detailed Description

Represents a pseudo-random number generator, which is an algorithm that produces a sequence of numbers that meet certain statistical requirements for randomness.

Note
Conforms to ECMA-335 Partition IV Section 5.19 (System.Random).

Definition at line 18 of file Random.h.

Constructor & Destructor Documentation

◆ Random() [1/2]

DotNetDupe::System::Random::Random ( )

Initializes a new instance of the Random class, using a time-dependent default seed value.

Definition at line 7 of file Random.cpp.

◆ Random() [2/2]

DotNetDupe::System::Random::Random ( int seed)

Initializes a new instance of the Random class, using the specified seed value.

Parameters
seedA number used to calculate a starting value for the pseudo-random number sequence.

Definition at line 9 of file Random.cpp.

Member Function Documentation

◆ Next() [1/3]

int DotNetDupe::System::Random::Next ( )
virtual

Returns a non-negative random integer.

Returns
A 32-bit signed integer that is greater than or equal to 0 and less than Int32.MaxValue.

Initialize Mersenne Twister engine with current seed and draw non-negative integer.

Definition at line 11 of file Random.cpp.

◆ Next() [2/3]

int DotNetDupe::System::Random::Next ( int maxValue)
virtual

Returns a non-negative random integer that is less than the specified maximum.

Parameters
maxValueThe exclusive upper bound of the random number to be generated.
Returns
A 32-bit signed integer that is greater than or equal to 0, and less than maxValue.

Sample uniform distribution across [0, maxValue].

Definition at line 18 of file Random.cpp.

◆ Next() [3/3]

int DotNetDupe::System::Random::Next ( int minValue,
int maxValue )
virtual

Returns a random integer that is within a specified range.

Parameters
minValueThe inclusive lower bound of the random number returned.
maxValueThe exclusive upper bound of the random number returned.
Returns
A 32-bit signed integer greater than or equal to minValue and less than maxValue.

Sample uniform distribution across [minValue, maxValue].

Definition at line 25 of file Random.cpp.

◆ NextBytes()

void DotNetDupe::System::Random::NextBytes ( unsigned char * buffer,
int bufferSize )
virtual

Fills the elements of a specified array of bytes with random numbers.

Parameters
bufferAn array of bytes to contain random numbers.
bufferSizeThe number of bytes to fill.

Generate random bytes across entire buffer span.

Definition at line 32 of file Random.cpp.

◆ NextDouble()

double DotNetDupe::System::Random::NextDouble ( )
virtual

Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.

Returns
A double-precision floating point number that is greater than or equal to 0.0, and less than 1.0.

Sample uniform real distribution in interval [0.0, 1.0).

Definition at line 41 of file Random.cpp.


The documentation for this class was generated from the following files: