mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-29 19:07:15 +02:00
Merge pull request #138 from cmazakas/feature/erase-perf
erase(iterator) perf
This commit is contained in:
@ -2928,6 +2928,23 @@ namespace boost {
|
||||
return 1;
|
||||
}
|
||||
|
||||
iterator erase_node(c_iterator pos) {
|
||||
c_iterator next = pos;
|
||||
++next;
|
||||
|
||||
bucket_iterator itb = pos.itb;
|
||||
node_pointer* pp = boost::addressof(itb->next);
|
||||
while (*pp != pos.p) {
|
||||
pp = boost::addressof((*pp)->next);
|
||||
}
|
||||
|
||||
buckets_.extract_node_after(itb, pp);
|
||||
this->delete_node(pos.p);
|
||||
--size_;
|
||||
|
||||
return iterator(next.p, next.itb);
|
||||
}
|
||||
|
||||
iterator erase_nodes_range(c_iterator first, c_iterator last)
|
||||
{
|
||||
if (first == last) {
|
||||
|
@ -1856,18 +1856,14 @@ namespace boost {
|
||||
typename unordered_map<K, T, H, P, A>::iterator
|
||||
unordered_map<K, T, H, P, A>::erase(iterator position)
|
||||
{
|
||||
const_iterator last = position;
|
||||
++last;
|
||||
return table_.erase_nodes_range(position, last);
|
||||
return table_.erase_node(position);
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
typename unordered_map<K, T, H, P, A>::iterator
|
||||
unordered_map<K, T, H, P, A>::erase(const_iterator position)
|
||||
{
|
||||
const_iterator last = position;
|
||||
++last;
|
||||
return table_.erase_nodes_range(position, last);
|
||||
return table_.erase_node(position);
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
@ -2340,9 +2336,7 @@ namespace boost {
|
||||
unordered_multimap<K, T, H, P, A>::erase(iterator position)
|
||||
{
|
||||
BOOST_ASSERT(position != this->end());
|
||||
iterator next = position;
|
||||
++next;
|
||||
return table_.erase_nodes_range(position, next);
|
||||
return table_.erase_node(position);
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
@ -2350,9 +2344,7 @@ namespace boost {
|
||||
unordered_multimap<K, T, H, P, A>::erase(const_iterator position)
|
||||
{
|
||||
BOOST_ASSERT(position != this->end());
|
||||
const_iterator next = position;
|
||||
++next;
|
||||
return table_.erase_nodes_range(position, next);
|
||||
return table_.erase_node(position);
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
|
@ -1457,9 +1457,7 @@ namespace boost {
|
||||
typename unordered_set<T, H, P, A>::iterator
|
||||
unordered_set<T, H, P, A>::erase(const_iterator position)
|
||||
{
|
||||
const_iterator last = position;
|
||||
++last;
|
||||
return table_.erase_nodes_range(position, last);
|
||||
return table_.erase_node(position);
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
@ -1853,10 +1851,7 @@ namespace boost {
|
||||
unordered_multiset<T, H, P, A>::erase(const_iterator position)
|
||||
{
|
||||
BOOST_ASSERT(position != this->end());
|
||||
iterator next = position;
|
||||
++next;
|
||||
table_.erase_nodes_range(position, next);
|
||||
return next;
|
||||
return table_.erase_node(position);
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
|
Reference in New Issue
Block a user