问题
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