QtBase  v6.3.1
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QRandomGenerator64 Class Reference

The QRandomGenerator64 class allows one to obtain 64-bit random values from a high-quality, seed-less Random Number Generator. More...

#include <qrandom.h>

Inheritance diagram for QRandomGenerator64:
Inheritance graph
[legend]
Collaboration diagram for QRandomGenerator64:
Collaboration graph
[legend]

Public Types

typedef quint64 result_type
 
- Public Types inherited from QRandomGenerator
typedef quint32 result_type
 

Public Member Functions

quint64 generate ()
 
result_type operator() ()
 
 QRandomGenerator64 (quint32 seedValue=1)
 
template<qsizetype N>
 QRandomGenerator64 (const quint32(&seedBuffer)[N])
 
 QRandomGenerator64 (const quint32 *seedBuffer, qsizetype len)
 
 QRandomGenerator64 (std::seed_seq &sseq) noexcept
 
 QRandomGenerator64 (const quint32 *begin, const quint32 *end)
 
 QRandomGenerator64 (const QRandomGenerator &other)
 
void discard (unsigned long long z)
 
quint32 generate ()
 
template<typename ForwardIterator >
void generate (ForwardIterator begin, ForwardIterator end)
 
void generate (quint32 *begin, quint32 *end)
 
- Public Member Functions inherited from QRandomGenerator
 QRandomGenerator (quint32 seedValue=1)
 
template<qsizetype N>
 QRandomGenerator (const quint32(&seedBuffer)[N])
 
 QRandomGenerator (const quint32 *seedBuffer, qsizetype len)
 
Q_CORE_EXPORT QRandomGenerator (std::seed_seq &sseq) noexcept
 
Q_CORE_EXPORT QRandomGenerator (const quint32 *begin, const quint32 *end)
 
Q_CORE_EXPORT QRandomGenerator (const QRandomGenerator &other)
 
Q_CORE_EXPORT QRandomGeneratoroperator= (const QRandomGenerator &other)
 
quint32 generate ()
 
quint64 generate64 ()
 
double generateDouble ()
 
double bounded (double highest)
 
quint32 bounded (quint32 highest)
 
quint32 bounded (quint32 lowest, quint32 highest)
 
int bounded (int highest)
 
int bounded (int lowest, int highest)
 
quint64 bounded (quint64 highest)
 
quint64 bounded (quint64 lowest, quint64 highest)
 
qint64 bounded (qint64 highest)
 
qint64 bounded (qint64 lowest, qint64 highest)
 
qint64 bounded (int lowest, qint64 highest)
 
qint64 bounded (qint64 lowest, int highest)
 
quint64 bounded (unsigned lowest, quint64 highest)
 
quint64 bounded (quint64 lowest, unsigned highest)
 
template<typename UInt , IfValidUInt< UInt > = true>
void fillRange (UInt *buffer, qsizetype count)
 
template<typename UInt , size_t N, IfValidUInt< UInt > = true>
void fillRange (UInt(&buffer)[N])
 
template<typename ForwardIterator >
void generate (ForwardIterator begin, ForwardIterator end)
 
void generate (quint32 *begin, quint32 *end)
 
result_type operator() ()
 
void seed (quint32 s=1)
 
void seed (std::seed_seq &sseq) noexcept
 
Q_CORE_EXPORT void discard (unsigned long long z)
 

Static Public Member Functions

static constexpr result_type min ()
 
static constexpr result_type max ()
 
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64system ()
 
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64global ()
 
static Q_CORE_EXPORT QRandomGenerator64 securelySeeded ()
 
- Static Public Member Functions inherited from QRandomGenerator
static constexpr result_type min ()
 
static constexpr result_type max ()
 
static Q_DECL_CONST_FUNCTION QRandomGeneratorsystem ()
 
static Q_DECL_CONST_FUNCTION QRandomGeneratorglobal ()
 
static QRandomGenerator securelySeeded ()
 

Additional Inherited Members

- Protected Types inherited from QRandomGenerator
enum  System
 
- Protected Member Functions inherited from QRandomGenerator
 QRandomGenerator (System)
 

Detailed Description

The QRandomGenerator64 class allows one to obtain 64-bit random values from a high-quality, seed-less Random Number Generator.

\inmodule QtCore

Since
5.10

QRandomGenerator64 is a simple adaptor class around QRandomGenerator, making the QRandomGenerator::generate64() function the default for operator()(), instead of the function that returns 32-bit quantities. This class is intended to be used in conjunction with Standard Library algorithms that need 64-bit quantities instead of 32-bit ones.

