Symphony Of Empires
DiscreteDistribution< T > Class Template Reference

Uses the Aiias method to generate a lookup table of with different probabilties. More...

#include <disc_dist.hpp>

Public Member Functions

 DiscreteDistribution (std::vector< T > items, std::vector< float > probabilities)
 
 ~DiscreteDistribution ()=default
 
get_item ()
 Get a random item with a certian probabilty, thread safe. More...
 

Detailed Description

template<typename T>
class DiscreteDistribution< T >

Uses the Aiias method to generate a lookup table of with different probabilties.

Template Parameters
TThe type of items to obtain the probability from https://www.keithschwarz.com/darts-dice-coins/ https://en.wikipedia.org/wiki/Alias_method

Definition at line 39 of file disc_dist.hpp.

Constructor & Destructor Documentation

◆ DiscreteDistribution()

template<typename T >
DiscreteDistribution< T >::DiscreteDistribution ( std::vector< T >  items,
std::vector< float >  probabilities 
)
inline

Definition at line 45 of file disc_dist.hpp.

◆ ~DiscreteDistribution()

template<typename T >
DiscreteDistribution< T >::~DiscreteDistribution ( )
default

Member Function Documentation

◆ get_item()

template<typename T >
T DiscreteDistribution< T >::get_item ( )
inline

Get a random item with a certian probabilty, thread safe.

Definition at line 92 of file disc_dist.hpp.


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