forked from boostorg/unordered
Implement merge
This commit is contained in:
@@ -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
|
||||
//
|
||||
|
Reference in New Issue
Block a user