Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Private Attributes | List of all members
cRandomWrapper< RandomEngine > Class Template Reference

Class to wrap any random engine to provide a more convenient interface. More...

#include <FastRandom.h>

Public Member Functions

 cRandomWrapper ()
 Initialize with a low quality seed. More...
 
template<class SeedSeq >
 cRandomWrapper (SeedSeq &a_SeedSeq)
 Initialize with a SeedSequence. More...
 
RandomEngine & Engine ()
 Returns a reference to the underlying random engine. More...
 
bool RandBool (double a_TrueProbability=0.5)
 Return a random bool with the given probability of being true. More...
 
template<class IntType = int>
IntType RandInt ()
 Return a random IntType in the range [0, std::numeric_limits<IntType>::max()]. More...
 
template<class IntType = int>
IntType RandInt (IntType a_Max)
 Return a random IntType in the range [0, a_Max]. More...
 
template<class IntType = int>
IntType RandInt (IntType a_Min, IntType a_Max)
 Return a random IntType in the range [a_Min, a_Max]. More...
 
template<class RealType = float>
RealType RandReal ()
 Return a random RealType in the range [0, 1). More...
 
template<class RealType = float>
RealType RandReal (RealType a_Max)
 Return a random RealType in the range [0, a_Max). More...
 
template<class RealType = float>
RealType RandReal (RealType a_Min, RealType a_Max)
 Return a random RealType in the range [a_Min, a_Max). More...
 

Private Attributes

RandomEngine m_Engine
 

Detailed Description

template<class RandomEngine>
class cRandomWrapper< RandomEngine >

Class to wrap any random engine to provide a more convenient interface.

Definition at line 57 of file FastRandom.h.

Constructor & Destructor Documentation

◆ cRandomWrapper() [1/2]

template<class RandomEngine >
cRandomWrapper< RandomEngine >::cRandomWrapper ( )
inline

Initialize with a low quality seed.

Definition at line 61 of file FastRandom.h.

◆ cRandomWrapper() [2/2]

template<class RandomEngine >
template<class SeedSeq >
cRandomWrapper< RandomEngine >::cRandomWrapper ( SeedSeq &  a_SeedSeq)
inline

Initialize with a SeedSequence.

Definition at line 69 of file FastRandom.h.

Member Function Documentation

◆ Engine()

template<class RandomEngine >
RandomEngine& cRandomWrapper< RandomEngine >::Engine ( )
inline

Returns a reference to the underlying random engine.

Definition at line 168 of file FastRandom.h.

◆ RandBool()

template<class RandomEngine >
bool cRandomWrapper< RandomEngine >::RandBool ( double  a_TrueProbability = 0.5)
inline

Return a random bool with the given probability of being true.

Definition at line 158 of file FastRandom.h.

◆ RandInt() [1/3]

template<class RandomEngine >
template<class IntType = int>
IntType cRandomWrapper< RandomEngine >::RandInt ( )
inline

Return a random IntType in the range [0, std::numeric_limits<IntType>::max()].

Definition at line 111 of file FastRandom.h.

◆ RandInt() [2/3]

template<class RandomEngine >
template<class IntType = int>
IntType cRandomWrapper< RandomEngine >::RandInt ( IntType  a_Max)
inline

Return a random IntType in the range [0, a_Max].

Definition at line 98 of file FastRandom.h.

◆ RandInt() [3/3]

template<class RandomEngine >
template<class IntType = int>
IntType cRandomWrapper< RandomEngine >::RandInt ( IntType  a_Min,
IntType  a_Max 
)
inline

Return a random IntType in the range [a_Min, a_Max].

Definition at line 78 of file FastRandom.h.

◆ RandReal() [1/3]

template<class RandomEngine >
template<class RealType = float>
RealType cRandomWrapper< RandomEngine >::RandReal ( )
inline

Return a random RealType in the range [0, 1).

Definition at line 147 of file FastRandom.h.

◆ RandReal() [2/3]

template<class RandomEngine >
template<class RealType = float>
RealType cRandomWrapper< RandomEngine >::RandReal ( RealType  a_Max)
inline

Return a random RealType in the range [0, a_Max).

Definition at line 135 of file FastRandom.h.

◆ RandReal() [3/3]

template<class RandomEngine >
template<class RealType = float>
RealType cRandomWrapper< RandomEngine >::RandReal ( RealType  a_Min,
RealType  a_Max 
)
inline

Return a random RealType in the range [a_Min, a_Max).

Definition at line 123 of file FastRandom.h.

Member Data Documentation

◆ m_Engine

template<class RandomEngine >
RandomEngine cRandomWrapper< RandomEngine >::m_Engine
private

Definition at line 175 of file FastRandom.h.


The documentation for this class was generated from the following file: