C++ Hash tables
Some compilers (mingw off the top of my head) support __gnu_cxx::hash_table<> as an extension of the C++ Standard Library.
Right now it depends on your compiler. But I believe hash_map is going to be added to the C++ Standard Library once the C++ Standards Committee finalizes the next language draft.
Good luck.
Right now it depends on your compiler. But I believe hash_map is going to be added to the C++ Standard Library once the C++ Standards Committee finalizes the next language draft.
Good luck.
There is a non-standard std::hash_map or stdext::hash_map (depending on the compiler... yes, 'std' is improper here). There also is the upcoming std::tr1::unordered_map, for which you will have to wait.
Currently, the closest standard container would be a std::map, which offers O(log n) operations.
Currently, the closest standard container would be a std::map, which offers O(log n) operations.
You can use maps, just don't use something like std::map<std::string, mystruct> it's very slow. I use hash_map so I haven't tried it but I suppose you could just create a map using hash of your string as a key and use that to retrieve the result in a fast way. It's just not as convenient as using hash maps directly and you have to write your own hashing functions too. At this point I'd just bite the bullet and use a 3rd party hash_map.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement