CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
random.h
1
3#pragma once
4
5#include <cstdint>
6#include "system/array.h"
7
8namespace System {
9
47class ASPOSECPP_SHARED_CLASS Random : public Object
48{
49 static constexpr int32_t m_big = std::numeric_limits<int32_t>::max();
50 static constexpr int32_t m_seed = 161803398;
51
52 int32_t m_inext;
53 int32_t m_inextp;
54 int32_t m_seedArray[56];
55
56 int32_t InternalSample();
57
58 double GetSampleForLargeRange();
59
60protected:
61
62 ASPOSECPP_SHARED_API virtual double Sample();
63
64public:
66 bool IsNull() const { return false; }
67
69 ASPOSECPP_SHARED_API Random();
70
73 ASPOSECPP_SHARED_API Random(int32_t seed);
74
76 ASPOSECPP_SHARED_API virtual int32_t Next();
77
80 ASPOSECPP_SHARED_API virtual int32_t Next(int32_t maxValue);
81
85 ASPOSECPP_SHARED_API virtual int32_t Next(int32_t minValue, int32_t maxValue);
86
89 ASPOSECPP_SHARED_API virtual void NextBytes(const ArrayPtr<uint8_t>& buffer);
90
92 ASPOSECPP_SHARED_API virtual double NextDouble();
93};
94
95} // namespace System
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Represents a pseudo-random number generator. Objects of this class should only be allocated using Sys...
Definition: random.h:48
Random()
Initializes a new instance, using a time-dependent default seed value.
bool IsNull() const
Always returns false.
Definition: random.h:66
Random(int32_t seed)
Initializes a new instance of the System.Random class, using the specified seed value.
virtual int32_t Next(int32_t maxValue)
Returns a nonnegative random number less than the specified maximum.
virtual int32_t Next(int32_t minValue, int32_t maxValue)
Returns a random number within the specified range.
virtual double NextDouble()
Returns a random number between 0.0 and 1.0.
virtual int32_t Next()
Returns a nonnegative random number less then int32 max value.
virtual void NextBytes(const ArrayPtr< uint8_t > &buffer)
Fills the elements of the specified array of bytes with random numbers.
virtual double Sample()
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Definition: db_command.h:9