문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top