<分区>
我知道我们可以做到 std::unordered_map<key, value> my_map;
当我尝试查看尺寸时,它显示 zero
当我尝试查看 bucket_count 时,它给出了 11
.
我想做的是这样的std::unordered_map<key, value> my_map(1000);
但我收到错误 expected identifier before numeric constant
我想设置哈希表的大小,这样当 vector 重新分配内存(将值从旧内存位置(小)复制到新内存位置(大))时,我不会遇到与 vector 相同的问题。 Since I have large data of specific size (~100,000) that I want to hash, this motivates me to do preallocation
当我在 cppreference 中看到 unordered_map 构造函数时它需要分配器、哈希函数等。我们真的需要提供这么多信息来将我的 HashMap 设置为特定大小吗?