The RandomGenerator class.
More...
Inherits QObject, and QStringList.
|
void | append (const QString &sValue) |
| Inserts a defined String at the end of the list. More...
|
|
int | appendStringList (const QStringList &sList) |
| Inserts a defined StringList at the end of the list. More...
|
|
const QString | at (int i) const |
| Returns the String at index position i in the StringList. More...
|
|
void | clear () |
| Removes all items from the list. More...
|
|
int | count () const |
| Returns the number of String items in the list. More...
|
|
int | count (const QString &sValue) const |
| Returns the number of a particular String occurrences in the list. More...
|
|
int | indexOf (const QString &sValue, int nFrom=0) const |
| Returns the index position of the first occurrence of the defined String in the list. More...
|
|
void | insert (int i, const QString &sValue) |
| Inserts a defined String value at specific index position i. More...
|
|
bool | isEmpty () const |
| Returns true if the list contains no Strings; otherwise returns false. More...
|
|
QStringList | randomize (int rMethod=(int) RandomGenerator_RandomizeStandard, QStringList sList=QStringList()) |
| Randomizes and return the String List. More...
|
|
double | randomizeDouble (double dMin, double dMax) |
| Creates a random Double value. More...
|
|
int | randomizeInt (int nMin, int nMax) |
| Creates a random Integer value. More...
|
|
int | removeAll (const QString &sValue) |
| Removes all occurrences of a String in the list and returns the number of entries removed. More...
|
|
void | removeAt (int i) |
| Removes the String at a defined index position in the list. More...
|
|
void | swap (int i, int j) |
| Exchange the String value at index position i with the String value at index position j. More...
|
|
QString | takeAt (int i) |
| Removes the String at a defined index position in the list and returns it. More...
|
|
QString | takeFirst () |
| Removes the first String in the list and returns it. More...
|
|
QString | takeLast () |
| Removes the last String in the list and returns it. More...
|
|
QStringList | toStringList () |
| Returns the String List. More...
|
|
The RandomGenerator class.
The Random Generator can be used to create and edit randomized lists and numbers. For the randomization it combines two different random number generators (Mersenne twister and Mother-of-All (Multiply with carry).
The enum (RandomGenerator_RandomizeMethod) can store a Randomization method
Enumerator |
---|
RandomGenerator_RandomizeStandard |
0: Standard randomization, it combines two different random number generators (Mersenne twister and Mother-of-All (Multiply with carry).
|
RandomGenerator_RandomizePreservedIndexes |
1: Standard randomization where a custom array can be provided that contains the indexes of the values inside the randomization array that are forced to be present in the new randomized array. These values of those indexes are thus preserved but their positions (indexes) are randomized.
|
RandomGenerator_RandomizePreservedValues |
2: Standard randomization where a custom array can be provided that contains the values inside the randomization array that are forced to be present in the new randomized array. These values are thus preserved but their positions (indexes) are randomized.
|
RandomGenerator_RandomizePreservedNonRandomizedIndexes |
3: The same as RandomGenerator::RandomGenerator_RandomizePreservedIndexes, the values of the indexes are also preserved but their positions (indexes) are NOT randomized.
|
RandomGenerator::RandomGenerator |
( |
QObject * |
parent = NULL | ) |
|
The RandomGenerator constructor.
You do not need to specify the parent object. The BrainStim script engine automatically retrieves the parent role
RandomGenerator::~RandomGenerator |
( |
| ) |
|
The RandomGenerator destructor.
You do not need call the destructor. The BrainStim script engine automatically performs the garbage collection after you set the object to NULL and the script ends
void RandomGenerator::append |
( |
const QString & |
sValue | ) |
|
|
slot |
Inserts a defined String at the end of the list.
This operation is typically very fast (constant time), because the list preallocates extra space on both sides of its internal buffer to allow for fast growth at both ends of the list.
- Parameters
-
sValue | an String value that should be inserted at the end of the list. |
int RandomGenerator::appendStringList |
( |
const QStringList & |
sList | ) |
|
|
slot |
Inserts a defined StringList at the end of the list.
This function inserts a defined StringList to the end of the list and returns the number of Strings in the list.
- Parameters
-
sList | an StringList (array) that should be inserted at the end of the list. |
- Returns
- an integer value representing the number of Strings in the list.
const QString RandomGenerator::at |
( |
int |
i | ) |
const |
|
slot |
Returns the String at index position i in the StringList.
This function returns the String at index position i in the list, i must be a valid index position in the list (i.e., 0 <= i < RandomGenerator::count()). This function is very fast (constant time).
- Parameters
-
i | an integer value that holds the index position. |
- Returns
- an String value containing the item at index position in the list.
void RandomGenerator::clear |
( |
| ) |
|
|
slot |
Removes all items from the list.
This function removes all items from the list.
int RandomGenerator::count |
( |
| ) |
const |
|
slot |
Returns the number of String items in the list.
- Returns
- an integer value containing the number of String items in the list.
int RandomGenerator::count |
( |
const QString & |
sValue | ) |
const |
|
slot |
Returns the number of a particular String occurrences in the list.
- Parameters
-
sValue | an String value that holds the String to search for in the list. |
- Returns
- an integer value containing the number of a particular String occurrences in the list.
int RandomGenerator::indexOf |
( |
const QString & |
sValue, |
|
|
int |
nFrom = 0 |
|
) |
| const |
|
slot |
Returns the index position of the first occurrence of the defined String in the list.
This function Returns the index position of the first occurrence of the defined String in the list, searching forward from index position nFrom. Note that QList uses 0-based indexes.
- Parameters
-
sValue | the String value to search for in the list. |
nFrom | an integer value holding the starting index position for the search operation. This value is 0 if not defined. |
- Returns
- an integer holding the index of the first occurrence of the defined String in the list. This function returns -1 if no item matched.
void RandomGenerator::insert |
( |
int |
i, |
|
|
const QString & |
sValue |
|
) |
| |
|
slot |
Inserts a defined String value at specific index position i.
This function inserts a String value at index position i in the list. If i is 0, the value is prepended to the list. If i is RandomGenerator::count(), the value is appended to the list.
- Parameters
-
i | an integer value holding the index position. |
sValue | the String value to insert to the list. |
bool RandomGenerator::isEmpty |
( |
| ) |
const |
|
slot |
Returns true if the list contains no Strings; otherwise returns false.
- Returns
- an boolean value representing whether the list was empty or not.
Randomizes and return the String List.
This function randomizes and then returns the randomized String List.
- Parameters
-
- Returns
- a randomized StringList (array).
double RandomGenerator::randomizeDouble |
( |
double |
dMin, |
|
|
double |
dMax |
|
) |
| |
|
slot |
Creates a random Double value.
This function creates a random double value between (and including) a defined range.
- Parameters
-
dMin | an integer value that determines the minimal double value of the range where a random number is picked from. |
dMax | an integer value that determines the maximal double value of the range where a random number is picked from. |
- Returns
- an random integer value between (and including) a defined range. If the range is not correct it returns 0x80000000;
int RandomGenerator::randomizeInt |
( |
int |
nMin, |
|
|
int |
nMax |
|
) |
| |
|
slot |
Creates a random Integer value.
This function creates a random integer value between (and including) a defined range.
- Parameters
-
nMin | an integer value that determines the minimal integer value of the range where a random number is picked from. |
nMax | an integer value that determines the maximal integer value of the range where a random number is picked from. |
- Returns
- an random integer value between (and including) a defined range. If the range is not correct it returns 0x80000000;
int RandomGenerator::removeAll |
( |
const QString & |
sValue | ) |
|
|
slot |
Removes all occurrences of a String in the list and returns the number of entries removed.
- Parameters
-
sValue | the String value that should be removed (all) from the list. |
- Returns
- an integer value representing the number of entries that were removed.
void RandomGenerator::removeAt |
( |
int |
i | ) |
|
|
slot |
Removes the String at a defined index position in the list.
This function assumes the list is not empty. To avoid failure, call RandomGenerator::isEmpty() before calling this function. This operation takes constant time.
- Parameters
-
i | an integer value holding the index position. |
void RandomGenerator::swap |
( |
int |
i, |
|
|
int |
j |
|
) |
| |
|
slot |
Exchange the String value at index position i with the String value at index position j.
This function assumes that both i and j are at least 0 but less than RandomGenerator::count(). To avoid failure, test that both i and j are at least 0 and less than RandomGenerator::count().
- Parameters
-
i | an integer value holding the first index position. |
j | an integer value holding the second index position. |
QString RandomGenerator::takeAt |
( |
int |
i | ) |
|
|
slot |
Removes the String at a defined index position in the list and returns it.
This function assumes the list is not empty. To avoid failure, call RandomGenerator::isEmpty() before calling this function. This operation takes constant time.
- Parameters
-
i | an integer value holding the index position. |
- Returns
- a String value containing the removed String from the list.
QString RandomGenerator::takeFirst |
( |
| ) |
|
|
slot |
Removes the first String in the list and returns it.
This function assumes the list is not empty. To avoid failure, call RandomGenerator::isEmpty() before calling this function. This operation takes constant time.
- Returns
- a String value containing the removed String from the list.
QString RandomGenerator::takeLast |
( |
| ) |
|
|
slot |
Removes the last String in the list and returns it.
This function assumes the list is not empty. To avoid failure, call RandomGenerator::isEmpty() before calling this function. This operation takes constant time.
- Returns
- a String value containing the removed String from the list.
QStringList RandomGenerator::toStringList |
( |
| ) |
|
|
slot |
Returns the String List.
This function returns the String List.
- Returns
- the StringList (array).