mirror of
https://github.com/boostorg/multi_index.git
synced 2025-05-10 07:24:01 +00:00
re-engineered random_access_index::splice(position,x,first,last)
the same way as done with sequenced_index
This commit is contained in:
parent
1bd4450884
commit
cb6a581eda
@ -541,7 +541,7 @@ public:
|
|||||||
BOOST_MULTI_INDEX_CHECK_DIFFERENT_CONTAINER(
|
BOOST_MULTI_INDEX_CHECK_DIFFERENT_CONTAINER(
|
||||||
this->final(*this),this->final(x));
|
this->final(*this),this->final(x));
|
||||||
BOOST_MULTI_INDEX_RND_INDEX_CHECK_INVARIANT;
|
BOOST_MULTI_INDEX_RND_INDEX_CHECK_INVARIANT;
|
||||||
splice_impl(position,x,boost::is_copy_constructible<value_type>());
|
external_splice(position,x,boost::is_copy_constructible<value_type>());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Index>
|
template<typename Index>
|
||||||
@ -568,7 +568,8 @@ public:
|
|||||||
if(pn!=in)relocate(pn,in);
|
if(pn!=in)relocate(pn,in);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
splice_impl(position,x,i,boost::is_copy_constructible<value_type>());
|
external_splice(
|
||||||
|
position,x,i,boost::is_copy_constructible<value_type>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,27 +597,23 @@ public:
|
|||||||
BOOST_MULTI_INDEX_CHECK_IS_OWNER(last,x);
|
BOOST_MULTI_INDEX_CHECK_IS_OWNER(last,x);
|
||||||
BOOST_MULTI_INDEX_CHECK_VALID_RANGE(first,last);
|
BOOST_MULTI_INDEX_CHECK_VALID_RANGE(first,last);
|
||||||
BOOST_MULTI_INDEX_RND_INDEX_CHECK_INVARIANT;
|
BOOST_MULTI_INDEX_RND_INDEX_CHECK_INVARIANT;
|
||||||
splice_impl(
|
if(x.end().get_node()==this->header()){ /* same container */
|
||||||
|
BOOST_MULTI_INDEX_CHECK_OUTSIDE_RANGE(position,first,last);
|
||||||
|
internal_splice(position,first,last);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
external_splice(
|
||||||
position,x,first,last,boost::is_copy_constructible<value_type>());
|
position,x,first,last,boost::is_copy_constructible<value_type>());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void splice(
|
template<typename Index>
|
||||||
iterator position,random_access_index<SuperMeta,TagList>& x,
|
BOOST_MULTI_INDEX_ENABLE_IF_MERGEABLE(random_access_index,Index,void)
|
||||||
|
splice(
|
||||||
|
iterator position,BOOST_RV_REF(Index) x,
|
||||||
iterator first,iterator last)
|
iterator first,iterator last)
|
||||||
{
|
{
|
||||||
BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position);
|
splice(position,static_cast<Index&>(x),first,last);
|
||||||
BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this);
|
|
||||||
BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(first);
|
|
||||||
BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(last);
|
|
||||||
BOOST_MULTI_INDEX_CHECK_IS_OWNER(first,x);
|
|
||||||
BOOST_MULTI_INDEX_CHECK_IS_OWNER(last,x);
|
|
||||||
BOOST_MULTI_INDEX_CHECK_VALID_RANGE(first,last);
|
|
||||||
BOOST_MULTI_INDEX_RND_INDEX_CHECK_INVARIANT;
|
|
||||||
if(&x==this)relocate(position,first,last);
|
|
||||||
else{
|
|
||||||
splice_impl(
|
|
||||||
position,x,first,last,boost::is_copy_constructible<value_type>());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(value_param_type value)
|
void remove(value_param_type value)
|
||||||
@ -1104,11 +1101,11 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Index>
|
template<typename Index>
|
||||||
void splice_impl(
|
void external_splice(
|
||||||
iterator position,Index& x,boost::true_type /* copy-constructible value */)
|
iterator position,Index& x,boost::true_type /* copy-constructible value */)
|
||||||
{
|
{
|
||||||
if(get_allocator()==x.get_allocator()){
|
if(get_allocator()==x.get_allocator()){
|
||||||
splice_impl(position,x,boost::false_type());
|
external_splice(position,x,boost::false_type());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
/* backwards compatibility with old, non-transfer-based splice */
|
/* backwards compatibility with old, non-transfer-based splice */
|
||||||
@ -1131,7 +1128,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Index>
|
template<typename Index>
|
||||||
void splice_impl(
|
void external_splice(
|
||||||
iterator position,Index& x,
|
iterator position,Index& x,
|
||||||
boost::false_type /* copy-constructible value */)
|
boost::false_type /* copy-constructible value */)
|
||||||
{
|
{
|
||||||
@ -1148,12 +1145,12 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Index>
|
template<typename Index>
|
||||||
void splice_impl(
|
void external_splice(
|
||||||
iterator position,Index& x,BOOST_DEDUCED_TYPENAME Index::iterator i,
|
iterator position,Index& x,BOOST_DEDUCED_TYPENAME Index::iterator i,
|
||||||
boost::true_type /* copy-constructible value */)
|
boost::true_type /* copy-constructible value */)
|
||||||
{
|
{
|
||||||
if(get_allocator()==x.get_allocator()){
|
if(get_allocator()==x.get_allocator()){
|
||||||
splice_impl(position,x,i,boost::false_type());
|
external_splice(position,x,i,boost::false_type());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
/* backwards compatibility with old, non-transfer-based splice */
|
/* backwards compatibility with old, non-transfer-based splice */
|
||||||
@ -1176,7 +1173,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Index>
|
template<typename Index>
|
||||||
void splice_impl(
|
void external_splice(
|
||||||
iterator position,Index& x,BOOST_DEDUCED_TYPENAME Index::iterator i,
|
iterator position,Index& x,BOOST_DEDUCED_TYPENAME Index::iterator i,
|
||||||
boost::false_type /* copy-constructible value */)
|
boost::false_type /* copy-constructible value */)
|
||||||
{
|
{
|
||||||
@ -1188,15 +1185,32 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Iterator>
|
||||||
|
void internal_splice(iterator position,Iterator first,Iterator last)
|
||||||
|
{
|
||||||
|
index_node_type* pn=position.get_node();
|
||||||
|
while(first!=last){
|
||||||
|
relocate(pn,static_cast<index_node_type*>((first++).get_node()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void internal_splice(iterator position,iterator first,iterator last)
|
||||||
|
{
|
||||||
|
index_node_type* pn=position.get_node();
|
||||||
|
index_node_type* fn=static_cast<index_node_type*>(first.get_node());
|
||||||
|
index_node_type* ln=static_cast<index_node_type*>(last.get_node());
|
||||||
|
if(pn!=ln)relocate(pn,fn,ln);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Index>
|
template<typename Index>
|
||||||
void splice_impl(
|
void external_splice(
|
||||||
iterator position,Index& x,
|
iterator position,Index& x,
|
||||||
BOOST_DEDUCED_TYPENAME Index::iterator first,
|
BOOST_DEDUCED_TYPENAME Index::iterator first,
|
||||||
BOOST_DEDUCED_TYPENAME Index::iterator last,
|
BOOST_DEDUCED_TYPENAME Index::iterator last,
|
||||||
boost::true_type /* copy-constructible value */)
|
boost::true_type /* copy-constructible value */)
|
||||||
{
|
{
|
||||||
if(get_allocator()==x.get_allocator()){
|
if(get_allocator()==x.get_allocator()){
|
||||||
splice_impl(position,x,first,last,boost::false_type());
|
external_splice(position,x,first,last,boost::false_type());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
/* backwards compatibility with old, non-transfer-based splice */
|
/* backwards compatibility with old, non-transfer-based splice */
|
||||||
@ -1218,7 +1232,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Index>
|
template<typename Index>
|
||||||
void splice_impl(
|
void external_splice(
|
||||||
iterator position,Index& x,
|
iterator position,Index& x,
|
||||||
BOOST_DEDUCED_TYPENAME Index::iterator first,
|
BOOST_DEDUCED_TYPENAME Index::iterator first,
|
||||||
BOOST_DEDUCED_TYPENAME Index::iterator last,
|
BOOST_DEDUCED_TYPENAME Index::iterator last,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user