【发布时间】:2019-09-11 01:59:18
【问题描述】:
我正在使用 C++ boost unordered_map 哈希表。
我可以使用local_iterator 来遍历特定的桶。
现在,我想擦除这个桶中的一些元素。
ShmHashMap::local_iterator it = hash_table_->begin(bucket_idx);
while(it != hash_table_->end(bucket_idx)) {
if(it->second >= now_time) {
it++;
continue;
}
hash_table_->erase(it);// this usage is not supported
// although I can `hash_table_->erase(it->first)`, this usage is inefficient
it++;
}
那么,有没有办法通过local_iterator擦除元素?
【问题讨论】:
标签: c++ boost hashtable unordered-map