KRandom

KRandom Namespace Reference

Functions

KCOREADDONS_EXPORT QString randomString (int length)
 
template<typename T >
void shuffle (T &container)
 
template<typename T >
void shuffle (T &container, QRandomGenerator *generator)
 

Detailed Description

Helper class to create random data.

This namespace provides methods which generate random data. KRandom is not recommended for serious random-number generation needs, like cryptography.

Function Documentation

◆ randomString()

QString KRandom::randomString ( int length)

Generates a random string.

It operates in the range [A-Za-z0-9]

Parameters
lengthGenerate a string of this length.
Returns
the random string

Definition at line 30 of file krandom.cpp.

◆ shuffle() [1/2]

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[]

Since
5.73

Definition at line 65 of file krandom.h.

◆ shuffle() [2/2]

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[]

Since
5.73

Definition at line 47 of file krandom.h.

This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.