mirror of
https://github.com/boostorg/intrusive.git
synced 2025-08-03 22:44:43 +02:00
Changes for Boost.1.39
[SVN r51964]
This commit is contained in:
@@ -1280,7 +1280,9 @@ And they also can receive additional options:
|
||||
provides a bucket length that is not power of two.
|
||||
Default: `power_2_buckets<false>`.
|
||||
|
||||
* [*`cache_begin<bool Enabled>`]: Due to its internal structure, finding the first
|
||||
* [*`cache_begin<bool Enabled>`]:
|
||||
[*Note: this option is not compatible with `auto_unlink` hooks].
|
||||
Due to its internal structure, finding the first
|
||||
element of an unordered container (`begin()` operation) is
|
||||
amortized constant-time. It's possible to speed up `begin()` and other operations
|
||||
related to it (like `clear()`) if the container caches internally the position
|
||||
@@ -3701,6 +3703,13 @@ all the objects to be inserted in intrusive containers in containers like `std::
|
||||
|
||||
[section:release_notes Release Notes]
|
||||
|
||||
[section:release_notes_boost_1_39_00 Boost 1.39 Release]
|
||||
|
||||
* Optimized `list::merge` and `slist::merge`
|
||||
* `list::sort` and `slist::sort` are now stable.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:release_notes_boost_1_38_00 Boost 1.38 Release]
|
||||
|
||||
* New treap-based containers: treap, treap_set, treap_multiset.
|
||||
|
@@ -34,7 +34,7 @@ int main()
|
||||
typedef any_to_slist_hook < base_hook< any_base_hook<> > > BaseSlistOption;
|
||||
typedef slist<MyClass, BaseSlistOption> BaseSList;
|
||||
|
||||
//Define a member hook option that converts any_base_hook to a list hook
|
||||
//Define a member hook option that converts any_member_hook to a list hook
|
||||
typedef any_to_list_hook< member_hook
|
||||
< MyClass, any_member_hook<>, &MyClass::member_hook_> > MemberListOption;
|
||||
typedef list<MyClass, MemberListOption> MemberList;
|
||||
|
@@ -26,18 +26,18 @@ class ebo_functor_holder_impl
|
||||
ebo_functor_holder_impl()
|
||||
{}
|
||||
ebo_functor_holder_impl(const T& t)
|
||||
: t(t)
|
||||
: t_(t)
|
||||
{}
|
||||
template<class Arg1, class Arg2>
|
||||
ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2)
|
||||
: t(arg1, arg2)
|
||||
: t_(arg1, arg2)
|
||||
{}
|
||||
|
||||
T& get(){return t;}
|
||||
const T& get()const{return t;}
|
||||
T& get(){return t_;}
|
||||
const T& get()const{return t_;}
|
||||
|
||||
private:
|
||||
T t;
|
||||
T t_;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@@ -15,7 +15,8 @@
|
||||
#include <boost/intrusive/detail/config_begin.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
#if defined(BOOST_MSVC) || (defined (BOOST_WINDOWS) && defined(BOOST_INTEL))
|
||||
#if defined(BOOST_MSVC) || ((defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && defined(BOOST_INTEL))
|
||||
|
||||
#define BOOST_INTRUSIVE_MSVC_COMPLIANT_PTR_TO_MEMBER
|
||||
#include <boost/cstdint.hpp>
|
||||
#endif
|
||||
|
@@ -99,8 +99,8 @@ class tree_iterator
|
||||
: members_ (0, 0)
|
||||
{}
|
||||
|
||||
explicit tree_iterator(node_ptr node, const Container *cont_ptr)
|
||||
: members_ (node, cont_ptr)
|
||||
explicit tree_iterator(node_ptr nodeptr, const Container *cont_ptr)
|
||||
: members_ (nodeptr, cont_ptr)
|
||||
{}
|
||||
|
||||
tree_iterator(tree_iterator<Container, false> const& other)
|
||||
@@ -110,8 +110,8 @@ class tree_iterator
|
||||
const node_ptr &pointed_node() const
|
||||
{ return members_.nodeptr_; }
|
||||
|
||||
tree_iterator &operator=(const node_ptr &node)
|
||||
{ members_.nodeptr_ = node; return static_cast<tree_iterator&>(*this); }
|
||||
tree_iterator &operator=(const node_ptr &nodeptr)
|
||||
{ members_.nodeptr_ = nodeptr; return static_cast<tree_iterator&>(*this); }
|
||||
|
||||
public:
|
||||
tree_iterator& operator++()
|
||||
|
@@ -718,6 +718,8 @@ class hashtable_impl
|
||||
|
||||
//Constant-time size is incompatible with auto-unlink hooks!
|
||||
BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink)));
|
||||
//Cache begin is incompatible with auto-unlink hooks!
|
||||
BOOST_STATIC_ASSERT(!(cache_begin && ((int)real_value_traits::link_mode == (int)auto_unlink)));
|
||||
|
||||
template<class Disposer>
|
||||
node_cast_adaptor<detail::node_disposer<Disposer, hashtable_impl> >
|
||||
@@ -871,7 +873,7 @@ class hashtable_impl
|
||||
|
||||
//! <b>Effects</b>: Returns true if the container is empty.
|
||||
//!
|
||||
//! <b>Complexity</b>: if constant-time size and cache_last options are disabled,
|
||||
//! <b>Complexity</b>: if constant-time size and cache_begin options are disabled,
|
||||
//! average constant time (worst case, with empty() == true: O(this->bucket_count()).
|
||||
//! Otherwise constant.
|
||||
//!
|
||||
|
@@ -978,7 +978,8 @@ class list_impl
|
||||
carry.splice(carry.cbegin(), *this, this->cbegin());
|
||||
int i = 0;
|
||||
while(i < fill && !counter[i].empty()) {
|
||||
carry.merge(counter[i++], p);
|
||||
counter[i].merge(carry, p);
|
||||
carry.swap(counter[i++]);
|
||||
}
|
||||
carry.swap(counter[i]);
|
||||
if(i == fill)
|
||||
@@ -1021,21 +1022,26 @@ class list_impl
|
||||
template<class Predicate>
|
||||
void merge(list_impl& x, Predicate p)
|
||||
{
|
||||
const_iterator e(this->end());
|
||||
const_iterator bx(x.begin());
|
||||
const_iterator ex(x.end());
|
||||
|
||||
for (const_iterator b = this->cbegin(); b != e; ++b) {
|
||||
size_type n(0);
|
||||
const_iterator ix(bx);
|
||||
while(ix != ex && p(*ix, *b)){
|
||||
++ix; ++n;
|
||||
const_iterator e(this->cend()), ex(x.cend());
|
||||
const_iterator b(this->cbegin());
|
||||
while(!x.empty()){
|
||||
const_iterator ix(x.cbegin());
|
||||
while (b != e && !p(*ix, *b)){
|
||||
++b;
|
||||
}
|
||||
if(b == e){
|
||||
//Now transfer the rest to the end of the container
|
||||
this->splice(e, x);
|
||||
break;
|
||||
}
|
||||
else{
|
||||
size_type n(0);
|
||||
do{
|
||||
++ix; ++n;
|
||||
} while(ix != ex && p(*ix, *b));
|
||||
this->splice(b, x, x.begin(), ix, n);
|
||||
}
|
||||
this->splice(b, x, bx, ix, n);
|
||||
bx = ix;
|
||||
}
|
||||
//Now transfer the rest at the end of the container
|
||||
this->splice(e, x);
|
||||
}
|
||||
|
||||
//! <b>Effects</b>: Reverses the order of elements in the list.
|
||||
|
@@ -513,9 +513,9 @@ class rbtree_impl
|
||||
template<class Iterator>
|
||||
void insert_equal(Iterator b, Iterator e)
|
||||
{
|
||||
iterator end(this->end());
|
||||
iterator iend(this->end());
|
||||
for (; b != e; ++b)
|
||||
this->insert_equal(end, *b);
|
||||
this->insert_equal(iend, *b);
|
||||
}
|
||||
|
||||
//! <b>Requires</b>: value must be an lvalue
|
||||
@@ -579,9 +579,9 @@ class rbtree_impl
|
||||
void insert_unique(Iterator b, Iterator e)
|
||||
{
|
||||
if(this->empty()){
|
||||
iterator end(this->end());
|
||||
iterator iend(this->end());
|
||||
for (; b != e; ++b)
|
||||
this->insert_unique(end, *b);
|
||||
this->insert_unique(iend, *b);
|
||||
}
|
||||
else{
|
||||
for (; b != e; ++b)
|
||||
|
@@ -598,7 +598,7 @@ class slist_impl
|
||||
void swap(slist_impl& other)
|
||||
{
|
||||
if(cache_last){
|
||||
this->priv_swap_cache_last(other);
|
||||
priv_swap_cache_last(this, &other);
|
||||
}
|
||||
else{
|
||||
this->priv_swap_lists(this->get_root_node(), other.get_root_node(), detail::bool_<linear>());
|
||||
@@ -1264,6 +1264,7 @@ class slist_impl
|
||||
carry.splice_after(carry.cbefore_begin(), *this, this->cbefore_begin());
|
||||
int i = 0;
|
||||
while(i < fill && !counter[i].empty()) {
|
||||
carry.swap(counter[i]);
|
||||
last_inserted = carry.merge(counter[i++], p);
|
||||
}
|
||||
BOOST_INTRUSIVE_INVARIANT_ASSERT(counter[i].empty());
|
||||
@@ -1340,24 +1341,26 @@ class slist_impl
|
||||
template<class Predicate>
|
||||
iterator merge(slist_impl& x, Predicate p)
|
||||
{
|
||||
const_iterator a(cbefore_begin()), e(cend()), ax(x.cbefore_begin()), ex(x.cend());
|
||||
const_iterator last_inserted(e);
|
||||
const_iterator a_next;
|
||||
while(++(a_next = a) != e && !x.empty()) {
|
||||
const_iterator ix(ax);
|
||||
const_iterator cx;
|
||||
size_type n(0);
|
||||
while(++(cx = ix) != ex && p(*cx, *a_next)){
|
||||
++ix; ++n;
|
||||
const_iterator e(this->cend()), ex(x.cend()), bb(this->cbefore_begin()),
|
||||
bb_next, last_inserted(e);
|
||||
while(!x.empty()){
|
||||
const_iterator ibx_next(x.cbefore_begin()), ibx(ibx_next++);
|
||||
while (++(bb_next = bb) != e && !p(*ibx_next, *bb_next)){
|
||||
bb = bb_next;
|
||||
}
|
||||
if(ax != ix){
|
||||
this->splice_after(a, x, ax, ix, n);
|
||||
last_inserted = ix;
|
||||
if(bb_next == e){
|
||||
//Now transfer the rest to the end of the container
|
||||
last_inserted = this->splice_after(bb, x);
|
||||
break;
|
||||
}
|
||||
else{
|
||||
size_type n(0);
|
||||
do{
|
||||
ibx = ibx_next; ++n;
|
||||
} while(++(ibx_next = ibx) != ex && p(*ibx_next, *bb_next));
|
||||
this->splice_after(bb, x, x.before_begin(), ibx, n);
|
||||
last_inserted = ibx;
|
||||
}
|
||||
a = a_next;
|
||||
}
|
||||
if (!x.empty()){
|
||||
last_inserted = this->splice_after(a, x);
|
||||
}
|
||||
return last_inserted.unconst();
|
||||
}
|
||||
@@ -1711,22 +1714,40 @@ class slist_impl
|
||||
}
|
||||
}
|
||||
|
||||
void priv_swap_cache_last(slist_impl &other)
|
||||
static void priv_swap_cache_last(slist_impl *this_impl, slist_impl *other_impl)
|
||||
{
|
||||
node_ptr other_last(other.get_last_node());
|
||||
node_ptr this_last(this->get_last_node());
|
||||
node_ptr other_bfirst(other.get_root_node());
|
||||
node_ptr this_bfirst(this->get_root_node());
|
||||
node_algorithms::transfer_after(this_bfirst, other_bfirst, other_last);
|
||||
node_algorithms::transfer_after(other_bfirst, other_last != other_bfirst? other_last : this_bfirst, this_last);
|
||||
node_ptr tmp(this->get_last_node());
|
||||
this->set_last_node(other.get_last_node());
|
||||
other.set_last_node(tmp);
|
||||
if(this->get_last_node() == other_bfirst){
|
||||
this->set_last_node(this_bfirst);
|
||||
bool other_was_empty = false;
|
||||
if(this_impl->empty()){
|
||||
//Check if both are empty or
|
||||
if(other_impl->empty())
|
||||
return;
|
||||
//If this is empty swap pointers
|
||||
slist_impl *tmp = this_impl;
|
||||
this_impl = other_impl;
|
||||
other_impl = tmp;
|
||||
other_was_empty = true;
|
||||
}
|
||||
if(other.get_last_node() == this_bfirst){
|
||||
other.set_last_node(other_bfirst);
|
||||
else{
|
||||
other_was_empty = other_impl->empty();
|
||||
}
|
||||
|
||||
//Precondition: this is not empty
|
||||
node_ptr other_old_last(other_impl->get_last_node());
|
||||
node_ptr other_bfirst(other_impl->get_root_node());
|
||||
node_ptr this_bfirst(this_impl->get_root_node());
|
||||
node_ptr this_old_last(this_impl->get_last_node());
|
||||
|
||||
//Move all nodes from this to other's beginning
|
||||
node_algorithms::transfer_after(other_bfirst, this_bfirst, this_old_last);
|
||||
other_impl->set_last_node(this_old_last);
|
||||
|
||||
if(other_was_empty){
|
||||
this_impl->set_last_node(this_bfirst);
|
||||
}
|
||||
else{
|
||||
//Move trailing nodes from other to this
|
||||
node_algorithms::transfer_after(this_bfirst, this_old_last, other_old_last);
|
||||
this_impl->set_last_node(other_old_last);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
DisableLanguageExtensions="FALSE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
|
@@ -27,7 +27,7 @@
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
DisableLanguageExtensions="FALSE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
|
@@ -27,7 +27,7 @@
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
DisableLanguageExtensions="FALSE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
|
@@ -27,7 +27,7 @@
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
DisableLanguageExtensions="FALSE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
|
@@ -27,7 +27,7 @@
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
DisableLanguageExtensions="FALSE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
|
@@ -27,7 +27,7 @@
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
DisableLanguageExtensions="FALSE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
|
@@ -27,7 +27,7 @@
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
DisableLanguageExtensions="FALSE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
|
@@ -24,3 +24,5 @@
|
||||
-> revise strong exception safety concepts for treap::erase functions.
|
||||
What happens with range deletions?
|
||||
-> Assure stable order for optimize_multikey and inverse order otherwise
|
||||
-> linear slist's splice_after(..., slist &x) can be optimized if *this is empty
|
||||
-> optimize slist::merge like list::merge
|
||||
|
@@ -27,7 +27,7 @@
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
DisableLanguageExtensions="FALSE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
|
@@ -417,6 +417,28 @@ void test_slist<ValueTraits, Linear, CacheLast>
|
||||
{ int init_values [] = { 2 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
|
||||
}
|
||||
{ //Now test swap when testlist2 is empty
|
||||
list_type testlist1 (&values[0], &values[0] + 2);
|
||||
list_type testlist2;
|
||||
testlist1.swap(testlist2);
|
||||
BOOST_TEST (testlist1.empty());
|
||||
{ int init_values [] = { 1, 2 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
|
||||
}
|
||||
{ //Now test swap when testlist1 is empty
|
||||
list_type testlist2 (&values[0], &values[0] + 2);
|
||||
list_type testlist1;
|
||||
testlist1.swap(testlist2);
|
||||
BOOST_TEST (testlist2.empty());
|
||||
{ int init_values [] = { 1, 2 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
}
|
||||
{ //Now test when both are empty
|
||||
list_type testlist1, testlist2;
|
||||
testlist2.swap(testlist1);
|
||||
BOOST_TEST (testlist1.empty() && testlist2.empty());
|
||||
}
|
||||
|
||||
if(!list_type::linear)
|
||||
{
|
||||
list_type testlist1 (&values[0], &values[0] + 2);
|
||||
|
@@ -719,7 +719,6 @@ class test_main_template
|
||||
, false
|
||||
, Incremental
|
||||
>::test_all(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@@ -740,7 +739,7 @@ class test_main_template<VoidPointer, false, Incremental>
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::base_hook_type
|
||||
>::type
|
||||
, true
|
||||
, false
|
||||
, false
|
||||
, Incremental
|
||||
>::test_all(data);
|
||||
@@ -752,7 +751,7 @@ class test_main_template<VoidPointer, false, Incremental>
|
||||
, &value_type::node_
|
||||
>
|
||||
>::type
|
||||
, false
|
||||
, true
|
||||
, false
|
||||
, Incremental
|
||||
>::test_all(data);
|
||||
@@ -761,8 +760,8 @@ class test_main_template<VoidPointer, false, Incremental>
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
, true
|
||||
, true
|
||||
, false
|
||||
, false
|
||||
, Incremental
|
||||
>::test_all(data);
|
||||
|
||||
|
@@ -623,7 +623,7 @@ class test_main_template<VoidPointer, false, incremental>
|
||||
< value_type
|
||||
, typename hooks<VoidPointer>::auto_base_hook_type
|
||||
>::type
|
||||
, true
|
||||
, false
|
||||
, true
|
||||
, incremental
|
||||
>::test_all(data);
|
||||
|
Reference in New Issue
Block a user