Implement merge

This commit is contained in:
Daniel James
2017-02-27 03:59:02 +00:00
parent 21a24d6cd7
commit d89aadc56c
8 changed files with 522 additions and 0 deletions

View File

@@ -3840,6 +3840,30 @@ struct table_impl : boost::unordered::detail::table<Types>
return iterator(pos);
}
template <typename Types2> void merge_impl(table_impl<Types2>& other)
{
if (other.size_) {
link_pointer prev = other.get_previous_start();
while (prev->next_) {
node_pointer n = other.next_node(prev);
const_key_type& k = this->get_key(n->value());
std::size_t key_hash = this->hash(k);
node_pointer pos = this->find_node(key_hash, k);
if (pos) {
prev = n;
} else {
this->reserve_for_insert(this->size_ + 1);
prev->next_ = n->next_;
--other.size_;
other.fix_bucket(other.hash_to_bucket(n->hash_), prev);
this->add_node(n, key_hash);
}
}
}
}
////////////////////////////////////////////////////////////////////////
// Insert range methods
//