Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 440
jiamo Avatar asked Sep 04 '25 03:09

jiamo


1 Answers

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

like image 129
Ralara Avatar answered Sep 07 '25 18:09

Ralara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!