Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

buckets in std::unordered_multiset

Say I have an std::unordered_multiset<int> which is named hashTable and a bucket i. Can I iterate through the elements of the ith bucket?

like image 709
Rontogiannis Aristofanis Avatar asked Dec 10 '25 03:12

Rontogiannis Aristofanis


1 Answers

You can indeed iterate through each bucket, using local iterators:

for (auto it = hashTable.cbegin(i); it != hashTable.cend(i); ++it)
{
    // ... use *it
}

Be sure that i lies in the range [0, hashTable.bucket_count()).

like image 178
Kerrek SB Avatar answered Dec 11 '25 17:12

Kerrek SB



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!