KRandom Namespace
Helper to create random data. More...
- Header:
#include <KRandom> - CMake:
find_package(KF6 REQUIRED COMPONENTS CoreAddons)
target_link_libraries(mytarget PRIVATE KF6::CoreAddons)
Detailed Description
This namespace provides methods which generate random data. KRandom is not recommended for serious random-number generation needs, like cryptography.
Function Documentation
QString KRandom::randomString(int length)
Generates a random string. It operates in the range [A-Za-z0-9]
length Generate a string of this length.
Returns the random string
template <typename T> void KRandom::shuffle(T &container)
Reorders the elements of the given container randomly.
The container needs to implement size() and T &operator[]
template <typename T> void KRandom::shuffle(T &container, QRandomGenerator *generator)
Reorders the elements of the given container randomly using the given random number generator.
The container needs to implement size() and T &operator[]