Asposecpplib
System::Random Class Reference

Represents a pseudo-random number generator. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument. More...

Public Member Functions

bool IsNull () const
 Always returns false. More...
 
ASPOSECPP_SHARED_API Random ()
 Initializes a new instance, using a time-dependent default seed value. More...
 
ASPOSECPP_SHARED_API Random (int32_t seed)
 Initializes a new instance of the System.Random class, using the specified seed value. More...
 
ASPOSECPP_SHARED_API int32_t Next ()
 Returns a nonnegative random number less then int32 max value. More...
 
ASPOSECPP_SHARED_API int32_t Next (int32_t maxValue)
 Returns a nonnegative random number less than the specified maximum. More...
 
ASPOSECPP_SHARED_API int32_t Next (int32_t minValue, int32_t maxValue)
 Returns a random number within the specified range. More...
 
ASPOSECPP_SHARED_API void NextBytes (const ArrayPtr< uint8_t > &buffer)
 Fills the elements of the specified array of bytes with random numbers. More...
 
ASPOSECPP_SHARED_API double NextDouble ()
 Returns a random number between 0.0 and 1.0. More...
 
Randomoperator= (std::nullptr_t)
 Effectively does nothing. More...
 

Detailed Description

Represents a pseudo-random number generator. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.

Constructor & Destructor Documentation

◆ Random() [1/2]

ASPOSECPP_SHARED_API System::Random::Random ( )

Initializes a new instance, using a time-dependent default seed value.

◆ Random() [2/2]

ASPOSECPP_SHARED_API System::Random::Random ( int32_t  seed)

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

Parameters
seedThe seed used to generate a pseudo-random number sequence

Member Function Documentation

◆ IsNull()

bool System::Random::IsNull ( ) const
inline

Always returns false.

◆ Next() [1/3]

ASPOSECPP_SHARED_API int32_t System::Random::Next ( )

Returns a nonnegative random number less then int32 max value.

◆ Next() [2/3]

ASPOSECPP_SHARED_API int32_t System::Random::Next ( int32_t  maxValue)

Returns a nonnegative random number less than the specified maximum.

Parameters
maxValueValues generated by the method will be less than this value

◆ Next() [3/3]

ASPOSECPP_SHARED_API int32_t System::Random::Next ( int32_t  minValue,
int32_t  maxValue 
)

Returns a random number within the specified range.

Parameters
minValueValues generated by the method will be greater than this value
maxValueValues generated by the method will be less than this value

◆ NextBytes()

ASPOSECPP_SHARED_API void System::Random::NextBytes ( const ArrayPtr< uint8_t > &  buffer)

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

Parameters
bufferThe array to fill

◆ NextDouble()

ASPOSECPP_SHARED_API double System::Random::NextDouble ( )

Returns a random number between 0.0 and 1.0.

◆ operator=()

Random& System::Random::operator= ( std::nullptr_t  )
inline

Effectively does nothing.

Returns
A reference to the self