mirror of https://github.com/axmolengine/axmol.git
getRandomObject() in Vector, Map is changed
* getRandomObject is changed https://github.com/cocos2d/cocos2d-x/issues/15270 getRandomObject issue in Vector * Update CCMap.h * Update CCVector.h
This commit is contained in:
parent
43a70f0a92
commit
107cef0667
|
@ -346,7 +346,7 @@ public:
|
|||
{
|
||||
if (!_data.empty())
|
||||
{
|
||||
ssize_t randIdx = rand() % _data.size();
|
||||
ssize_t randIdx = RandomHelper::random_int<int>(0, _data.size()-1);
|
||||
const_iterator randIter = _data.begin();
|
||||
std::advance(randIter , randIdx);
|
||||
return randIter->second;
|
||||
|
|
|
@ -279,7 +279,7 @@ public:
|
|||
{
|
||||
if (!_data.empty())
|
||||
{
|
||||
ssize_t randIdx = rand() % _data.size();
|
||||
ssize_t randIdx = RandomHelper::random_int<int>(0,_data.size()-1);
|
||||
return *(_data.begin() + randIdx);
|
||||
}
|
||||
return nullptr;
|
||||
|
|
Loading…
Reference in New Issue