replaced erase_ backbone function with extract:_

This commit is contained in:
joaquintides 2020-05-01 20:36:38 +02:00
parent 3a47a82947
commit a766a08573
7 changed files with 32 additions and 39 deletions

View File

@ -150,10 +150,7 @@ protected:
return x; return x;
} }
void erase_(index_node_type* x) void extract_(index_node_type*){}
{
final().destroy_value(static_cast<final_node_type*>(x));
}
void clear_(){} void clear_(){}

View File

@ -755,11 +755,11 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
return res; return res;
} }
void erase_(index_node_type* x) void extract_(index_node_type* x)
{ {
node_impl_type::rebalance_for_erase( node_impl_type::rebalance_for_extract(
x->impl(),header()->parent(),header()->left(),header()->right()); x->impl(),header()->parent(),header()->left(),header()->right());
super::erase_(x); super::extract_(x);
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
detach_iterators(x); detach_iterators(x);
@ -818,7 +818,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
index_node_type* next=x; index_node_type* next=x;
index_node_type::increment(next); index_node_type::increment(next);
node_impl_type::rebalance_for_erase( node_impl_type::rebalance_for_extract(
x->impl(),header()->parent(),header()->left(),header()->right()); x->impl(),header()->parent(),header()->left(),header()->right());
BOOST_TRY{ BOOST_TRY{
@ -844,17 +844,17 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
b=in_place(x->value(),x,Category()); b=in_place(x->value(),x,Category());
} }
BOOST_CATCH(...){ BOOST_CATCH(...){
erase_(x); extract_(x);
BOOST_RETHROW; BOOST_RETHROW;
} }
BOOST_CATCH_END BOOST_CATCH_END
if(!b){ if(!b){
node_impl_type::rebalance_for_erase( node_impl_type::rebalance_for_extract(
x->impl(),header()->parent(),header()->left(),header()->right()); x->impl(),header()->parent(),header()->left(),header()->right());
BOOST_TRY{ BOOST_TRY{
link_info inf; link_info inf;
if(!link_point(key(x->value()),inf,Category())){ if(!link_point(key(x->value()),inf,Category())){
super::erase_(x); super::extract_(x);
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
detach_iterators(x); detach_iterators(x);
@ -864,7 +864,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
node_impl_type::link(x->impl(),inf.side,inf.pos,header()->impl()); node_impl_type::link(x->impl(),inf.side,inf.pos,header()->impl());
} }
BOOST_CATCH(...){ BOOST_CATCH(...){
super::erase_(x); super::extract_(x);
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
detach_iterators(x); detach_iterators(x);
@ -877,7 +877,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
BOOST_TRY{ BOOST_TRY{
if(!super::modify_(x)){ if(!super::modify_(x)){
node_impl_type::rebalance_for_erase( node_impl_type::rebalance_for_extract(
x->impl(),header()->parent(),header()->left(),header()->right()); x->impl(),header()->parent(),header()->left(),header()->right());
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
@ -889,7 +889,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
else return true; else return true;
} }
BOOST_CATCH(...){ BOOST_CATCH(...){
node_impl_type::rebalance_for_erase( node_impl_type::rebalance_for_extract(
x->impl(),header()->parent(),header()->left(),header()->right()); x->impl(),header()->parent(),header()->left(),header()->right());
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
@ -910,7 +910,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
index_node_type* next=x; index_node_type* next=x;
index_node_type::increment(next); index_node_type::increment(next);
node_impl_type::rebalance_for_erase( node_impl_type::rebalance_for_extract(
x->impl(),header()->parent(),header()->left(),header()->right()); x->impl(),header()->parent(),header()->left(),header()->right());
BOOST_TRY{ BOOST_TRY{
@ -1383,7 +1383,7 @@ private:
else index_node_type::increment(position); else index_node_type::increment(position);
if(position!=x){ if(position!=x){
node_impl_type::rebalance_for_erase( node_impl_type::rebalance_for_extract(
x->impl(),header()->parent(),header()->left(),header()->right()); x->impl(),header()->parent(),header()->left(),header()->right());
node_impl_type::restore( node_impl_type::restore(
x->impl(),position->impl(),header()->impl()); x->impl(),position->impl(),header()->impl());

View File

@ -1,4 +1,4 @@
/* Copyright 2003-2019 Joaquin M Lopez Munoz. /* Copyright 2003-2020 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt) * http://www.boost.org/LICENSE_1_0.txt)
@ -412,7 +412,7 @@ public:
ordered_index_node_impl::rebalance(x,header->parent()); ordered_index_node_impl::rebalance(x,header->parent());
} }
static pointer rebalance_for_erase( static pointer rebalance_for_extract(
pointer z,parent_ref root,pointer& leftmost,pointer& rightmost) pointer z,parent_ref root,pointer& leftmost,pointer& rightmost)
{ {
pointer y=z; pointer y=z;

View File

@ -837,10 +837,10 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
return res; return res;
} }
void erase_(index_node_type* x) void extract_(index_node_type* x)
{ {
unlink(x); unlink(x);
super::erase_(x); super::extract_(x);
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
detach_iterators(x); detach_iterators(x);
@ -960,7 +960,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
b=in_place(x->impl(),key(x->value()),buc); b=in_place(x->impl(),key(x->value()),buc);
} }
BOOST_CATCH(...){ BOOST_CATCH(...){
erase_(x); extract_(x);
BOOST_RETHROW; BOOST_RETHROW;
} }
BOOST_CATCH_END BOOST_CATCH_END
@ -969,7 +969,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
BOOST_TRY{ BOOST_TRY{
link_info pos(buckets.at(buc)); link_info pos(buckets.at(buc));
if(!link_point(x->value(),pos)){ if(!link_point(x->value(),pos)){
super::erase_(x); super::extract_(x);
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
detach_iterators(x); detach_iterators(x);
@ -979,7 +979,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
link(x,pos); link(x,pos);
} }
BOOST_CATCH(...){ BOOST_CATCH(...){
super::erase_(x); super::extract_(x);
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
detach_iterators(x); detach_iterators(x);

View File

@ -800,10 +800,10 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
return res; return res;
} }
void erase_(index_node_type* x) void extract_(index_node_type* x)
{ {
ptrs.erase(x->impl()); ptrs.erase(x->impl());
super::erase_(x); super::extract_(x);
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
detach_iterators(x); detach_iterators(x);

View File

@ -692,10 +692,10 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
return res; return res;
} }
void erase_(index_node_type* x) void extract_(index_node_type* x)
{ {
unlink(x); unlink(x);
super::erase_(x); super::extract_(x);
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
detach_iterators(x); detach_iterators(x);

View File

@ -734,8 +734,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
return std::pair<final_node_type*,bool>(res,true); return std::pair<final_node_type*,bool>(res,true);
} }
else{ else{
destroy_value(x); delete_node_(x);
deallocate_node(x);
return std::pair<final_node_type*,bool>(res,false); return std::pair<final_node_type*,bool>(res,false);
} }
} }
@ -777,8 +776,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
return std::pair<final_node_type*,bool>(res,true); return std::pair<final_node_type*,bool>(res,true);
} }
else{ else{
destroy_value(x); delete_node_(x);
deallocate_node(x);
return std::pair<final_node_type*,bool>(res,false); return std::pair<final_node_type*,bool>(res,false);
} }
} }
@ -837,8 +835,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
return std::pair<final_node_type*,bool>(res,true); return std::pair<final_node_type*,bool>(res,true);
} }
else{ else{
destroy_value(x); delete_node_(x);
deallocate_node(x);
return std::pair<final_node_type*,bool>(res,false); return std::pair<final_node_type*,bool>(res,false);
} }
} }
@ -883,8 +880,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
return std::pair<final_node_type*,bool>(res,true); return std::pair<final_node_type*,bool>(res,true);
} }
else{ else{
destroy_value(x); delete_node_(x);
deallocate_node(x);
return std::pair<final_node_type*,bool>(res,false); return std::pair<final_node_type*,bool>(res,false);
} }
} }
@ -904,8 +900,8 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
void erase_(final_node_type* x) void erase_(final_node_type* x)
{ {
--node_count; --node_count;
super::erase_(x); super::extract_(x);
deallocate_node(x); delete_node_(x);
} }
void delete_node_(final_node_type* x) void delete_node_(final_node_type* x)
@ -985,14 +981,14 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
BOOST_TRY{ BOOST_TRY{
if(!super::modify_(x)){ if(!super::modify_(x)){
deallocate_node(x); delete_node_(x);
--node_count; --node_count;
return false; return false;
} }
else return true; else return true;
} }
BOOST_CATCH(...){ BOOST_CATCH(...){
deallocate_node(x); delete_node_(x);
--node_count; --node_count;
BOOST_RETHROW; BOOST_RETHROW;
} }