hash map in C++
I am looking for a hash map implementation in C++. I was suprised not to find any in boost. Any good recommendation
I really like Google's implementation. They have a sparse version which is very memory friendly, but a bit slower, and a dense version which takes more RAM but is blazingly fast (at least compared to MS VC++ 2003 and 2k5 for my test cases).
Oh, and if you're using GCC, remember that it's __gnu_cxx::hash_map (instead of stdext::hash_map), and found in <ext/hash_map> (instead of <hash_map>).
Quote:Original post by bulgurmayo
I am looking for a hash map implementation in C++. I was suprised not to find any in boost. Any good recommendation
The ISO C++ standards committee provided an excellent hash map. The current standard gives you std::tr1::unordered_map<typename Key, typename Value, typename Hash = std::tr1::hash<Key> > and the C++09 standard gives us the same template without the tr1:: qualification.
Any quality C++ implementation will supply something conforming to the current C++ standard, which in fact includes TR1. Yes, it's an optional part of the standard so a conforming implementation is not required to supply it, but a quality implementation should. Check yours today.
That ignores the fact that TR1 was published in late 2005, whereas most C++ compilers in use predate that. Furthermore, TR1 is not part of the standard. TR1 components are likely to find their way into the next version of the standard; however, it says specifically in the introduction:
Emphasis mine.
Quote:
This technical report is non-normative. Some of the library components in this technical report may be considered for standardization in a future version of C++, but they are not currently part of any C++ standard. Some of the components in this technical report may never be standardized, and others may be standardized in a substantially changed form.
Emphasis mine.
Quote:Original post by strtok
Oh, and if you're using GCC, remember that it's __gnu_cxx::hash_map (instead of stdext::hash_map), and found in <ext/hash_map> (instead of <hash_map>).
Good info. Also, you might find only sparse documentation for these extensions, but what I've found is that you can pretty much use the same class functions (methods) as used with the other std::<association containers>, such as std::map<> or std::set<>, for initialization, insertion, finding, etc.
--random
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement