C ++ 11在unordered_map中获取一个存储桶的所有项 [英] C++11 get all items of one bucket in a unordered_map
问题描述
我们知道 std :: unordered_map :: bucket
return桶是容器内部哈希表中的一个槽,根据其键的哈希值将元素分配给该槽。如何在返回存储区中获取begin-iterator和end-iterator?换句话说,我可以使用 bucket_count
来获取存储桶数,如何检测每个存储桶中的项目?
we know std::unordered_map::bucket
return A bucket is a slot in the container's internal hash table to which elements are assigned based on the hash value of their key. How can I get the begin-iterator and end-iterator in the return bucket ? In other word, I can use bucket_count
to get count of buckets, how can detect items in each bucket?
推荐答案
您可以使用 std :: unordered_map :: begin(int)和 std :: unordered_map :: end(int) 获取特定存储桶的迭代器。
You can use std::unordered_map::begin(int) and std::unordered_map::end(int) to get iterators for a particular bucket.
这篇关于C ++ 11在unordered_map中获取一个存储桶的所有项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!