Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
src_corelib_global_qrandom.cpp
Go to the documentation of this file.
1// Copyright (C) 2018 Intel Corporation.
2// Copyright (C) 2018 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
4
8
14
21
23 std::uniform_real_distribution dist(1, 2.5);
26
28 std::seed_seq sseq(seedBuffer, seedBuffer + len);
31
33 std::seed_seq sseq(begin, end);
36
38 while (z--)
41
43 std::generate(begin, end, [this]() { return generate(); });
45
47 std::generate(begin, end, []() { return QRandomGenerator::global()->generate64(); });
49
55
60
63 return std::generate_canonical<qreal, std::numeric_limits<qreal>::digits>(rd);
65
67 return generateDouble() * highest;
69
73
77
79 return QColor::fromRgb(QRandomGenerator::global()->generate());
81
83 qint64 value = QRandomGenerator64::global()->generate() & std::numeric_limits<qint64>::max();
static QColor fromRgb(QRgb rgb) noexcept
Static convenience function that returns a QColor constructed from the given QRgb value rgb.
Definition qcolor.cpp:2369
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
pointer data()
Definition qlist.h:414
void resize(qsizetype size)
Definition qlist.h:392
\inmodule QtCore
Definition qrandom.h:209
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 * global()
Definition qrandom.cpp:1133
quint64 generate()
Generates one 64-bit random value and returns it.
Definition qrandom.h:214
\inmodule QtCore \reentrant
Definition qrandom.h:21
quint32 generate()
Generates a 32-bit random quantity and returns it.
Definition qrandom.h:48
static Q_DECL_CONST_FUNCTION QRandomGenerator * global()
\threadsafe
Definition qrandom.h:275
quint64 generate64()
Generates a 64-bit random quantity and returns it.
Definition qrandom.h:53
double bounded(double highest)
Generates one random double in the range between 0 (inclusive) and highest (exclusive).
Definition qrandom.h:72
void fillRange(UInt *buffer, qsizetype count)
Generates count 32- or 64-bit quantities (depending on the type UInt) and stores them in the buffer p...
Definition qrandom.h:141
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLuint GLuint end
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLenum array
GLenum GLsizei len
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
unsigned int quint32
Definition qtypes.h:45
long long qint64
Definition qtypes.h:55
QRandomGenerator prng2(1234)
QList< quint32 > list
[8]
return generateDouble() *highest
[11]
QRandomGenerator64 rd
[10]
std::seed_seq sseq(seedBuffer, seedBuffer+len)
[3]
QRandomGenerator prng1(1234)
[0]
QRandomGenerator generator(sseq)
std::uniform_real_distribution dist(1, 2.5)
[2]