first commit
This commit is contained in:
55
include/platform/rand/rand.h
Normal file
55
include/platform/rand/rand.h
Normal file
@ -0,0 +1,55 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#ifndef __NRAND__
|
||||
#define __NRAND__
|
||||
|
||||
|
||||
#include "ntypes.h"
|
||||
|
||||
|
||||
namespace GS {
|
||||
namespace Random {
|
||||
|
||||
#ifndef RAND_MAX
|
||||
#define RAND_MAX 0x7fff
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@short A random number generator class.
|
||||
|
||||
@note The maximum precision of this generator is fixed to 16bit integer.
|
||||
This means that you cannot get, even with floats, more than 65536
|
||||
different values. But this generator has, of course, no query
|
||||
limit.
|
||||
|
||||
@author Emmanuel Julien (ejulien@gsworks.fr)
|
||||
*/
|
||||
/// Set the starting seed of the random number generator.
|
||||
void Seed(uint s);
|
||||
/// Return an integer random number in the range [0;r] (default [0;RAND_MAX].
|
||||
uint Rand(uint r = RAND_MAX);
|
||||
/// Return a float random value in the range [0;r] (default [0;1]).
|
||||
float FRand(float r = 1.0f);
|
||||
/// Return a float random value un the range [lo, hi] (default [-1, 1]).
|
||||
float FRRand(float lo = -1, float hi = 1);
|
||||
/*!
|
||||
@short Pseudo-unique random number generator.
|
||||
|
||||
A random number generator that tries to feed a different number
|
||||
than what was returned at the previous call.
|
||||
This class is a wrapper for Rand().
|
||||
|
||||
@note The number 'might' still be the same.
|
||||
*/
|
||||
uint CRand(uint r = RAND_MAX);
|
||||
|
||||
} // Random
|
||||
} // GS
|
||||
|
||||
|
||||
#endif // __NRAND__
|
||||
|
||||
Reference in New Issue
Block a user