C++11 get all items of one bucket in a unordered_map

廉价感情. 提交于 2019-12-04 04:11:54

问题


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?


回答1:


You can use std::unordered_map::begin(int) and std::unordered_map::end(int) to get iterators for a particular bucket.



来源:https://stackoverflow.com/questions/31402314/c11-get-all-items-of-one-bucket-in-a-unordered-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!