25

Possible Duplicates:
Hashtable in C++?
can anybody offer a simple hash_map example in C++?

Does the STL contain an implementation of a hashtable?

If so, can you provide a brief example of how to use it?

Community
  • 1
  • 1
Mithrax
  • 7,603
  • 18
  • 55
  • 60
  • there is, and I think it's called hashmap or hash_map. Google should be able to help you out. – falstro Feb 03 '10 at 15:21
  • 6
    Dupe http://stackoverflow.com/questions/133569/hashtable-in-c. This is actually the first entry in the "Related" list on the RHS of this page. And for a use case, http://stackoverflow.com/questions/2179946/can-anybody-offer-a-simple-hash-map-example-in-c –  Feb 03 '10 at 15:21
  • also duplicate of first related question http://stackoverflow.com/questions/133569/hashtable-in-c – falstro Feb 03 '10 at 15:21

3 Answers3

13

Current standard implementation doesn't, STL::TR1 does, see Unordered Map.

Most modern compilers have a TR1 implementation, if that fails, you may always use the Boost TR1 implementation.

  • MSVC has it for VS2008 via service pack 1
  • GCC has it shipped with 4.x, but you can make it work with 3.4.x too AFAIR

Usage is almost the same as with a std::map.

Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149
3

While not officially part of the STL standard, hash_map and hash_set are commonly used to improve searching times......

http://msdn.microsoft.com/en-us/library/0d462wfh%28VS.80%29.aspx

So, long story short--no .

bdd
  • 3,436
  • 5
  • 31
  • 43
0

A quick google came up with this description of hash_map.

Maurits Rijk
  • 9,789
  • 2
  • 36
  • 53