In all other aspects, the class is the same. Please refer to QRandomGenerator's documentation for more information.

See also
QRandomGenerator

Definition at line 244 of file qrandom.h.

Member Typedef Documentation

◆ result_type

A typedef to the type that operator() returns. That is, quint64.

See also
operator()

Definition at line 252 of file qrandom.h.

Constructor & Destructor Documentation

◆ QRandomGenerator64() [1/6]

QRandomGenerator64::QRandomGenerator64 ( quint32  seedValue = 1)
inline

Definition at line 256 of file qrandom.h.

◆ QRandomGenerator64() [2/6]

template<qsizetype N>
QRandomGenerator64::QRandomGenerator64 ( const quint32(&)  seedBuffer[N])
inline

Definition at line 259 of file qrandom.h.

◆ QRandomGenerator64() [3/6]

QRandomGenerator64::QRandomGenerator64 ( const quint32 seedBuffer,
qsizetype  len 
)
inline

Definition at line 262 of file qrandom.h.

◆ QRandomGenerator64() [4/6]

QRandomGenerator64::QRandomGenerator64 ( std::seed_seq &  sseq)
inlinenoexcept

Definition at line 265 of file qrandom.h.

◆ QRandomGenerator64() [5/6]

QRandomGenerator64::QRandomGenerator64 ( const quint32 begin,
const quint32 end 
)
inline

Definition at line 268 of file qrandom.h.

◆ QRandomGenerator64() [6/6]

QRandomGenerator64::QRandomGenerator64 ( const QRandomGenerator other)
inline

Definition at line 271 of file qrandom.h.

Member Function Documentation

◆ discard()

void QRandomGenerator64::discard ( unsigned long long  z)
inline

Definition at line 273 of file qrandom.h.

Here is the call graph for this function:

◆ generate() [1/4]

quint32 QRandomGenerator::generate
inline

Generates a 32-bit random quantity and returns it.

See also
{QRandomGenerator::operator()}{operator()()}, generate64()

Definition at line 84 of file qrandom.h.

◆ generate() [2/4]

quint64 QRandomGenerator64::generate ( )
inline

Generates one 64-bit random value and returns it.

Note about casting to a signed integer: all bits returned by this function are random, so there's a 50% chance that the most significant bit will be set. If you wish to cast the returned value to qint64 and keep it positive, you should mask the sign bit off:

See also
QRandomGenerator, QRandomGenerator::generate64()

Definition at line 250 of file qrandom.h.

Here is the call graph for this function:

◆ generate() [3/4]

template<typename ForwardIterator >
template< typename ForwardIterator > void QRandomGenerator::generate ( typename ForwardIterator  )
inline

Generates 32-bit quantities and stores them in the range between begin and end. This function is equivalent to (and is implemented as):

This function complies with the requirements for the function \l{http://en.cppreference.com/w/cpp/numeric/random/seed_seq/generate}{std::seed_seq::generate}, which requires unsigned 32-bit integer values.

Note that if the [begin, end) range refers to an area that can store more than 32 bits per element, the elements will still be initialized with only 32 bits of data. Any other bits will be zero. To fill the range with 64 bit quantities, one can write:

If the range refers to contiguous memory (such as an array or the data from a QList), the fillRange() function may be used too.

See also
fillRange()

Definition at line 190 of file qrandom.h.

◆ generate() [4/4]

void QRandomGenerator::generate
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 195 of file qrandom.h.

◆ global()

QRandomGenerator64 * QRandomGenerator64::global ( )
static

Definition at line 1170 of file qrandom.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max()

static constexpr result_type QRandomGenerator64::max ( )
inlinestaticconstexpr

Definition at line 281 of file qrandom.h.

◆ min()

static constexpr result_type QRandomGenerator64::min ( )
inlinestaticconstexpr

Definition at line 280 of file qrandom.h.

◆ operator()()

result_type QRandomGenerator64::operator() ( )
inline

Generates a 64-bit random quantity and returns it.

See also
QRandomGenerator::generate(), QRandomGenerator::generate64()

Definition at line 253 of file qrandom.h.

Here is the call graph for this function:

◆ securelySeeded()

QRandomGenerator64 QRandomGenerator64::securelySeeded ( )
static

Definition at line 1188 of file qrandom.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ system()

QRandomGenerator64 * QRandomGenerator64::system ( )
static

Definition at line 1163 of file qrandom.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

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