在Java和C#现在我回到C++。当然,我的编程风格受这些语言的影响,我倾向于感受到我大量使用的特殊组件的需求:HASH MAP。在STL中有hash_map,GCC表示它已被弃用,我应该使用unordered_map。所以我转向它。我承认我不确定我在做什么的可移植性,因为我不得不使用编译器开关来打开即将到来的标准的功能-std = C++ 0x。无论如何,我对此感到高兴。只要我能不能得到它的工作,因为如果我把我的班C + + STL unordered_map问题和疑惑
std::unordered_map<unsigned int, baseController*> actionControllers;
和方法:
void baseController::attachActionController(unsigned int *actionArr, int len,
baseController *controller) {
for (int i = 0; i < len; i++){
actionControllers.insert(actionArr[i], controller);
}
}
它出来跟平时ieroglyphs说,它不能找到插入...提示?
顺便说一句,为什么不使用std :: map来代替?这将解决您的便携性问题。 – hrnt 2009-11-12 12:57:23
地图有一个哈希映射的访问时间保证不一样......这就是为什么我使用它。 – gotch4 2009-11-12 13:08:01