NCBI C++ ToolKit
|
Classes | |
class | CRandom |
CRandom:: More... | |
class | CRandomException |
Exceptions generated by CRandom class. More... | |
Typedefs | |
typedef Uint4 | CRandom::TValue |
Type of the generated integer value and/or the seed value. More... | |
Enumerations | |
enum | CRandom::EGetRandMethod { CRandom::eGetRand_LFG , CRandom::eGetRand_Sys } |
Random generator to use in the GetRand() functions. More... | |
enum | { CRandom::kStateSize = 33 } |
enum | CRandomException::EErrCode { CRandomException::eUnavailable , CRandomException::eUnexpectedRandMethod , CRandomException::eSysGeneratorError } |
Functions | |
CRandom::CRandom (EGetRandMethod method=eGetRand_LFG) | |
If "method" is: More... | |
CRandom::CRandom (TValue seed) | |
Use LFG random generator seeded with "seed". More... | |
TValue | CRandom::GetRand (void) |
Get the next random number in the interval [0..GetMax()] (inclusive) More... | |
TValue | CRandom::GetRand (TValue min_value, TValue max_value) |
Get random number in the interval [min_value..max_value] (inclusive) More... | |
Uint8 | CRandom::GetRandUint8 (void) |
Get random Uint8 number. More... | |
Uint8 | CRandom::GetRandUint8 (Uint8 min_value, Uint8 max_value) |
Get random number in the interval [min_value..max_value] (inclusive) More... | |
size_t | CRandom::GetRandSize_t (size_t min_value, size_t max_value) |
Get random number in the interval [min_value..max_value] (inclusive) More... | |
TValue | CRandom::GetRandIndex (TValue size) |
Get random number in the interval [0..size-1] (e.g. More... | |
Uint8 | CRandom::GetRandIndexUint8 (Uint8 size) |
Get random number in the interval [0..size-1] (e.g. More... | |
size_t | CRandom::GetRandIndexSize_t (size_t size) |
Get random number in the interval [0..size-1] (e.g. More... | |
static TValue | CRandom::GetMax (void) |
The max. value GetRand() returns. More... | |
EGetRandMethod | CRandom::GetRandMethod (void) const |
Get the random generator type. More... | |
void | CRandom::Randomize (void) |
Re-initialize (re-seed) the generator using platform-specific randomization. More... | |
void | CRandom::SetSeed (TValue seed) |
Seed the random number generator with "seed". More... | |
TValue | CRandom::GetSeed (void) const |
Get the last set seed (LFG only) More... | |
void | CRandom::Reset (void) |
Reset random number generator to initial startup condition (LFG only) More... | |
TValue | CRandom::x_GetRand32Bits (void) |
Uint8 | CRandom::x_GetRand64Bits (void) |
TValue | CRandom::x_GetSysRand32Bits (void) const |
CRandom::CRandom (const CRandom &) | |
CRandom & | CRandom::operator= (const CRandom &) |
virtual const char * | CRandomException::GetErrCodeString (void) const override |
Get error code interpreted as text. More... | |
CRandomException::NCBI_EXCEPTION_DEFAULT (CRandomException, CException) | |
Variables | |
EGetRandMethod | CRandom::m_RandMethod |
TValue | CRandom::m_State [kStateSize] |
int | CRandom::m_RJ |
int | CRandom::m_RK |
TValue | CRandom::m_Seed |
typedef Uint4 CRandom::TValue |
Type of the generated integer value and/or the seed value.
Definition at line 69 of file random_gen.hpp.
|
private |
Enumerator | |
---|---|
kStateSize |
Definition at line 159 of file random_gen.hpp.
Definition at line 182 of file random_gen.hpp.
Random generator to use in the GetRand() functions.
Enumerator | |
---|---|
eGetRand_LFG | Use lagged Fibonacci (LFG) random number generator. |
eGetRand_Sys | Use system-dependent random generator. |
Definition at line 72 of file random_gen.hpp.
CRandom::CRandom | ( | EGetRandMethod | method = eGetRand_LFG | ) |
If "method" is:
Definition at line 215 of file random_gen.cpp.
References CRandom::eGetRand_Sys, NCBI_THROW, CRandom::Reset(), and s_RandomSupplier.
CRandom::CRandom | ( | TValue | seed | ) |
Use LFG random generator seeded with "seed".
Definition at line 227 of file random_gen.cpp.
References seed, and CRandom::SetSeed().
|
inlineoverridevirtual |
Get error code interpreted as text.
Reimplemented from CException.
Definition at line 190 of file random_gen.hpp.
References CRandomException::eSysGeneratorError, CRandomException::eUnavailable, CRandomException::eUnexpectedRandMethod, CException::GetErrCode(), and CException::GetErrCodeString().
|
inlinestatic |
The max. value GetRand() returns.
Definition at line 295 of file random_gen.hpp.
Referenced by CNCDistributionConf::GenerateBlobKey(), and alp_data::ran2().
|
inline |
Get random number in the interval [min_value..max_value] (inclusive)
Definition at line 277 of file random_gen.hpp.
References CRandom::GetRandIndex(), and min_value.
|
inline |
Get the next random number in the interval [0..GetMax()] (inclusive)
Definition at line 238 of file random_gen.hpp.
References CRandom::x_GetRand32Bits().
Referenced by BOOST_AUTO_TEST_CASE(), CNCDistributionConf::GenerateBlobKey(), CNcbiEncryptApp::GenerateKey(), TestUtil::GenerateRandomSeqid_Gi(), GetKValues(), CDiscreteDistributionImpl::GetNextValue(), SCompoundIDPoolImpl::GetRand(), CMTTestThread::GetRandomId(), GetRandomNumbers(), CMTTestThread::Main(), CSeqportUtil_implementation::MapIupacnaToNcbi2na(), CSeqportUtil_implementation::MapNcbi4naToNcbi2na(), SNetServiceIterator_RandomPivot::Next(), CSymDustMasker::CIupac2Ncbi2na_converter::operator()(), alp_data::ran2(), CDbapiSampleApp::Run(), s_GetRand(), s_GetRandomNumbers(), s_Ncbi4naToNcbi2na(), s_SetNextTime(), CRandom::SetSeed(), CNCActiveSyncControl::x_FinishScanSlots(), CElementaryMatching::x_InitBasic(), and CAmbigDataBuilder::x_Random().
|
inline |
Get random number in the interval [0..size-1] (e.g.
index in array)
Definition at line 251 of file random_gen.hpp.
References r(), ncbi::grid::netcache::search::fields::size, and CRandom::x_GetRand32Bits().
Referenced by CRandom::GetRand(), CRandom::GetRandIndexSize_t(), and CRandom::GetRandIndexUint8().
|
inline |
Get random number in the interval [0..size-1] (e.g.
index in array)
Definition at line 267 of file random_gen.hpp.
References CRandom::GetRandIndex(), CRandom::GetRandIndexUint8(), and ncbi::grid::netcache::search::fields::size.
Referenced by CRandom::GetRandSize_t().
Get random number in the interval [0..size-1] (e.g.
index in array)
Definition at line 331 of file random_gen.cpp.
References CRandom::GetRandIndex(), CRandom::GetRandUint8(), kMax_UI4, r(), and ncbi::grid::netcache::search::fields::size.
Referenced by CRandom::GetRandIndexSize_t(), and CRandom::GetRandUint8().
|
inline |
Get the random generator type.
Definition at line 301 of file random_gen.hpp.
References CRandom::m_RandMethod.
|
inline |
Get random number in the interval [min_value..max_value] (inclusive)
Definition at line 289 of file random_gen.hpp.
References CRandom::GetRandIndexSize_t(), and min_value.
Get random number in the interval [min_value..max_value] (inclusive)
Definition at line 283 of file random_gen.hpp.
References CRandom::GetRandIndexUint8(), and min_value.
|
inline |
Get random Uint8 number.
Definition at line 244 of file random_gen.hpp.
References CRandom::x_GetRand32Bits().
Referenced by NDirectNetStorageImpl::SContext::Create(), CRandom::GetRandIndexUint8(), and CPubseqGatewayApp::Run().
CRandom::TValue CRandom::GetSeed | ( | void | ) | const |
Get the last set seed (LFG only)
Definition at line 312 of file random_gen.cpp.
References CRandom::eGetRand_Sys, CRandom::m_RandMethod, CRandom::m_Seed, and NCBI_THROW.
CRandomException::NCBI_EXCEPTION_DEFAULT | ( | CRandomException | , |
CException | |||
) |
void CRandom::Randomize | ( | void | ) |
Re-initialize (re-seed) the generator using platform-specific randomization.
Definition at line 267 of file random_gen.cpp.
References CTime::eCurrent, CRandom::eGetRand_Sys, CCurrentProcess::GetPid(), CThread::GetSelf(), CRandom::m_RandMethod, CTime::NanoSecond(), s_RandomSupplier, CTime::Second(), seed, and CRandom::SetSeed().
Referenced by CNcbiEncryptApp::GenerateKey(), and NDirectNetStorageImpl::SContext::Init().
void CRandom::Reset | ( | void | ) |
Reset random number generator to initial startup condition (LFG only)
Definition at line 234 of file random_gen.cpp.
References _ASSERT, CRandom::eGetRand_Sys, i, kStateOffset, CRandom::kStateSize, CRandom::m_RandMethod, CRandom::m_RJ, CRandom::m_RK, CRandom::m_State, and NCBI_THROW.
Referenced by CSubjectRangesSet::AddRange(), CRandom::CRandom(), and CSeqDBVol::SetOffsetRanges().
void CRandom::SetSeed | ( | TValue | seed | ) |
Seed the random number generator with "seed".
Definition at line 287 of file random_gen.cpp.
References _ASSERT, CRandom::eGetRand_Sys, CRandom::GetRand(), i, kStateOffset, CRandom::kStateSize, CRandom::m_RandMethod, CRandom::m_RJ, CRandom::m_RK, CRandom::m_Seed, CRandom::m_State, NCBI_THROW, and seed.
Referenced by alp_data::alp_data(), CRandom::CRandom(), CSeqportUtil_implementation::MapIupacnaToNcbi2na(), CSeqportUtil_implementation::MapNcbi4naToNcbi2na(), and CRandom::Randomize().
|
inlineprivate |
Definition at line 217 of file random_gen.hpp.
References CRandom::eGetRand_Sys, CRandom::kStateSize, CRandom::m_RandMethod, CRandom::m_RJ, CRandom::m_RK, CRandom::m_State, r(), and CRandom::x_GetSysRand32Bits().
Referenced by CRandom::GetRand(), CRandom::GetRandIndex(), and CRandom::GetRandUint8().
|
private |
|
private |
Definition at line 323 of file random_gen.cpp.
References r(), and s_RandomSupplier.
Referenced by CRandom::x_GetRand32Bits().
|
private |
Definition at line 162 of file random_gen.hpp.
Referenced by CRandom::GetRandMethod(), CRandom::GetSeed(), CRandom::Randomize(), CRandom::Reset(), CRandom::SetSeed(), and CRandom::x_GetRand32Bits().
|
private |
Definition at line 164 of file random_gen.hpp.
Referenced by CRandom::Reset(), CRandom::SetSeed(), and CRandom::x_GetRand32Bits().
|
private |
Definition at line 165 of file random_gen.hpp.
Referenced by CRandom::Reset(), CRandom::SetSeed(), and CRandom::x_GetRand32Bits().
|
private |
Definition at line 166 of file random_gen.hpp.
Referenced by CRandom::GetSeed(), and CRandom::SetSeed().
|
private |
Definition at line 163 of file random_gen.hpp.
Referenced by CRandom::Reset(), CRandom::SetSeed(), and CRandom::x_GetRand32Bits().