jiamo
jiamo

Reputation: 1456

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

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?

Upvotes: 4

Views: 1620

Answers (1)

Ralara
Ralara

Reputation: 569

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

Upvotes: 7

Related Questions