class KRandomSequence

A class to create a pseudo-random sequence More...

Definition#include <krandomsequence.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

A class to create a pseudo-random sequence

Given a seed number, this class will produce a sequence of pseudo-random numbers. This would typically be used in applications like games.

In general, you should instantiate a KRandomSequence object and pass along your seed number in the constructor. From then on, simply call getDouble or getLong to obtain the next number in the sequence.

 KRandomSequence ( long lngSeed = 0 )

KRandomSequence

Creates a pseudo-random sequence based on the seed lngSeed.

If lngSeed is 0, the sequence is initialized with a value from kapp->random().

A Pseudo-random sequence is different for each seed but can be reproduced by starting the sequence with the same seed.

If you need a single value which needs to be unpredictable, you need to use kapp->random() instead.

Parameters:
lngSeedSeed to initialize the sequence with.

 ~KRandomSequence ()

~KRandomSequence

[virtual]

Standard destructor

void  setSeed ( long lngSeed = 1 )

setSeed

Restart the sequence based on lngSeed

double  getDouble ()

getDouble

Get the next number from the pseudo-random sequence

Returns: a psuedo-random double value between [0,1[

unsigned long  getLong (unsigned long max)

getLong

Get the next number from the pseudo-random sequence

Returns: a pseudo-random integer value between [0, max[ with 0 <= max < 1.000.000

bool  getBool ()

getBool

Get a boolean from the pseudo-random sequence

Returns: a boolean which is either true or false

void  randomize (QGList *list)

randomize

Put a list in random order

Returns: modifies the order of list