Hashtable in C++?

后端 未结 9 852
孤城傲影
孤城傲影 2020-12-02 08:53

I usually use C++ stdlib map whenever I need to store some data associated with a specific type of value (a key value - e.g. a string or other object). The stdlib map implem

相关标签:
9条回答
  • 2020-12-02 09:31

    If you have the TR1 extensions available for yor compiler, use those. If not, boost.org has a version that's quite similar except for the std:: namespace. In that case, put in a using-declaration so you can switch to std:: later.

    0 讨论(0)
  • 2020-12-02 09:35

    If you're using C++11, you have access to the <unordered_map> and <unordered_set> headers. These provide classes std::unordered_map and std::unordered_set.

    If you're using C++03 with TR1, you have access to the classes std::tr1::unordered_map and std::tr1::unordered_set, using the same headers (unless you're using GCC, in which case the headers are <tr1/unordered_map> and <tr1/unordered_set> instead).

    In all cases, there are corresponding unordered_multimap and unordered_multiset types too.

    0 讨论(0)
  • 2020-12-02 09:37

    If you don't already have unordered_map or unordered_set, they are part of boost.
    Here's the documentation for both.

    0 讨论(0)
  • 2020-12-02 09:37

    std::hash_map

    0 讨论(0)
  • 2020-12-02 09:42

    std::tr1::unordered_map, in <unordered_map>

    if you don't have tr1, get boost, and use boost::unordered_map in <boost/unordered_map.hpp>

    0 讨论(0)
  • 2020-12-02 09:42

    See std::hash_map from SGI.

    This is included in the STLPort distribution as well.

    0 讨论(0)
提交回复
热议问题