Core/Utils: Changed all Trinity::Containers utilities to work on all container types (including arrays where it makes sense)

* Added MapGetValuePtr to allow writing `if (Val* v = MapGetValuePtr(map, key))`
* Added utility IteratorPair class with begin/end methods and MapEqualRange for use in range for syntax with multimaps
This commit is contained in:
Shauren
2017-03-21 21:04:01 +01:00
parent 9cc5273cd2
commit a1e3b54e07
3 changed files with 115 additions and 48 deletions

View File

@@ -20,8 +20,10 @@
#include "Errors.h"
#include "SFMT.h"
#include <boost/thread/tss.hpp>
#include <random>
static boost::thread_specific_ptr<SFMTRand> sfmtRand;
static SFMTEngine engine;
static SFMTRand* GetRng()
{
@@ -84,8 +86,13 @@ double rand_chance()
return GetRng()->Random() * 100.0;
}
uint32 urandweighted(size_t count, double const* chances)
{
std::discrete_distribution<uint32> dd(chances, chances + count);
return dd(SFMTEngine::Instance());
}
SFMTEngine& SFMTEngine::Instance()
{
static SFMTEngine engine;
return engine;
}