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

(cherry picked from commit a1e3b54e076bf0361d23ace53703a4e501354d7c)
This commit is contained in:
Shauren authored and Aokromes committed 2017-06-07 09:14:37 +02:00
1 parent 0bb27ecd4b
commit 38d1fc9ab3
3 files changed
+115 -48

No files matched your search

+8 -1
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;
}