假设我有一个 std::unordered_multiset<int>
名为 hashTable
和一个水桶i
.我可以遍历 i
的元素吗?第桶?
最佳答案
您确实可以使用本地迭代器遍历每个存储桶:
for (auto it = hashTable.cbegin(i); it != hashTable.cend(i); ++it)
{
// ... use *it
}
确保 i
位于 [0, hashTable.bucket_count())
范围内。
关于c++ - std::unordered_multiset 中的桶,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13036036/