forked from boostorg/intrusive
#1912: some copy edits on boost.intrusive
#1932: move semantics for shared objects #1635: Incomplete include guard in boost/intrusive [SVN r45696]
This commit is contained in:
@@ -391,7 +391,11 @@ struct link_dispatch
|
||||
|
||||
template<class Hook>
|
||||
void destructor_impl(Hook &hook, detail::link_dispatch<safe_link>)
|
||||
{ (void)hook; BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT(!hook.is_linked()); }
|
||||
{ //If this assertion raises, you might have destroyed an object
|
||||
//while it was still inserted in a container that is alive.
|
||||
//If so, remove the object from the container before destroying it.
|
||||
(void)hook; BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT(!hook.is_linked());
|
||||
}
|
||||
|
||||
template<class Hook>
|
||||
void destructor_impl(Hook &hook, detail::link_dispatch<auto_unlink>)
|
||||
|
@@ -343,7 +343,7 @@ struct uset_defaults
|
||||
//! is used to construct intrusive unordered_set and unordered_multiset containers. The
|
||||
//! no-throw guarantee holds only, if the Equal object and Hasher don't throw.
|
||||
//!
|
||||
//! hashtable is a pseudo-intrusive container: each object to be stored in the
|
||||
//! hashtable is a semi-intrusive container: each object to be stored in the
|
||||
//! container must contain a proper hook, but the container also needs
|
||||
//! additional auxiliary memory to work: hashtable needs a pointer to an array
|
||||
//! of type `bucket_type` to be passed in the constructor. This bucket array must
|
||||
|
@@ -586,7 +586,7 @@ class list_impl
|
||||
iterator erase(iterator i)
|
||||
{ return this->erase_and_dispose(i, detail::null_disposer()); }
|
||||
|
||||
//! <b>Requires</b>: first and last must be valid iterator to elements in *this.
|
||||
//! <b>Requires</b>: b and e must be valid iterators to elements in *this.
|
||||
//!
|
||||
//! <b>Effects</b>: Erases the element range pointed by b and e
|
||||
//! No destructors are called.
|
||||
@@ -596,8 +596,8 @@ class list_impl
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements erased if it's a safe-mode
|
||||
//! or auto-unlink value. Constant time otherwise.
|
||||
//! <b>Complexity</b>: Linear to the number of erased elements if it's a safe-mode
|
||||
//! or auto-unlink value, or constant-time size is enabled. Constant-time otherwise.
|
||||
//!
|
||||
//! <b>Note</b>: Invalidates the iterators (but not the references) to the
|
||||
//! erased elements.
|
||||
@@ -612,6 +612,37 @@ class list_impl
|
||||
}
|
||||
}
|
||||
|
||||
//! <b>Requires</b>: b and e must be valid iterators to elements in *this.
|
||||
//! n must be std::distance(b, e).
|
||||
//!
|
||||
//! <b>Effects</b>: Erases the element range pointed by b and e
|
||||
//! No destructors are called.
|
||||
//!
|
||||
//! <b>Returns</b>: the first element remaining beyond the removed elements,
|
||||
//! or end() if no such element exists.
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of erased elements if it's a safe-mode
|
||||
//! or auto-unlink value is enabled. Constant-time otherwise.
|
||||
//!
|
||||
//! <b>Note</b>: Invalidates the iterators (but not the references) to the
|
||||
//! erased elements.
|
||||
iterator erase(iterator b, iterator e, difference_type n)
|
||||
{
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(b, e) == difference_type(n));
|
||||
if(safemode_or_autounlink || constant_time_size){
|
||||
return this->erase_and_dispose(b, e, detail::null_disposer());
|
||||
}
|
||||
else{
|
||||
if(constant_time_size){
|
||||
this->priv_size_traits().set_size(this->priv_size_traits().get_size() - n);
|
||||
}
|
||||
node_algorithms::unlink(b.pointed_node(), e.pointed_node());
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
|
||||
//!
|
||||
//! <b>Effects</b>: Erases the element pointed by i of the list.
|
||||
|
@@ -778,12 +778,64 @@ class slist_impl
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: Lineal to the elements (last - before_first + 1).
|
||||
//! <b>Complexity</b>: Linear to the number of erased elements if it's a safe-mode
|
||||
//! , auto-unlink value or constant-time size is activated. Constant time otherwise.
|
||||
//!
|
||||
//! <b>Note</b>: Invalidates the iterators (but not the references) to the
|
||||
//! erased element.
|
||||
iterator erase_after(iterator before_first, iterator last)
|
||||
{ return this->erase_after_and_dispose(before_first, last, detail::null_disposer()); }
|
||||
{
|
||||
if(safemode_or_autounlink || constant_time_size){
|
||||
return this->erase_after_and_dispose(before_first, last, detail::null_disposer());
|
||||
}
|
||||
else{
|
||||
node_ptr bfp = before_first.pointed_node();
|
||||
node_ptr lp = last.pointed_node();
|
||||
if(cache_last){
|
||||
if((lp == this->get_end_node())){
|
||||
this->set_last_node(bfp);
|
||||
}
|
||||
}
|
||||
node_algorithms::unlink_after(bfp, lp);
|
||||
return last;
|
||||
}
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Erases the range (before_first, last) from
|
||||
//! the list. n must be std::distance(before_first, last) - 1.
|
||||
//! No destructors are called.
|
||||
//!
|
||||
//! <b>Returns</b>: the first element remaining beyond the removed elements,
|
||||
//! or end() if no such element exists.
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: constant-time if link_mode is normal_link.
|
||||
//! Linear to the elements (last - before_first) otherwise.
|
||||
//!
|
||||
//! <b>Note</b>: Invalidates the iterators (but not the references) to the
|
||||
//! erased element.
|
||||
iterator erase_after(iterator before_first, iterator last, difference_type n)
|
||||
{
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(++iterator(before_first), last) == difference_type(n));
|
||||
if(safemode_or_autounlink){
|
||||
return this->erase_after(before_first, last);
|
||||
}
|
||||
else{
|
||||
node_ptr bfp = before_first.pointed_node();
|
||||
node_ptr lp = last.pointed_node();
|
||||
if(cache_last){
|
||||
if((lp == this->get_end_node())){
|
||||
this->set_last_node(bfp);
|
||||
}
|
||||
}
|
||||
node_algorithms::unlink_after(bfp, lp);
|
||||
if(constant_time_size){
|
||||
this->priv_size_traits().set_size(this->priv_size_traits().get_size() - n);
|
||||
}
|
||||
return last;
|
||||
}
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Erases the element pointed by i of the list.
|
||||
//! No destructors are called.
|
||||
@@ -810,14 +862,30 @@ class slist_impl
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements erased plus linear
|
||||
//! to the elements before first.
|
||||
//! <b>Complexity</b>: Linear to the elements before last.
|
||||
//!
|
||||
//! <b>Note</b>: Invalidates the iterators (but not the references) to the
|
||||
//! erased elements.
|
||||
iterator erase(iterator first, iterator last)
|
||||
{ return this->erase_after(this->previous(first), last); }
|
||||
|
||||
//! <b>Effects</b>: Erases the range [first, last) from
|
||||
//! the list. n must be std::distance(first, last).
|
||||
//! No destructors are called.
|
||||
//!
|
||||
//! <b>Returns</b>: the first element remaining beyond the removed elements,
|
||||
//! or end() if no such element exists.
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: linear to the elements before first if link_mode is normal_link
|
||||
//! and constant_time_size is activated. Linear to the elements before last otherwise.
|
||||
//!
|
||||
//! <b>Note</b>: Invalidates the iterators (but not the references) to the
|
||||
//! erased element.
|
||||
iterator erase(iterator first, iterator last, difference_type n)
|
||||
{ return this->erase_after(this->previous(first), last, n); }
|
||||
|
||||
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
|
||||
//!
|
||||
//! <b>Effects</b>: Erases the element after the element pointed by prev of
|
||||
@@ -885,7 +953,7 @@ class slist_impl
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: Lineal to the elements (last - before_first).
|
||||
//! <b>Complexity</b>: Lineal to the elements (last - before_first + 1).
|
||||
//!
|
||||
//! <b>Note</b>: Invalidates the iterators to the erased element.
|
||||
template<class Disposer>
|
||||
@@ -939,7 +1007,7 @@ class slist_impl
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements erased plus linear
|
||||
//! <b>Complexity</b>: Linear to the number of erased elements plus linear
|
||||
//! to the elements before first.
|
||||
//!
|
||||
//! <b>Note</b>: Invalidates the iterators (but not the references) to the
|
||||
@@ -1047,10 +1115,7 @@ class slist_impl
|
||||
void splice_after(iterator prev_pos, slist_impl &x, iterator prev_ele)
|
||||
{
|
||||
iterator elem = prev_ele;
|
||||
++elem;
|
||||
if (elem != prev_pos && prev_ele != prev_pos){
|
||||
this->splice_after(prev_pos, x, prev_ele, elem, 1);
|
||||
}
|
||||
this->splice_after(prev_pos, x, prev_ele, ++elem, 1);
|
||||
}
|
||||
|
||||
//! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be
|
||||
@@ -1587,6 +1652,8 @@ class slist_impl
|
||||
|
||||
private:
|
||||
void priv_splice_after(node_ptr prev_pos_n, slist_impl &x, node_ptr before_first_n, node_ptr before_last_n)
|
||||
{
|
||||
if (before_first_n != before_last_n && prev_pos_n != before_first_n && prev_pos_n != before_last_n)
|
||||
{
|
||||
if(cache_last){
|
||||
if(node_traits::get_next(prev_pos_n) == this->get_end_node()){
|
||||
@@ -1598,6 +1665,7 @@ class slist_impl
|
||||
}
|
||||
node_algorithms::transfer_after(prev_pos_n, before_first_n, before_last_n);
|
||||
}
|
||||
}
|
||||
|
||||
void priv_reverse(detail::bool_<false>)
|
||||
{ node_algorithms::reverse(this->get_root_node()); }
|
||||
|
@@ -24,7 +24,7 @@ namespace intrusive {
|
||||
//! The class template unordered_set is an intrusive container, that mimics most of
|
||||
//! the interface of std::tr1::unordered_set as described in the C++ TR1.
|
||||
//!
|
||||
//! unordered_set is a pseudo-intrusive container: each object to be stored in the
|
||||
//! unordered_set is a semi-intrusive container: each object to be stored in the
|
||||
//! container must contain a proper hook, but the container also needs
|
||||
//! additional auxiliary memory to work: unordered_set needs a pointer to an array
|
||||
//! of type `bucket_type` to be passed in the constructor. This bucket array must
|
||||
@@ -1019,7 +1019,7 @@ class unordered_set
|
||||
//! The class template unordered_multiset is an intrusive container, that mimics most of
|
||||
//! the interface of std::tr1::unordered_multiset as described in the C++ TR1.
|
||||
//!
|
||||
//! unordered_multiset is a pseudo-intrusive container: each object to be stored in the
|
||||
//! unordered_multiset is a semi-intrusive container: each object to be stored in the
|
||||
//! container must contain a proper hook, but the container also needs
|
||||
//! additional auxiliary memory to work: unordered_multiset needs a pointer to an array
|
||||
//! of type `bucket_type` to be passed in the constructor. This bucket array must
|
||||
|
Reference in New Issue
Block a user