C ++中的哈希表v/s STL映射

2022-01-08 00:00:00 hashtable hashmap c++

我正在尝试学习 C++ 映射.只是想知道 STL map 的实现.我读到它采用二叉搜索树.

I am trying to learn C++ maps. Was just wondering about the implementation of STL map. I read it employs Binary search tree.

  1. STL 中是否有哈希表的实现?

  1. Is there a implementation of hash table in STL?

STL map 究竟是如何存储键值对的?

How exactly do STL map stores Key Value pairs?

推荐答案

典型的 STL 实现基于红黑树.C++ TR1 提供使用哈希表实现的 std::tr1::unordered_map.Boost 还提供了一个 unordered_map 哈希表实现.

Typical STL implementations are based on Red-Black trees. C++ TR1 provides std::tr1::unordered_map which uses a hash table implementation. Boost also provides an unordered_map hash table implementation.

C++11 现在有 std::unordered_map

C++11 now has std::unordered_map

相关文章