[ACCEPTED]-Hashtable in C++?-complexity-theory
If you're using C++11, you have access to 7 the <unordered_map>
and <unordered_set>
headers. These provide classes 6 std::unordered_map
and std::unordered_set
.
If you're using C++03 with TR1, you 5 have access to the classes std::tr1::unordered_map
and std::tr1::unordered_set
, using 4 the same headers (unless you're using GCC, in 3 which case the headers are <tr1/unordered_map>
and <tr1/unordered_set>
instead).
In 2 all cases, there are corresponding unordered_multimap
and 1 unordered_multiset
types too.
If you don't already have unordered_map 1 or unordered_set, they are part of boost.
Here's the documentation for both.
There is a hash_map object as many here have mentioned, but 3 it is not part of the stl. It is a SGI 2 extension, so if you were looking for something 1 in the STL, I think you are out of luck.
Visual Studio has the class stdext::hash_map
in the header 1 <hash_map>
, and gcc has the class __gnu_cxx::hash_map
in the same header.
std::tr1::unordered_map, in <unordered_map>
if you don't 2 have tr1, get boost, and use
boost::unordered_map 1 in <boost/unordered_map.hpp>
hash_map is also supported in GNU's libstdc++.
Dinkumware 3 also supports this, which means that lots of implementations 2 will have a hash_map (I think even Visual 1 C++ delivers with Dinkumware).
If you have the TR1 extensions available 5 for yor compiler, use those. If not, boost.org 4 has a version that's quite similar except 3 for the std:: namespace. In that case, put 2 in a using-declaration so you can switch 1 to std:: later.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.