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:
JANG SUN HYUK 2016-04-07 12:46:54 +09:00 committed by minggo
parent 43a70f0a92
commit 107cef0667
2 changed files with 2 additions and 2 deletions

View File

@ -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;

View File

@ -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;