Sign in to follow this  
bulgurmayo

hash map in C++

Recommended Posts

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>).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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:
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this