【问题标题】:hash_map and stdext:: hash_map?hash_map 和 stdext:: hash_map?
【发布时间】:2010-06-10 07:57:16
【问题描述】:

在可视化 C++ 下,我们有“hash_map”和“hash_set”。在 g++ 中,我们有“stdext::hash_map”和“stdext::hash_set”。它们各自的性能或其他因素有什么不同吗?

【问题讨论】:

    标签: c++ visual-c++ stl


    【解决方案1】:

    这些都不是标准。他们只是在那里满足需求。至于表演,我不知道,但我想他们真的很相似。

    存在于 TR1 中并将包含在 C++1X 中的是 unordered_map 和 unordered_set 他们说他们更改了名称是为了避免与以前的非标准实现混淆。

    http://www2.research.att.com/~bs/C++0xFAQ.html#std-unordered

    【讨论】:

      【解决方案2】:

      正如 Tristram 所指出的,标准是(或将是)unordered_map。如何获得它有点令人困惑。最好的前进方式可能是:

      #include <unordered_map>
      
      int main() {
          std::unordered_map<int,int> m;
      }
      

      并使用 C++0X 开关使用 g++ 编译:

      g++ -std=c++0x mymap.cpp
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-12-11
        • 2010-11-06
        • 1970-01-01
        相关资源
        最近更新 更多