LoginSignup
3
3

More than 5 years have passed since last update.

cocos2dx v3 Map

Last updated at Posted at 2014-08-08

cocos2d::Mapの挙動について

試したバージョン
cocos2dx 3.2
ndk-r9d

こんな感じのコードをかくと


class Obj : public cocos2d::Ref
{
public:
CREATE_FUNC(Obj);
bool init() { return true; }
CC_SYNTHESIZE(std::string, name, Name);
static Obj* create(std::string str) {
auto o = create();
o->setName(str);
return o;
}

};

cocos2d::Map<int, Obj*> m;
m.insert(1, Obj::create("obj1"));
m.insert(2, Obj::create("obj2"));
m.insert(3, Obj::create("obj3"));
m.insert(4, Obj::create("obj4"));

for(auto a : m) {
CCLOG("map=>%d,%s", a.first, a.second->getName());
}

androidだとこうなる。
map=>4,obj4
map=>3,obj3
map=>2,obj2
map=>1,obj1

iosだと
map=>1,obj1
map=>2,obj2
map=>3,obj3
map=>4,obj4

いろいろと実験してみたところ、

CCMap.h
#define USE_STD_UNORDERED_MAP 0

にするとunordered_mapをmapにするとandroidでもiosと同じ用に出力された。

ndkの問題なのかな。。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3