确实会提升::unordered_multimap调整大小
Does boost::unordered_multimap resize
初始化 boost::unordered_multimap 时,我们定义哈希映射的大小。
explicit unordered_multimap(size_type n = implementation-defined,
hasher const& hf = hasher(),
key_equal const& eq = key_equal(),
allocator_type const& a = allocator_type());
Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0.
当哈希映射几乎已满时,它会调整大小吗?它似乎没有这样的 API。它会自动完成吗?定义unordered_multimap大小的最佳做法是什么?
它将自动执行此操作,如文档所示:
存储桶的数量可以通过调用插入或调用 rehash 来自动增加。
但请记住,它在缩小时不会重新散列:为什么C++11/Boost 'unordered_map'在擦除时不会重新散列?
您可以通过手动强制降低负载系数并将最大负载系数设置得足够高(http://www.boost.org/doc/libs/1_64_0/doc/html/boost/unordered_map.html#idp776321712-bb、http://www.boost.org/doc/libs/1_64_0/doc/html/boost/unordered_map.html#idp776318000-bb)来防止不必要的重新哈希
相关文章:
- 使用std::multimap迭代器创建std::list
- 为char数组调整zlib-zpipe
- 调整大小后指向元素值的指针unordered_map有效?
- 在C++中调整向量中的索引
- 哪些库可以通过Opencv调整曝光率
- 如何调整 std::vector of Eigen::MatrixXd 的大小
- Alt+Enter 在 Win32 应用中,管理大小调整和分辨率
- 在容量内调整矢量大小时的性能影响
- 将 boost::odeint 与向量类一起使用,而无需调整向量的大小
- 将摄像机调整到俯视图
- Qt 图表条形图调整大小崩溃
- 除非重新绘制大小,否则SDL_Texture在调整大小后呈现黑色
- std::multimap<std::chrono::milliseconds, T>::rbegin 在 MSVS-13 中指向 end()?
- 调整布局上的 QGraphicsView 小部件的大小
- 如何在构建链接列表时调整头、尾指针
- 如何将旧的 C 样式 #define 映射与现代C++进行调整?
- 当您在此单词中搜索单词时调整字符数组的大小?
- SDL2 调整窗口大小后如何缩放鼠标坐标?
- 如何按另一个向量的方向调整一个向量?
- C++在使用std::multimap时出现运行时错误的几率很小