Rontogiannis Aristofanis
Rontogiannis Aristofanis

Reputation: 9073

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?

Upvotes: 3

Views: 243

Answers (1)

Kerrek SB
Kerrek SB

Reputation: 477710

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()).

Upvotes: 8

Related Questions