开发者

hash_map and stdext:: hash_map?

Under the visual C++, we have " hash_map" and "hash_set". In g++, we have " stdext::hash_map" and " stdext::hash_set". Is there any difference in terms of their respe开发者_开发问答ctive performance or other factors?


None of those are standards. They were just there to fill a need. Concerning the performances, I have no idea, but I guess they're really similar.

What existed in TR1, and will be included in C++1X is unordered_map and unordered_set They say they changed the name to avoid any confusion with previous non-standard implementations.

http://www2.research.att.com/~bs/C++0xFAQ.html#std-unordered


As Tristram points out, the standard is (or will be) unordered_map. How to get it is a little confusing. Probably the best way going forward is:

#include <unordered_map>

int main() {
    std::unordered_map<int,int> m;
}

and with g++ compile with the C++0X switch:

g++ -std=c++0x mymap.cpp
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