* Fixed GCC -Wshadow warnings.

*  Added missing `explicit` keyword in several intrusive container constructors.
*  Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros.

[SVN r81516]
This commit is contained in:
Ion Gaztañaga
2012-11-24 21:05:58 +00:00
parent 50caf8e34f
commit 9847a9f626
16 changed files with 383 additions and 313 deletions

View File

@@ -86,8 +86,8 @@ class avl_set_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor of the value_compare object throws. //! or the copy constructor of the value_compare object throws.
avl_set_impl( const value_compare &cmp = value_compare() explicit avl_set_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: tree_(cmp, v_traits) : tree_(cmp, v_traits)
{} {}
@@ -1381,8 +1381,8 @@ class avl_multiset_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor/operator() of the value_compare object throws. //! or the copy constructor/operator() of the value_compare object throws.
avl_multiset_impl( const value_compare &cmp = value_compare() explicit avl_multiset_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: tree_(cmp, v_traits) : tree_(cmp, v_traits)
{} {}

View File

@@ -219,8 +219,8 @@ class avltree_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor of the value_compare object throws. Basic guarantee. //! or the copy constructor of the value_compare object throws. Basic guarantee.
avltree_impl( const value_compare &cmp = value_compare() explicit avltree_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: data_(cmp, v_traits) : data_(cmp, v_traits)
{ {
node_algorithms::init_header(this->priv_header_ptr()); node_algorithms::init_header(this->priv_header_ptr());
@@ -542,9 +542,9 @@ class avltree_impl
template<class Iterator> template<class Iterator>
void insert_equal(Iterator b, Iterator e) void insert_equal(Iterator b, Iterator e)
{ {
iterator end_(this->end()); iterator iend(this->end());
for (; b != e; ++b) for (; b != e; ++b)
this->insert_equal(end_, *b); this->insert_equal(iend, *b);
} }
//! <b>Requires</b>: value must be an lvalue //! <b>Requires</b>: value must be an lvalue
@@ -608,9 +608,9 @@ class avltree_impl
void insert_unique(Iterator b, Iterator e) void insert_unique(Iterator b, Iterator e)
{ {
if(this->empty()){ if(this->empty()){
iterator end_(this->end()); iterator iend(this->end());
for (; b != e; ++b) for (; b != e; ++b)
this->insert_unique(end_, *b); this->insert_unique(iend, *b);
} }
else{ else{
for (; b != e; ++b) for (; b != e; ++b)
@@ -1249,7 +1249,7 @@ class avltree_impl
//! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
//! ordering compatible with the strict weak ordering used to create the //! ordering compatible with the strict weak ordering used to create the
//! the tree. //! the tree.
//! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
//! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
//! //!
@@ -1298,7 +1298,7 @@ class avltree_impl
//! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
//! ordering compatible with the strict weak ordering used to create the //! ordering compatible with the strict weak ordering used to create the
//! the tree. //! the tree.
//! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
//! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
//! //!

View File

@@ -174,7 +174,7 @@ class circular_list_algorithms
NodeTraits::set_previous(this_node, prev); NodeTraits::set_previous(this_node, prev);
NodeTraits::set_next(this_node, nxt_node); NodeTraits::set_next(this_node, nxt_node);
//nxt_node might be an alias for prev->next_ //nxt_node might be an alias for prev->next_
//so use it before update it before NodeTraits::set_next(prev, ...) //so use it before NodeTraits::set_next(prev, ...)
//is called and the reference changes it's value //is called and the reference changes it's value
NodeTraits::set_previous(nxt_node, this_node); NodeTraits::set_previous(nxt_node, this_node);
NodeTraits::set_next(prev, this_node); NodeTraits::set_next(prev, this_node);

View File

@@ -1020,7 +1020,7 @@ class tree_algorithms
if(hint == header || comp(key, hint)){ if(hint == header || comp(key, hint)){
node_ptr prev(hint); node_ptr prev(hint);
//Previous value should be less than the key //Previous value should be less than the key
if(hint == begin_node(header)|| comp((prev = prev_node(hint)), key)){ if(hint == begin_node(header) || comp((prev = prev_node(hint)), key)){
commit_data.link_left = unique(header) || !NodeTraits::get_left(hint); commit_data.link_left = unique(header) || !NodeTraits::get_left(hint);
commit_data.node = commit_data.link_left ? hint : prev; commit_data.node = commit_data.link_left ? hint : prev;
if(pdepth){ if(pdepth){

View File

@@ -424,20 +424,20 @@ struct group_functions
{ {
node_ptr nxt_ptr(node_traits::get_next(to_erase_ptr)); node_ptr nxt_ptr(node_traits::get_next(to_erase_ptr));
node_ptr prev_in_group_ptr(group_traits::get_next(to_erase_ptr)); node_ptr prev_in_group_ptr(group_traits::get_next(to_erase_ptr));
bool last_in_group_bool = (end_ptr == nxt_ptr) || bool last_in_group = (end_ptr == nxt_ptr) ||
(group_traits::get_next(nxt_ptr) != to_erase_ptr); (group_traits::get_next(nxt_ptr) != to_erase_ptr);
bool first_in_group_bool = node_traits::get_next(prev_in_group_ptr) != to_erase_ptr; bool is_first_in_group = node_traits::get_next(prev_in_group_ptr) != to_erase_ptr;
if(first_in_group_bool && last_in_group_bool){ if(is_first_in_group && last_in_group){
group_algorithms::init(to_erase_ptr); group_algorithms::init(to_erase_ptr);
} }
else if(first_in_group_bool){ else if(is_first_in_group){
group_algorithms::unlink_after(nxt_ptr); group_algorithms::unlink_after(nxt_ptr);
} }
else if(last_in_group_bool){ else if(last_in_group){
node_ptr first_in_group_ptr = node_ptr first_in_group =
get_first_in_group_of_last_in_group(to_erase_ptr); get_first_in_group_of_last_in_group(to_erase_ptr);
group_algorithms::unlink_after(first_in_group_ptr); group_algorithms::unlink_after(first_in_group);
} }
else{ else{
group_algorithms::unlink_after(nxt_ptr); group_algorithms::unlink_after(nxt_ptr);
@@ -888,20 +888,20 @@ class hashtable_impl
//! //!
//! <b>Notes</b>: buckets array must be disposed only after //! <b>Notes</b>: buckets array must be disposed only after
//! *this is disposed. //! *this is disposed.
hashtable_impl ( const bucket_traits &b_traits explicit hashtable_impl ( const bucket_traits &b_traits
, const hasher & hash_func = hasher() , const hasher & hash_func = hasher()
, const key_equal &equal_func = key_equal() , const key_equal &equal_func = key_equal()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: data_(b_traits, hash_func, equal_func, v_traits) : data_(b_traits, hash_func, equal_func, v_traits)
{ {
this->priv_initialize_buckets(); this->priv_initialize_buckets();
this->priv_size_traits().set_size(size_type(0)); this->priv_size_traits().set_size(size_type(0));
size_type bucket_size_ = this->priv_bucket_count(); size_type bucket_sz = this->priv_bucket_count();
BOOST_INTRUSIVE_INVARIANT_ASSERT(bucket_size_ != 0); BOOST_INTRUSIVE_INVARIANT_ASSERT(bucket_sz != 0);
//Check power of two bucket array if the option is activated //Check power of two bucket array if the option is activated
BOOST_INTRUSIVE_INVARIANT_ASSERT BOOST_INTRUSIVE_INVARIANT_ASSERT
(!power_2_buckets || (0 == (bucket_size_ & (bucket_size_-1)))); (!power_2_buckets || (0 == (bucket_sz & (bucket_sz-1))));
this->priv_split_traits().set_size(bucket_size_>>1); this->priv_split_traits().set_size(bucket_sz>>1);
} }
//! <b>Effects</b>: to-do //! <b>Effects</b>: to-do
@@ -1026,9 +1026,9 @@ class hashtable_impl
return this->begin() == this->end(); return this->begin() == this->end();
} }
else{ else{
size_type bucket_count_ = this->priv_bucket_count(); size_type bucket_cnt = this->priv_bucket_count();
const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_bucket_pointer()); const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_bucket_pointer());
for (size_type n = 0; n < bucket_count_; ++n, ++b){ for (size_type n = 0; n < bucket_cnt; ++n, ++b){
if(!b->empty()){ if(!b->empty()){
return false; return false;
} }
@@ -1049,9 +1049,9 @@ class hashtable_impl
return this->priv_size_traits().get_size(); return this->priv_size_traits().get_size();
else{ else{
size_type len = 0; size_type len = 0;
size_type bucket_count_ = this->priv_bucket_count(); size_type bucket_cnt = this->priv_bucket_count();
const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_bucket_pointer()); const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_bucket_pointer());
for (size_type n = 0; n < bucket_count_; ++n, ++b){ for (size_type n = 0; n < bucket_cnt; ++n, ++b){
len += b->size(); len += b->size();
} }
return len; return len;
@@ -1468,9 +1468,9 @@ class hashtable_impl
siterator first_local_it(b.slist_it()); siterator first_local_it(b.slist_it());
size_type first_bucket_num = this->priv_get_bucket_num(first_local_it); size_type first_bucket_num = this->priv_get_bucket_num(first_local_it);
const bucket_ptr bucket_pointer_ = this->priv_bucket_pointer(); const bucket_ptr buck_ptr = this->priv_bucket_pointer();
siterator before_first_local_it siterator before_first_local_it
= this->priv_get_previous(bucket_pointer_[first_bucket_num], first_local_it); = this->priv_get_previous(buck_ptr[first_bucket_num], first_local_it);
size_type last_bucket_num; size_type last_bucket_num;
siterator last_local_it; siterator last_local_it;
@@ -1478,7 +1478,7 @@ class hashtable_impl
//of the last bucket //of the last bucket
if(e == this->end()){ if(e == this->end()){
last_bucket_num = this->bucket_count() - 1; last_bucket_num = this->bucket_count() - 1;
last_local_it = bucket_pointer_[last_bucket_num].end(); last_local_it = buck_ptr[last_bucket_num].end();
} }
else{ else{
last_local_it = e.slist_it(); last_local_it = e.slist_it();
@@ -1533,7 +1533,7 @@ class hashtable_impl
siterator it = siterator it =
this->priv_find(key, hash_func, equal_func, bucket_num, h, prev); this->priv_find(key, hash_func, equal_func, bucket_num, h, prev);
bool success = it != this->priv_invalid_local_it(); bool success = it != this->priv_invalid_local_it();
size_type count_(0); size_type cnt(0);
if(!success){ if(!success){
return 0; return 0;
} }
@@ -1541,12 +1541,12 @@ class hashtable_impl
siterator last = bucket_type::s_iterator_to siterator last = bucket_type::s_iterator_to
(*node_traits::get_next(group_functions_t::get_last_in_group (*node_traits::get_next(group_functions_t::get_last_in_group
(hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()))); (hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())));
this->priv_erase_range_impl(bucket_num, prev, last, disposer, count_); this->priv_erase_range_impl(bucket_num, prev, last, disposer, cnt);
} }
else{ else{
//If found erase all equal values //If found erase all equal values
bucket_type &b = this->priv_bucket_pointer()[bucket_num]; bucket_type &b = this->priv_bucket_pointer()[bucket_num];
for(siterator end_ = b.end(); it != end_; ++count_, ++it){ for(siterator end_sit = b.end(); it != end_sit; ++cnt, ++it){
slist_node_ptr n(it.pointed_node()); slist_node_ptr n(it.pointed_node());
const value_type &v = this->priv_value_from_slist_node(n); const value_type &v = this->priv_value_from_slist_node(n);
if(compare_hash){ if(compare_hash){
@@ -1563,7 +1563,7 @@ class hashtable_impl
b.erase_after_and_dispose(prev, it, make_node_disposer(disposer)); b.erase_after_and_dispose(prev, it, make_node_disposer(disposer));
} }
this->priv_erasure_update_cache(); this->priv_erasure_update_cache();
return count_; return cnt;
} }
//! <b>Effects</b>: Erases all of the elements. //! <b>Effects</b>: Erases all of the elements.
@@ -1630,9 +1630,9 @@ class hashtable_impl
template<class KeyType, class KeyHasher, class KeyValueEqual> template<class KeyType, class KeyHasher, class KeyValueEqual>
size_type count(const KeyType &key, const KeyHasher &hash_func, const KeyValueEqual &equal_func) const size_type count(const KeyType &key, const KeyHasher &hash_func, const KeyValueEqual &equal_func) const
{ {
size_type bucket_n1, bucket_n2, count_; size_type bucket_n1, bucket_n2, cnt;
this->priv_equal_range(key, hash_func, equal_func, bucket_n1, bucket_n2, count_); this->priv_equal_range(key, hash_func, equal_func, bucket_n1, bucket_n2, cnt);
return count_; return cnt;
} }
//! <b>Effects</b>: Finds an iterator to the first element is equal to //! <b>Effects</b>: Finds an iterator to the first element is equal to
@@ -1746,9 +1746,9 @@ class hashtable_impl
std::pair<iterator,iterator> equal_range std::pair<iterator,iterator> equal_range
(const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) (const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func)
{ {
size_type bucket_n1, bucket_n2, count_; size_type bucket_n1, bucket_n2, cnt;
std::pair<siterator, siterator> ret = this->priv_equal_range std::pair<siterator, siterator> ret = this->priv_equal_range
(key, hash_func, equal_func, bucket_n1, bucket_n2, count_); (key, hash_func, equal_func, bucket_n1, bucket_n2, cnt);
return std::pair<iterator, iterator> return std::pair<iterator, iterator>
(iterator(ret.first, this), iterator(ret.second, this)); (iterator(ret.first, this), iterator(ret.second, this));
} }
@@ -1788,9 +1788,9 @@ class hashtable_impl
std::pair<const_iterator,const_iterator> equal_range std::pair<const_iterator,const_iterator> equal_range
(const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) const (const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) const
{ {
size_type bucket_n1, bucket_n2, count_; size_type bucket_n1, bucket_n2, cnt;
std::pair<siterator, siterator> ret = std::pair<siterator, siterator> ret =
this->priv_equal_range(key, hash_func, equal_func, bucket_n1, bucket_n2, count_); this->priv_equal_range(key, hash_func, equal_func, bucket_n1, bucket_n2, cnt);
return std::pair<const_iterator, const_iterator> return std::pair<const_iterator, const_iterator>
(const_iterator(ret.first, this), const_iterator(ret.second, this)); (const_iterator(ret.first, this), const_iterator(ret.second, this));
} }
@@ -2102,9 +2102,9 @@ class hashtable_impl
if(!fast_shrink){ if(!fast_shrink){
siterator before_i(old_bucket.before_begin()); siterator before_i(old_bucket.before_begin());
siterator end_(old_bucket.end()); siterator end_sit(old_bucket.end());
siterator i(old_bucket.begin()); siterator i(old_bucket.begin());
for(;i != end_; ++i){ for(;i != end_sit; ++i){
const value_type &v = this->priv_value_from_slist_node(i.pointed_node()); const value_type &v = this->priv_value_from_slist_node(i.pointed_node());
const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t()); const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t());
const size_type new_n = this->priv_hash_to_bucket(hash_value, new_bucket_count, new_bucket_count); const size_type new_n = this->priv_hash_to_bucket(hash_value, new_bucket_count, new_bucket_count);
@@ -2159,19 +2159,19 @@ class hashtable_impl
{ {
//This function is only available for containers with incremental hashing //This function is only available for containers with incremental hashing
BOOST_STATIC_ASSERT(( incremental && power_2_buckets )); BOOST_STATIC_ASSERT(( incremental && power_2_buckets ));
const size_type split_idx = this->priv_split_traits().get_size(); const size_type split_idx = this->priv_split_traits().get_size();
const size_type bucket_count_ = this->priv_bucket_count(); const size_type bucket_cnt = this->priv_bucket_count();
const bucket_ptr bucket_pointer_ = this->priv_bucket_pointer(); const bucket_ptr buck_ptr = this->priv_bucket_pointer();
if(grow){ if(grow){
//Test if the split variable can be changed //Test if the split variable can be changed
if(split_idx >= bucket_count_) if(split_idx >= bucket_cnt)
return false; return false;
const size_type bucket_to_rehash = split_idx - bucket_count_/2; const size_type bucket_to_rehash = split_idx - bucket_cnt/2;
bucket_type &old_bucket = bucket_pointer_[bucket_to_rehash]; bucket_type &old_bucket = buck_ptr[bucket_to_rehash];
siterator before_i(old_bucket.before_begin()); siterator before_i(old_bucket.before_begin());
const siterator end_(old_bucket.end()); const siterator end_sit(old_bucket.end());
siterator i(old_bucket.begin()); siterator i(old_bucket.begin());
this->priv_split_traits().increment(); this->priv_split_traits().increment();
@@ -2179,8 +2179,8 @@ class hashtable_impl
//moving elements from old_bucket to the target bucket, all moved //moving elements from old_bucket to the target bucket, all moved
//elements are moved back to the original one. //elements are moved back to the original one.
detail::incremental_rehash_rollback<bucket_type, split_traits> rollback detail::incremental_rehash_rollback<bucket_type, split_traits> rollback
( bucket_pointer_[split_idx], old_bucket, this->priv_split_traits()); ( buck_ptr[split_idx], old_bucket, this->priv_split_traits());
for(;i != end_; ++i){ for(;i != end_sit; ++i){
const value_type &v = this->priv_value_from_slist_node(i.pointed_node()); const value_type &v = this->priv_value_from_slist_node(i.pointed_node());
const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t()); const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t());
const size_type new_n = this->priv_hash_to_bucket(hash_value); const size_type new_n = this->priv_hash_to_bucket(hash_value);
@@ -2191,7 +2191,7 @@ class hashtable_impl
before_i = last; before_i = last;
} }
else{ else{
bucket_type &new_b = bucket_pointer_[new_n]; bucket_type &new_b = buck_ptr[new_n];
new_b.splice_after(new_b.before_begin(), old_bucket, before_i, last); new_b.splice_after(new_b.before_begin(), old_bucket, before_i, last);
} }
i = before_i; i = before_i;
@@ -2202,11 +2202,11 @@ class hashtable_impl
} }
else{ else{
//Test if the split variable can be changed //Test if the split variable can be changed
if(split_idx <= bucket_count_/2) if(split_idx <= bucket_cnt/2)
return false; return false;
const size_type target_bucket_num = split_idx - 1 - bucket_count_/2; const size_type target_bucket_num = split_idx - 1 - bucket_cnt/2;
bucket_type &target_bucket = bucket_pointer_[target_bucket_num]; bucket_type &target_bucket = buck_ptr[target_bucket_num];
bucket_type &source_bucket = bucket_pointer_[split_idx-1]; bucket_type &source_bucket = buck_ptr[split_idx-1];
target_bucket.splice_after(target_bucket.cbefore_begin(), source_bucket); target_bucket.splice_after(target_bucket.cbefore_begin(), source_bucket);
this->priv_split_traits().decrement(); this->priv_split_traits().decrement();
this->priv_insertion_update_cache(target_bucket_num); this->priv_insertion_update_cache(target_bucket_num);
@@ -2324,20 +2324,20 @@ class hashtable_impl
std::size_t priv_hash_to_bucket(std::size_t hash_value) const std::size_t priv_hash_to_bucket(std::size_t hash_value) const
{ return this->priv_hash_to_bucket(hash_value, this->priv_real_bucket_traits().bucket_count(), this->priv_split_traits().get_size()); } { return this->priv_hash_to_bucket(hash_value, this->priv_real_bucket_traits().bucket_count(), this->priv_split_traits().get_size()); }
std::size_t priv_hash_to_bucket(std::size_t hash_value, std::size_t bucket_count_, std::size_t split) const std::size_t priv_hash_to_bucket(std::size_t hash_value, std::size_t bucket_cnt, std::size_t split) const
{ {
std::size_t bucket_number = hashtable_impl::priv_hash_to_bucket_impl(hash_value, bucket_count_, power_2_buckets_t()); std::size_t bucket_number = hashtable_impl::priv_hash_to_bucket_impl(hash_value, bucket_cnt, power_2_buckets_t());
if(incremental) if(incremental)
if(bucket_number >= split) if(bucket_number >= split)
bucket_number -= bucket_count_/2; bucket_number -= bucket_cnt/2;
return bucket_number; return bucket_number;
} }
static std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_count, detail::false_) static std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_cnt, detail::false_)
{ return hash_value % bucket_count; } { return hash_value % bucket_cnt; }
static std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_count, detail::true_) static std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_cnt, detail::true_)
{ return hash_value & (bucket_count - 1); } { return hash_value & (bucket_cnt - 1); }
const key_equal &priv_equal() const const key_equal &priv_equal() const
{ return static_cast<const key_equal&>(this->data_.internal_.bucket_hash_equal_.get()); } { return static_cast<const key_equal&>(this->data_.internal_.bucket_hash_equal_.get()); }
@@ -2413,20 +2413,20 @@ class hashtable_impl
template<class Disposer> template<class Disposer>
void priv_erase_range_impl void priv_erase_range_impl
(size_type bucket_num, siterator before_first_it, siterator end_, Disposer disposer, size_type &num_erased) (size_type bucket_num, siterator before_first_it, siterator end_sit, Disposer disposer, size_type &num_erased)
{ {
const bucket_ptr buckets = this->priv_bucket_pointer(); const bucket_ptr buckets = this->priv_bucket_pointer();
bucket_type &b = buckets[bucket_num]; bucket_type &b = buckets[bucket_num];
if(before_first_it == b.before_begin() && end_ == b.end()){ if(before_first_it == b.before_begin() && end_sit == b.end()){
this->priv_erase_range_impl(bucket_num, 1, disposer, num_erased); this->priv_erase_range_impl(bucket_num, 1, disposer, num_erased);
} }
else{ else{
num_erased = 0; num_erased = 0;
siterator to_erase(before_first_it); siterator to_erase(before_first_it);
++to_erase; ++to_erase;
slist_node_ptr end_ptr = end_.pointed_node(); slist_node_ptr end_ptr = end_sit.pointed_node();
while(to_erase != end_){ while(to_erase != end_sit){
group_functions_t::erase_from_group(end_ptr, hashtable_impl::dcast_bucket_ptr(to_erase.pointed_node()), optimize_multikey_t()); group_functions_t::erase_from_group(end_ptr, hashtable_impl::dcast_bucket_ptr(to_erase.pointed_node()), optimize_multikey_t());
to_erase = b.erase_after_and_dispose(before_first_it, make_node_disposer(disposer)); to_erase = b.erase_after_and_dispose(before_first_it, make_node_disposer(disposer));
++num_erased; ++num_erased;
@@ -2447,8 +2447,8 @@ class hashtable_impl
siterator b_begin(b.before_begin()); siterator b_begin(b.before_begin());
siterator nxt(b_begin); siterator nxt(b_begin);
++nxt; ++nxt;
siterator end_(b.end()); siterator end_sit(b.end());
while(nxt != end_){ while(nxt != end_sit){
group_functions_t::init_group(hashtable_impl::dcast_bucket_ptr(nxt.pointed_node()), optimize_multikey_t()); group_functions_t::init_group(hashtable_impl::dcast_bucket_ptr(nxt.pointed_node()), optimize_multikey_t());
nxt = b.erase_after_and_dispose nxt = b.erase_after_and_dispose
(b_begin, make_node_disposer(disposer)); (b_begin, make_node_disposer(disposer));
@@ -2648,8 +2648,8 @@ class hashtable_impl
siterator priv_begin(detail::false_) const siterator priv_begin(detail::false_) const
{ {
size_type n = 0; size_type n = 0;
size_type bucket_count_ = this->priv_bucket_count(); size_type bucket_cnt = this->priv_bucket_count();
for (n = 0; n < bucket_count_; ++n){ for (n = 0; n < bucket_cnt; ++n){
bucket_type &b = this->priv_bucket_pointer()[n]; bucket_type &b = this->priv_bucket_pointer()[n];
if(!b.empty()){ if(!b.empty()){
return b.begin(); return b.begin();
@@ -2772,9 +2772,9 @@ class hashtable_impl
void priv_initialize_buckets() void priv_initialize_buckets()
{ this->priv_clear_buckets(this->priv_bucket_pointer(), this->priv_bucket_count()); } { this->priv_clear_buckets(this->priv_bucket_pointer(), this->priv_bucket_count()); }
void priv_clear_buckets(bucket_ptr buckets_ptr, size_type bucket_count_) void priv_clear_buckets(bucket_ptr buckets_ptr, size_type bucket_cnt)
{ {
for(; bucket_count_--; ++buckets_ptr){ for(; bucket_cnt--; ++buckets_ptr){
if(safemode_or_autounlink){ if(safemode_or_autounlink){
hashtable_impl::priv_clear_group_nodes(*buckets_ptr, optimize_multikey_t()); hashtable_impl::priv_clear_group_nodes(*buckets_ptr, optimize_multikey_t());
buckets_ptr->clear_and_dispose(detail::init_disposer<node_algorithms>()); buckets_ptr->clear_and_dispose(detail::init_disposer<node_algorithms>());
@@ -2877,10 +2877,10 @@ class hashtable_impl
, KeyValueEqual equal_func , KeyValueEqual equal_func
, size_type &bucket_number_first , size_type &bucket_number_first
, size_type &bucket_number_second , size_type &bucket_number_second
, size_type &count_) const , size_type &cnt) const
{ {
std::size_t h; std::size_t h;
count_ = 0; cnt = 0;
siterator prev; siterator prev;
//Let's see if the element is present //Let's see if the element is present
std::pair<siterator, siterator> to_return std::pair<siterator, siterator> to_return
@@ -2890,43 +2890,43 @@ class hashtable_impl
bucket_number_second = bucket_number_first; bucket_number_second = bucket_number_first;
return to_return; return to_return;
} }
//If it's present, find the first that it's not equal in
//the same bucket
{ {
bucket_type &b = this->priv_bucket_pointer()[bucket_number_first]; //If it's present, find the first that it's not equal in
siterator it = to_return.first; //the same bucket
if(optimize_multikey){ bucket_type &b = this->priv_bucket_pointer()[bucket_number_first];
to_return.second = bucket_type::s_iterator_to siterator it = to_return.first;
(*node_traits::get_next(group_functions_t::get_last_in_group if(optimize_multikey){
(hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()))); to_return.second = bucket_type::s_iterator_to
count_ = std::distance(it, to_return.second); (*node_traits::get_next(group_functions_t::get_last_in_group
if(to_return.second != b.end()){ (hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())));
bucket_number_second = bucket_number_first; cnt = std::distance(it, to_return.second);
return to_return; if(to_return.second != b.end()){
} bucket_number_second = bucket_number_first;
} return to_return;
else{ }
++count_; }
++it; else{
while(it != b.end()){ ++cnt;
const value_type &v = this->priv_value_from_slist_node(it.pointed_node()); ++it;
if(compare_hash){ while(it != b.end()){
std::size_t hv = this->priv_stored_or_compute_hash(v, store_hash_t()); const value_type &v = this->priv_value_from_slist_node(it.pointed_node());
if(hv != h || !equal_func(key, v)){ if(compare_hash){
to_return.second = it; std::size_t hv = this->priv_stored_or_compute_hash(v, store_hash_t());
bucket_number_second = bucket_number_first; if(hv != h || !equal_func(key, v)){
return to_return; to_return.second = it;
} bucket_number_second = bucket_number_first;
} return to_return;
else if(!equal_func(key, v)){ }
to_return.second = it; }
bucket_number_second = bucket_number_first; else if(!equal_func(key, v)){
return to_return; to_return.second = it;
} bucket_number_second = bucket_number_first;
++it; return to_return;
++count_; }
} ++it;
} ++cnt;
}
}
} }
//If we reached the end, find the first, non-empty bucket //If we reached the end, find the first, non-empty bucket

View File

@@ -202,7 +202,7 @@ class list_impl
//! //!
//! <b>Throws</b>: If real_value_traits::node_traits::node //! <b>Throws</b>: If real_value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks). //! constructor throws (this does not happen with predefined Boost.Intrusive hooks).
list_impl(const value_traits &v_traits = value_traits()) explicit list_impl(const value_traits &v_traits = value_traits())
: data_(v_traits) : data_(v_traits)
{ {
this->priv_size_traits().set_size(size_type(0)); this->priv_size_traits().set_size(size_type(0));
@@ -916,9 +916,9 @@ class list_impl
} }
//! <b>Requires</b>: p must be a valid iterator of *this. //! <b>Requires</b>: p must be a valid iterator of *this.
//! start and end must point to elements contained in list x. //! f and e must point to elements contained in list x.
//! //!
//! <b>Effects</b>: Transfers the range pointed by start and end from list x to this list, //! <b>Effects</b>: Transfers the range pointed by f and e from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called. //! before the the element pointed by p. No destructors or copy constructors are called.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
@@ -928,19 +928,19 @@ class list_impl
//! //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated. //! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, list_impl&x, const_iterator start, const_iterator end_) void splice(const_iterator p, list_impl&x, const_iterator f, const_iterator e)
{ {
if(constant_time_size) if(constant_time_size)
this->splice(p, x, start, end_, std::distance(start, end_)); this->splice(p, x, f, e, std::distance(f, e));
else else
this->splice(p, x, start, end_, 1);//distance is a dummy value this->splice(p, x, f, e, 1);//distance is a dummy value
} }
//! <b>Requires</b>: p must be a valid iterator of *this. //! <b>Requires</b>: p must be a valid iterator of *this.
//! start and end must point to elements contained in list x. //! f and e must point to elements contained in list x.
//! n == std::distance(start, end) //! n == std::distance(f, e)
//! //!
//! <b>Effects</b>: Transfers the range pointed by start and end from list x to this list, //! <b>Effects</b>: Transfers the range pointed by f and e from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called. //! before the the element pointed by p. No destructors or copy constructors are called.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
@@ -949,19 +949,19 @@ class list_impl
//! //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated. //! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, list_impl&x, const_iterator start, const_iterator end_, difference_type n) void splice(const_iterator p, list_impl&x, const_iterator f, const_iterator e, difference_type n)
{ {
if(n){ if(n){
if(constant_time_size){ if(constant_time_size){
size_traits &thist = this->priv_size_traits(); size_traits &thist = this->priv_size_traits();
size_traits &xt = x.priv_size_traits(); size_traits &xt = x.priv_size_traits();
BOOST_INTRUSIVE_INVARIANT_ASSERT(n == std::distance(start, end_)); BOOST_INTRUSIVE_INVARIANT_ASSERT(n == std::distance(f, e));
node_algorithms::transfer(p.pointed_node(), start.pointed_node(), end_.pointed_node()); node_algorithms::transfer(p.pointed_node(), f.pointed_node(), e.pointed_node());
thist.set_size(thist.get_size() + n); thist.set_size(thist.get_size() + n);
xt.set_size(xt.get_size() - n); xt.set_size(xt.get_size() - n);
} }
else{ else{
node_algorithms::transfer(p.pointed_node(), start.pointed_node(), end_.pointed_node()); node_algorithms::transfer(p.pointed_node(), f.pointed_node(), e.pointed_node());
} }
} }
} }

View File

@@ -224,8 +224,8 @@ class rbtree_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructorof the value_compare object throws. Basic guarantee. //! or the copy constructorof the value_compare object throws. Basic guarantee.
rbtree_impl( const value_compare &cmp = value_compare() explicit rbtree_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: data_(cmp, v_traits) : data_(cmp, v_traits)
{ {
node_algorithms::init_header(this->priv_header_ptr()); node_algorithms::init_header(this->priv_header_ptr());

View File

@@ -93,8 +93,8 @@ class set_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor of the value_compare object throws. //! or the copy constructor of the value_compare object throws.
set_impl( const value_compare &cmp = value_compare() explicit set_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: tree_(cmp, v_traits) : tree_(cmp, v_traits)
{} {}
@@ -1394,8 +1394,8 @@ class multiset_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor/operator() of the value_compare object throws. //! or the copy constructor/operator() of the value_compare object throws.
multiset_impl( const value_compare &cmp = value_compare() explicit multiset_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: tree_(cmp, v_traits) : tree_(cmp, v_traits)
{} {}

View File

@@ -84,8 +84,8 @@ class sg_set_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor of the value_compare object throws. //! or the copy constructor of the value_compare object throws.
sg_set_impl( const value_compare &cmp = value_compare() explicit sg_set_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: tree_(cmp, v_traits) : tree_(cmp, v_traits)
{} {}
@@ -1417,8 +1417,8 @@ class sg_multiset_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor/operator() of the value_compare object throws. //! or the copy constructor/operator() of the value_compare object throws.
sg_multiset_impl( const value_compare &cmp = value_compare() explicit sg_multiset_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: tree_(cmp, v_traits) : tree_(cmp, v_traits)
{} {}

View File

@@ -370,8 +370,8 @@ class sgtree_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructorof the value_compare object throws. Basic guarantee. //! or the copy constructorof the value_compare object throws. Basic guarantee.
sgtree_impl( const value_compare &cmp = value_compare() explicit sgtree_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: data_(cmp, v_traits) : data_(cmp, v_traits)
{ {
node_algorithms::init_header(this->priv_header_ptr()); node_algorithms::init_header(this->priv_header_ptr());
@@ -701,9 +701,9 @@ class sgtree_impl
template<class Iterator> template<class Iterator>
void insert_equal(Iterator b, Iterator e) void insert_equal(Iterator b, Iterator e)
{ {
iterator end_(this->end()); iterator iend(this->end());
for (; b != e; ++b) for (; b != e; ++b)
this->insert_equal(end_, *b); this->insert_equal(iend, *b);
} }
//! <b>Requires</b>: value must be an lvalue //! <b>Requires</b>: value must be an lvalue
@@ -767,9 +767,9 @@ class sgtree_impl
void insert_unique(Iterator b, Iterator e) void insert_unique(Iterator b, Iterator e)
{ {
if(this->empty()){ if(this->empty()){
iterator end_(this->end()); iterator iend(this->end());
for (; b != e; ++b) for (; b != e; ++b)
this->insert_unique(end_, *b); this->insert_unique(iend, *b);
} }
else{ else{
for (; b != e; ++b) for (; b != e; ++b)

View File

@@ -186,10 +186,17 @@ class slist_impl
{ return this->set_last_node(n, detail::bool_<cache_last>()); } { return this->set_last_node(n, detail::bool_<cache_last>()); }
static node_ptr get_last_node(detail::bool_<false>) static node_ptr get_last_node(detail::bool_<false>)
{ return node_ptr(); } {
//This function shall not be used if cache_last is not true
BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
return node_ptr();
}
static void set_last_node(const node_ptr &, detail::bool_<false>) static void set_last_node(const node_ptr &, detail::bool_<false>)
{} {
//This function shall not be used if cache_last is not true
BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
}
node_ptr get_last_node(detail::bool_<true>) node_ptr get_last_node(detail::bool_<true>)
{ return node_ptr(data_.root_plus_size_.last_); } { return node_ptr(data_.root_plus_size_.last_); }
@@ -273,19 +280,56 @@ class slist_impl
{ return this->get_real_value_traits(detail::bool_<external_value_traits>()); } { return this->get_real_value_traits(detail::bool_<external_value_traits>()); }
public: public:
///@cond
//! <b>Requires</b>: f and before_l belong to another slist.
//!
//! <b>Effects</b>: Transfers the range [f, before_l] to this
//! list, after the element pointed by prev_pos.
//! No destructors or copy constructors are called.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the number of elements transferred
//! if constant_time_size is true. Constant-time otherwise.
//!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
//!
//! <b>Warning</b>: Experimental function, don't use it!
slist_impl( const node_ptr & f, const node_ptr & before_l
, size_type n, const value_traits &v_traits = value_traits())
: data_(v_traits)
{
if(n){
this->priv_size_traits().set_size(n);
if(cache_last){
this->set_last_node(before_l);
}
node_traits::set_next(this->get_root_node(), f);
node_traits::set_next(before_l, this->get_end_node());
}
else{
this->set_default_constructed_state();
}
}
///@endcond
//! <b>Effects</b>: constructs an empty list. //! <b>Effects</b>: constructs an empty list.
//! //!
//! <b>Complexity</b>: Constant //! <b>Complexity</b>: Constant
//! //!
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks). //! constructor throws (this does not happen with predefined Boost.Intrusive hooks).
slist_impl(const value_traits &v_traits = value_traits()) explicit slist_impl(const value_traits &v_traits = value_traits())
: data_(v_traits) : data_(v_traits)
{ this->set_default_constructed_state(); } { this->set_default_constructed_state(); }
//! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type. //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type.
//! //!
//! <b>Effects</b>: Constructs a list equal to [first,last). //! <b>Effects</b>: Constructs a list equal to [b ,e).
//! //!
//! <b>Complexity</b>: Linear in std::distance(b, e). No copy constructors are called. //! <b>Complexity</b>: Linear in std::distance(b, e). No copy constructors are called.
//! //!
@@ -406,7 +450,14 @@ class slist_impl
void push_back(reference value) void push_back(reference value)
{ {
BOOST_STATIC_ASSERT((cache_last)); BOOST_STATIC_ASSERT((cache_last));
this->insert_after(const_iterator(this->get_last_node(), this), value); node_ptr n = get_real_value_traits().to_node_ptr(value);
if(safemode_or_autounlink)
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(n));
node_algorithms::link_after(this->get_last_node(), n);
if(cache_last){
this->set_last_node(n);
}
this->priv_size_traits().increment();
} }
//! <b>Effects</b>: Erases the first element of the list. //! <b>Effects</b>: Erases the first element of the list.
@@ -573,9 +624,13 @@ class slist_impl
//! //!
//! <b>Note</b>: This function is present only if cached_last<> option is true. //! <b>Note</b>: This function is present only if cached_last<> option is true.
iterator last() iterator last()
{ return iterator (this->get_last_node(), this); } {
//This function shall not be used if cache_last is not true
BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
return iterator (this->get_last_node(), this);
}
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list. //! <b>Effects</b>: Returns a const_iterator to the last element contained in the list.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
@@ -583,9 +638,13 @@ class slist_impl
//! //!
//! <b>Note</b>: This function is present only if cached_last<> option is true. //! <b>Note</b>: This function is present only if cached_last<> option is true.
const_iterator last() const const_iterator last() const
{ return const_iterator (this->get_last_node(), this); } {
//This function shall not be used if cache_last is not true
BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last);
return const_iterator (this->get_last_node(), this);
}
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list. //! <b>Effects</b>: Returns a const_iterator to the last element contained in the list.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
@@ -749,7 +808,7 @@ class slist_impl
//! an lvalue of type value_type and prev_p must point to an element //! an lvalue of type value_type and prev_p must point to an element
//! contained by the list or to the end node. //! contained by the list or to the end node.
//! //!
//! <b>Effects</b>: Inserts the [first, last) //! <b>Effects</b>: Inserts the [f, l)
//! after the position prev_p. //! after the position prev_p.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
@@ -758,10 +817,10 @@ class slist_impl
//! //!
//! <b>Note</b>: Does not affect the validity of iterators and references. //! <b>Note</b>: Does not affect the validity of iterators and references.
template<class Iterator> template<class Iterator>
void insert_after(const_iterator prev_p, Iterator first, Iterator last_) void insert_after(const_iterator prev_p, Iterator f, Iterator l)
{ {
for (; first != last_; ++first) for (; f != l; ++f)
prev_p = this->insert_after(prev_p, *first); prev_p = this->insert_after(prev_p, *f);
} }
//! <b>Requires</b>: value must be an lvalue and p must point to an element //! <b>Requires</b>: value must be an lvalue and p must point to an element
@@ -812,7 +871,7 @@ class slist_impl
iterator erase_after(const_iterator prev) iterator erase_after(const_iterator prev)
{ return this->erase_after_and_dispose(prev, detail::null_disposer()); } { return this->erase_after_and_dispose(prev, detail::null_disposer()); }
//! <b>Effects</b>: Erases the range (before_first, last) from //! <b>Effects</b>: Erases the range (before_f, l) from
//! the list. No destructors are called. //! the list. No destructors are called.
//! //!
//! <b>Returns</b>: the first element remaining beyond the removed elements, //! <b>Returns</b>: the first element remaining beyond the removed elements,
@@ -825,26 +884,26 @@ class slist_impl
//! //!
//! <b>Note</b>: Invalidates the iterators (but not the references) to the //! <b>Note</b>: Invalidates the iterators (but not the references) to the
//! erased element. //! erased element.
iterator erase_after(const_iterator before_first, const_iterator last_) iterator erase_after(const_iterator before_f, const_iterator l)
{ {
if(safemode_or_autounlink || constant_time_size){ if(safemode_or_autounlink || constant_time_size){
return this->erase_after_and_dispose(before_first, last_, detail::null_disposer()); return this->erase_after_and_dispose(before_f, l, detail::null_disposer());
} }
else{ else{
node_ptr bfp = before_first.pointed_node(); const node_ptr bfp = before_f.pointed_node();
node_ptr lp = last_.pointed_node(); const node_ptr lp = l.pointed_node();
if(cache_last){ if(cache_last){
if(lp == this->get_end_node()){ if(lp == this->get_end_node()){
this->set_last_node(bfp); this->set_last_node(bfp);
} }
} }
node_algorithms::unlink_after(bfp, lp); node_algorithms::unlink_after(bfp, lp);
return last_.unconst(); return l.unconst();
} }
} }
//! <b>Effects</b>: Erases the range (before_first, last) from //! <b>Effects</b>: Erases the range (before_f, l) from
//! the list. n must be std::distance(before_first, last) - 1. //! the list. n must be std::distance(before_f, l) - 1.
//! No destructors are called. //! No destructors are called.
//! //!
//! <b>Returns</b>: the first element remaining beyond the removed elements, //! <b>Returns</b>: the first element remaining beyond the removed elements,
@@ -853,19 +912,19 @@ class slist_impl
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Complexity</b>: constant-time if link_mode is normal_link. //! <b>Complexity</b>: constant-time if link_mode is normal_link.
//! Linear to the elements (last - before_first) otherwise. //! Linear to the elements (l - before_f) otherwise.
//! //!
//! <b>Note</b>: Invalidates the iterators (but not the references) to the //! <b>Note</b>: Invalidates the iterators (but not the references) to the
//! erased element. //! erased element.
iterator erase_after(const_iterator before_first, const_iterator last_, difference_type n) iterator erase_after(const_iterator before_f, const_iterator l, size_type n)
{ {
BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(++const_iterator(before_first), last_) == difference_type(n)); BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(++const_iterator(before_f), l) == difference_type(n));
if(safemode_or_autounlink){ if(safemode_or_autounlink){
return this->erase_after(before_first, last_); return this->erase_after(before_f, l);
} }
else{ else{
node_ptr bfp = before_first.pointed_node(); const node_ptr bfp = before_f.pointed_node();
node_ptr lp = last_.pointed_node(); const node_ptr lp = l.pointed_node();
if(cache_last){ if(cache_last){
if((lp == this->get_end_node())){ if((lp == this->get_end_node())){
this->set_last_node(bfp); this->set_last_node(bfp);
@@ -875,7 +934,7 @@ class slist_impl
if(constant_time_size){ if(constant_time_size){
this->priv_size_traits().set_size(this->priv_size_traits().get_size() - n); this->priv_size_traits().set_size(this->priv_size_traits().get_size() - n);
} }
return last_.unconst(); return l.unconst();
} }
} }
@@ -894,7 +953,7 @@ class slist_impl
iterator erase(const_iterator i) iterator erase(const_iterator i)
{ return this->erase_after(this->previous(i)); } { return this->erase_after(this->previous(i)); }
//! <b>Requires</b>: first and last must be valid iterator to elements in *this. //! <b>Requires</b>: f and l must be valid iterator to elements in *this.
//! //!
//! <b>Effects</b>: Erases the range pointed by b and e. //! <b>Effects</b>: Erases the range pointed by b and e.
//! No destructors are called. //! No destructors are called.
@@ -904,15 +963,15 @@ class slist_impl
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Complexity</b>: Linear to the elements before last. //! <b>Complexity</b>: Linear to the elements before l.
//! //!
//! <b>Note</b>: Invalidates the iterators (but not the references) to the //! <b>Note</b>: Invalidates the iterators (but not the references) to the
//! erased elements. //! erased elements.
iterator erase(const_iterator first, const_iterator last_) iterator erase(const_iterator f, const_iterator l)
{ return this->erase_after(this->previous(first), last_); } { return this->erase_after(this->previous(f), l); }
//! <b>Effects</b>: Erases the range [first, last) from //! <b>Effects</b>: Erases the range [f, l) from
//! the list. n must be std::distance(first, last). //! the list. n must be std::distance(f, l).
//! No destructors are called. //! No destructors are called.
//! //!
//! <b>Returns</b>: the first element remaining beyond the removed elements, //! <b>Returns</b>: the first element remaining beyond the removed elements,
@@ -920,13 +979,13 @@ class slist_impl
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Complexity</b>: linear to the elements before first if link_mode is normal_link //! <b>Complexity</b>: linear to the elements before f if link_mode is normal_link
//! and constant_time_size is activated. Linear to the elements before last otherwise. //! and constant_time_size is activated. Linear to the elements before l otherwise.
//! //!
//! <b>Note</b>: Invalidates the iterators (but not the references) to the //! <b>Note</b>: Invalidates the iterators (but not the references) to the
//! erased element. //! erased element.
iterator erase(const_iterator first, const_iterator last_, difference_type n) iterator erase(const_iterator f, const_iterator l, size_type n)
{ return this->erase_after(this->previous(first), last_, n); } { return this->erase_after(this->previous(f), l, n); }
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
//! //!
@@ -986,7 +1045,7 @@ class slist_impl
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
//! //!
//! <b>Effects</b>: Erases the range (before_first, last) from //! <b>Effects</b>: Erases the range (before_f, l) from
//! the list. //! the list.
//! Disposer::operator()(pointer) is called for the removed elements. //! Disposer::operator()(pointer) is called for the removed elements.
//! //!
@@ -995,13 +1054,13 @@ class slist_impl
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Complexity</b>: Lineal to the elements (last - before_first + 1). //! <b>Complexity</b>: Lineal to the elements (l - before_f + 1).
//! //!
//! <b>Note</b>: Invalidates the iterators to the erased element. //! <b>Note</b>: Invalidates the iterators to the erased element.
template<class Disposer> template<class Disposer>
iterator erase_after_and_dispose(const_iterator before_first, const_iterator last_, Disposer disposer) iterator erase_after_and_dispose(const_iterator before_f, const_iterator l, Disposer disposer)
{ {
node_ptr bfp(before_first.pointed_node()), lp(last_.pointed_node()); node_ptr bfp(before_f.pointed_node()), lp(l.pointed_node());
node_ptr fp(node_traits::get_next(bfp)); node_ptr fp(node_traits::get_next(bfp));
node_algorithms::unlink_after(bfp, lp); node_algorithms::unlink_after(bfp, lp);
while(fp != lp){ while(fp != lp){
@@ -1015,7 +1074,7 @@ class slist_impl
if(cache_last && (node_traits::get_next(bfp) == this->get_end_node())){ if(cache_last && (node_traits::get_next(bfp) == this->get_end_node())){
this->set_last_node(bfp); this->set_last_node(bfp);
} }
return last_.unconst(); return l.unconst();
} }
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
@@ -1043,7 +1102,7 @@ class slist_impl
{ return this->erase_and_dispose(const_iterator(i), disposer); } { return this->erase_and_dispose(const_iterator(i), disposer); }
#endif #endif
//! <b>Requires</b>: first and last must be valid iterator to elements in *this. //! <b>Requires</b>: f and l must be valid iterator to elements in *this.
//! Disposer::operator()(pointer) shouldn't throw. //! Disposer::operator()(pointer) shouldn't throw.
//! //!
//! <b>Effects</b>: Erases the range pointed by b and e. //! <b>Effects</b>: Erases the range pointed by b and e.
@@ -1056,13 +1115,13 @@ class slist_impl
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Complexity</b>: Linear to the number of erased elements plus linear //! <b>Complexity</b>: Linear to the number of erased elements plus linear
//! to the elements before first. //! to the elements before f.
//! //!
//! <b>Note</b>: Invalidates the iterators (but not the references) to the //! <b>Note</b>: Invalidates the iterators (but not the references) to the
//! erased elements. //! erased elements.
template<class Disposer> template<class Disposer>
iterator erase_and_dispose(const_iterator first, const_iterator last_, Disposer disposer) iterator erase_and_dispose(const_iterator f, const_iterator l, Disposer disposer)
{ return this->erase_after_and_dispose(this->previous(first), last_, disposer); } { return this->erase_after_and_dispose(this->previous(f), l, disposer); }
//! <b>Requires</b>: Dereferencing iterator must yield //! <b>Requires</b>: Dereferencing iterator must yield
//! an lvalue of type value_type. //! an lvalue of type value_type.
@@ -1121,23 +1180,23 @@ class slist_impl
//! //!
//! <b>Complexity</b>: In general, linear to the elements contained in x. //! <b>Complexity</b>: In general, linear to the elements contained in x.
//! Constant-time if cache_last<> option is true and also constant-time if //! Constant-time if cache_last<> option is true and also constant-time if
//! linear<> option is true "this" is empty and "last" is not used. //! linear<> option is true "this" is empty and "l" is not used.
//! //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated. //! list. Iterators of this list and all the references are not invalidated.
//! //!
//! <b>Additional note</b>: If the optional parameter "last" is provided, it will be //! <b>Additional note</b>: If the optional parameter "l" is provided, it will be
//! assigned to the last spliced element or prev if x is empty. //! assigned to the last spliced element or prev if x is empty.
//! This iterator can be used as new "prev" iterator for a new splice_after call. //! This iterator can be used as new "prev" iterator for a new splice_after call.
//! that will splice new values after the previously spliced values. //! that will splice new values after the previously spliced values.
void splice_after(const_iterator prev, slist_impl &x, const_iterator *last_ = 0) void splice_after(const_iterator prev, slist_impl &x, const_iterator *l = 0)
{ {
if(x.empty()){ if(x.empty()){
if(last_) *last_ = prev; if(l) *l = prev;
} }
else if(linear && this->empty()){ else if(linear && this->empty()){
this->swap(x); this->swap(x);
if(last_) *last_ = this->previous(this->cend()); if(l) *l = this->previous(this->cend());
} }
else{ else{
const_iterator last_x(x.previous(x.end())); //<- constant time if cache_last is active const_iterator last_x(x.previous(x.end())); //<- constant time if cache_last is active
@@ -1152,7 +1211,7 @@ class slist_impl
node_algorithms::transfer_after( prev_n, x.before_begin().pointed_node(), last_x_n); node_algorithms::transfer_after( prev_n, x.before_begin().pointed_node(), last_x_n);
this->priv_size_traits().set_size(this->priv_size_traits().get_size() + x.priv_size_traits().get_size()); this->priv_size_traits().set_size(this->priv_size_traits().get_size() + x.priv_size_traits().get_size());
x.priv_size_traits().set_size(size_type(0)); x.priv_size_traits().set_size(size_type(0));
if(last_) *last_ = last_x; if(l) *l = last_x;
} }
} }
@@ -1176,10 +1235,10 @@ class slist_impl
} }
//! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be //! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be
//! before_begin(), and before_first and before_last belong to x and //! before_begin(), and before_f and before_l belong to x and
//! ++before_first != x.end() && before_last != x.end(). //! ++before_f != x.end() && before_l != x.end().
//! //!
//! <b>Effects</b>: Transfers the range (before_first, before_last] from list x to this //! <b>Effects</b>: Transfers the range (before_f, before_l] from list x to this
//! list, after the element pointed by prev_pos. //! list, after the element pointed by prev_pos.
//! No destructors or copy constructors are called. //! No destructors or copy constructors are called.
//! //!
@@ -1190,21 +1249,21 @@ class slist_impl
//! //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated. //! list. Iterators of this list and all the references are not invalidated.
void splice_after(const_iterator prev_pos, slist_impl &x, const_iterator before_first, const_iterator before_last) void splice_after(const_iterator prev_pos, slist_impl &x, const_iterator before_f, const_iterator before_l)
{ {
if(constant_time_size) if(constant_time_size)
this->splice_after(prev_pos, x, before_first, before_last, std::distance(before_first, before_last)); this->splice_after(prev_pos, x, before_f, before_l, std::distance(before_f, before_l));
else else
this->priv_splice_after this->priv_splice_after
(prev_pos.pointed_node(), x, before_first.pointed_node(), before_last.pointed_node()); (prev_pos.pointed_node(), x, before_f.pointed_node(), before_l.pointed_node());
} }
//! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be //! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be
//! before_begin(), and before_first and before_last belong to x and //! before_begin(), and before_f and before_l belong to x and
//! ++before_first != x.end() && before_last != x.end() and //! ++before_f != x.end() && before_l != x.end() and
//! n == std::distance(before_first, before_last). //! n == std::distance(before_f, before_l).
//! //!
//! <b>Effects</b>: Transfers the range (before_first, before_last] from list x to this //! <b>Effects</b>: Transfers the range (before_f, before_l] from list x to this
//! list, after the element pointed by p. No destructors or copy constructors are called. //! list, after the element pointed by p. No destructors or copy constructors are called.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
@@ -1213,16 +1272,14 @@ class slist_impl
//! //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated. //! list. Iterators of this list and all the references are not invalidated.
void splice_after(const_iterator prev_pos, slist_impl &x, const_iterator before_first, const_iterator before_last, difference_type n) void splice_after(const_iterator prev_pos, slist_impl &x, const_iterator before_f, const_iterator before_l, size_type n)
{ {
if(n){ BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(before_f, before_l) == difference_type(n));
BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(before_first, before_last) == n); this->priv_splice_after
this->priv_splice_after (prev_pos.pointed_node(), x, before_f.pointed_node(), before_l.pointed_node());
(prev_pos.pointed_node(), x, before_first.pointed_node(), before_last.pointed_node()); if(constant_time_size){
if(constant_time_size){ this->priv_size_traits().set_size(this->priv_size_traits().get_size() + n);
this->priv_size_traits().set_size(this->priv_size_traits().get_size() + n); x.priv_size_traits().set_size(x.priv_size_traits().get_size() - n);
x.priv_size_traits().set_size(x.priv_size_traits().get_size() - n);
}
} }
} }
@@ -1243,12 +1300,12 @@ class slist_impl
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated. //! list. Iterators of this list and all the references are not invalidated.
//! //!
//! <b>Additional note</b>: If the optional parameter "last" is provided, it will be //! <b>Additional note</b>: If the optional parameter "l" is provided, it will be
//! assigned to the last spliced element or prev if x is empty. //! assigned to the last spliced element or prev if x is empty.
//! This iterator can be used as new "prev" iterator for a new splice_after call. //! This iterator can be used as new "prev" iterator for a new splice_after call.
//! that will splice new values after the previously spliced values. //! that will splice new values after the previously spliced values.
void splice(const_iterator it, slist_impl &x, const_iterator *last_ = 0) void splice(const_iterator it, slist_impl &x, const_iterator *l = 0)
{ this->splice_after(this->previous(it), x, last_); } { this->splice_after(this->previous(it), x, l); }
//! <b>Requires</b>: it p must be a valid iterator of *this. //! <b>Requires</b>: it p must be a valid iterator of *this.
//! elem must point to an element contained in list //! elem must point to an element contained in list
@@ -1268,43 +1325,43 @@ class slist_impl
{ return this->splice_after(this->previous(pos), x, x.previous(elem)); } { return this->splice_after(this->previous(pos), x, x.previous(elem)); }
//! <b>Requires</b>: pos must be a dereferenceable iterator in *this //! <b>Requires</b>: pos must be a dereferenceable iterator in *this
//! and first and last belong to x and first and last a valid range on x. //! and f and f belong to x and f and f a valid range on x.
//! //!
//! <b>Effects</b>: Transfers the range [first, last) from list x to this //! <b>Effects</b>: Transfers the range [f, l) from list x to this
//! list, before the element pointed by pos. //! list, before the element pointed by pos.
//! No destructors or copy constructors are called. //! No destructors or copy constructors are called.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Complexity</b>: Linear to the sum of elements before pos, first, and last //! <b>Complexity</b>: Linear to the sum of elements before pos, f, and l
//! plus linear to the number of elements transferred if constant_time_size is true. //! plus linear to the number of elements transferred if constant_time_size is true.
//! Linear to the sum of elements before first, and last //! Linear to the sum of elements before f, and l
//! plus linear to the number of elements transferred if constant_time_size is true //! plus linear to the number of elements transferred if constant_time_size is true
//! if cache_last<> is true and pos == end() //! if cache_last<> is true and pos == end()
//! //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated. //! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator pos, slist_impl &x, const_iterator first, const_iterator last_) void splice(const_iterator pos, slist_impl &x, const_iterator f, const_iterator l)
{ return this->splice_after(this->previous(pos), x, x.previous(first), x.previous(last_)); } { return this->splice_after(this->previous(pos), x, x.previous(f), x.previous(l)); }
//! <b>Requires</b>: pos must be a dereferenceable iterator in *this //! <b>Requires</b>: pos must be a dereferenceable iterator in *this
//! and first and last belong to x and first and last a valid range on x. //! and f and l belong to x and f and l a valid range on x.
//! n == std::distance(first, last). //! n == std::distance(f, l).
//! //!
//! <b>Effects</b>: Transfers the range [first, last) from list x to this //! <b>Effects</b>: Transfers the range [f, l) from list x to this
//! list, before the element pointed by pos. //! list, before the element pointed by pos.
//! No destructors or copy constructors are called. //! No destructors or copy constructors are called.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Complexity</b>: Linear to the sum of elements before pos, first, and last. //! <b>Complexity</b>: Linear to the sum of elements before pos, f, and l.
//! Linear to the sum of elements before first and last //! Linear to the sum of elements before f and l
//! if cache_last<> is true and pos == end(). //! if cache_last<> is true and pos == end().
//! //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated. //! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator pos, slist_impl &x, const_iterator first, const_iterator last_, difference_type n) void splice(const_iterator pos, slist_impl &x, const_iterator f, const_iterator l, size_type n)
{ return this->splice_after(this->previous(pos), x, x.previous(first), x.previous(last_), n); } { return this->splice_after(this->previous(pos), x, x.previous(f), x.previous(l), n); }
//! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>. //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
//! The sort is stable, that is, the relative order of equivalent elements is preserved. //! The sort is stable, that is, the relative order of equivalent elements is preserved.
@@ -1402,14 +1459,14 @@ class slist_impl
//! //!
//! <b>Note</b>: Iterators and references are not invalidated. //! <b>Note</b>: Iterators and references are not invalidated.
//! //!
//! <b>Additional note</b>: If optional "last" argument is passed, it is assigned //! <b>Additional note</b>: If optional "l" argument is passed, it is assigned
//! to an iterator to the last transferred value or end() is x is empty. //! to an iterator to the last transferred value or end() is x is empty.
template<class Predicate> template<class Predicate>
void merge(slist_impl& x, Predicate p, const_iterator *last_ = 0) void merge(slist_impl& x, Predicate p, const_iterator *l = 0)
{ {
const_iterator e(this->cend()), ex(x.cend()), bb(this->cbefore_begin()), const_iterator e(this->cend()), ex(x.cend()), bb(this->cbefore_begin()),
bb_next; bb_next;
if(last_) *last_ = e.unconst(); if(l) *l = e.unconst();
while(!x.empty()){ while(!x.empty()){
const_iterator ibx_next(x.cbefore_begin()), ibx(ibx_next++); const_iterator ibx_next(x.cbefore_begin()), ibx(ibx_next++);
while (++(bb_next = bb) != e && !p(*ibx_next, *bb_next)){ while (++(bb_next = bb) != e && !p(*ibx_next, *bb_next)){
@@ -1417,7 +1474,7 @@ class slist_impl
} }
if(bb_next == e){ if(bb_next == e){
//Now transfer the rest to the end of the container //Now transfer the rest to the end of the container
this->splice_after(bb, x, last_); this->splice_after(bb, x, l);
break; break;
} }
else{ else{
@@ -1426,7 +1483,7 @@ class slist_impl
ibx = ibx_next; ++n; ibx = ibx_next; ++n;
} while(++(ibx_next = ibx) != ex && p(*ibx_next, *bb_next)); } while(++(ibx_next = ibx) != ex && p(*ibx_next, *bb_next));
this->splice_after(bb, x, x.before_begin(), ibx, n); this->splice_after(bb, x, x.before_begin(), ibx, n);
if(last_) *last_ = ibx; if(l) *l = ibx;
} }
} }
} }
@@ -1728,11 +1785,12 @@ class slist_impl
(prev_from.pointed_node(), i.pointed_node()), this); (prev_from.pointed_node(), i.pointed_node()), this);
} }
///@cond
//! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be //! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be
//! before_begin(), and before_first and before_last belong to x and //! before_begin(), and f and before_l belong to another slist.
//! ++before_first != x.end() && before_last != x.end().
//! //!
//! <b>Effects</b>: Transfers the range (before_first, before_last] to this //! <b>Effects</b>: Transfers the range [f, before_l] to this
//! list, after the element pointed by prev_pos. //! list, after the element pointed by prev_pos.
//! No destructors or copy constructors are called. //! No destructors or copy constructors are called.
//! //!
@@ -1741,67 +1799,70 @@ class slist_impl
//! <b>Complexity</b>: Linear to the number of elements transferred //! <b>Complexity</b>: Linear to the number of elements transferred
//! if constant_time_size is true. Constant-time otherwise. //! if constant_time_size is true. Constant-time otherwise.
//! //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this //! <b>Note</b>: Iterators of values obtained from the list that owned f and before_l now
//! list. Iterators of this list and all the references are not invalidated. //! point to elements of this list. Iterators of this list and all the references are not invalidated.
void incorporate_after(const_iterator prev_from, const node_ptr & first, const node_ptr & before_last) //!
//! <b>Warning</b>: Experimental function, don't use it!
void incorporate_after(const_iterator prev_pos, const node_ptr & f, const node_ptr & before_l)
{ {
if(constant_time_size) if(constant_time_size)
this->incorporate_after(prev_from, first, before_last, std::distance(first, before_last)+1); this->incorporate_after(prev_pos, f, before_l, std::distance(f, before_l)+1);
else else
this->priv_incorporate_after this->priv_incorporate_after(prev_pos.pointed_node(), f, before_l);
(prev_from.pointed_node(), first, before_last);
} }
//! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be //! <b>Requires</b>: prev_pos must be a dereferenceable iterator in *this or be
//! before_begin(), and before_first and before_last belong to x and //! before_begin(), and f and before_l belong to another slist.
//! ++before_first != x.end() && before_last != x.end() and //! n == std::distance(f, before_l) + 1.
//! n == std::distance(first, before_last) + 1.
//! //!
//! <b>Effects</b>: Transfers the range (before_first, before_last] from list x to this //! <b>Effects</b>: Transfers the range [f, before_l] to this
//! list, after the element pointed by p. No destructors or copy constructors are called. //! list, after the element pointed by prev_pos.
//! No destructors or copy constructors are called.
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Complexity</b>: Constant time. //! <b>Complexity</b>: Constant time.
//! //!
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this //! <b>Note</b>: Iterators of values obtained from the list that owned f and before_l now
//! list. Iterators of this list and all the references are not invalidated. //! point to elements of this list. Iterators of this list and all the references are not invalidated.
void incorporate_after(const_iterator prev_pos, const node_ptr & first, const node_ptr & before_last, difference_type n) //!
//! <b>Warning</b>: Experimental function, don't use it!
void incorporate_after(const_iterator prev_pos, const node_ptr & f, const node_ptr & before_l, size_type n)
{ {
if(n){ if(n){
BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(iterator(first, this), iterator(before_last, this))+1 == n); BOOST_INTRUSIVE_INVARIANT_ASSERT(n > 0);
this->priv_incorporate_after(prev_pos.pointed_node(), first, before_last); BOOST_INTRUSIVE_INVARIANT_ASSERT(size_type(std::distance(iterator(f, this), iterator(before_l, this)))+1 == n);
this->priv_incorporate_after(prev_pos.pointed_node(), f, before_l);
if(constant_time_size){ if(constant_time_size){
this->priv_size_traits().set_size(this->priv_size_traits().get_size() + n); this->priv_size_traits().set_size(this->priv_size_traits().get_size() + n);
} }
} }
} }
///@endcond
private: private:
void priv_splice_after(const node_ptr & prev_pos_n, slist_impl &x, const node_ptr & before_first_n, const node_ptr & before_last_n) void priv_splice_after(const node_ptr & prev_pos_n, slist_impl &x, const node_ptr & before_f_n, const node_ptr & before_l_n)
{ {
if (before_first_n != before_last_n && prev_pos_n != before_first_n && prev_pos_n != before_last_n) if (cache_last && (before_f_n != before_l_n)){
{ if(prev_pos_n == this->get_last_node()){
if(cache_last){ this->set_last_node(before_l_n);
if(node_traits::get_next(prev_pos_n) == this->get_end_node()){ }
this->set_last_node(before_last_n); if(&x != this && node_traits::get_next(before_l_n) == x.get_end_node()){
} x.set_last_node(before_f_n);
if(node_traits::get_next(before_last_n) == x.get_end_node()){
x.set_last_node(before_first_n);
}
} }
node_algorithms::transfer_after(prev_pos_n, before_first_n, before_last_n);
} }
node_algorithms::transfer_after(prev_pos_n, before_f_n, before_l_n);
} }
void priv_incorporate_after(const node_ptr & prev_pos_n, const node_ptr & first_n, const node_ptr & before_last_n) void priv_incorporate_after(const node_ptr & prev_pos_n, const node_ptr & first_n, const node_ptr & before_l_n)
{ {
if(cache_last){ if(cache_last){
if(node_traits::get_next(prev_pos_n) == this->get_end_node()){ if(prev_pos_n == this->get_last_node()){
this->set_last_node(before_last_n); this->set_last_node(before_l_n);
} }
} }
node_algorithms::incorporate_after(prev_pos_n, first_n, before_last_n); node_algorithms::incorporate_after(prev_pos_n, first_n, before_l_n);
} }
void priv_reverse(detail::bool_<false>) void priv_reverse(detail::bool_<false>)
@@ -1816,9 +1877,9 @@ class slist_impl
void priv_shift_backwards(size_type n, detail::bool_<false>) void priv_shift_backwards(size_type n, detail::bool_<false>)
{ {
node_ptr last_ = node_algorithms::move_forward(this->get_root_node(), (std::size_t)n); node_ptr l = node_algorithms::move_forward(this->get_root_node(), (std::size_t)n);
if(cache_last && last_){ if(cache_last && l){
this->set_last_node(last_); this->set_last_node(l);
} }
} }
@@ -1837,9 +1898,9 @@ class slist_impl
void priv_shift_forward(size_type n, detail::bool_<false>) void priv_shift_forward(size_type n, detail::bool_<false>)
{ {
node_ptr last_ = node_algorithms::move_backwards(this->get_root_node(), (std::size_t)n); node_ptr l = node_algorithms::move_backwards(this->get_root_node(), (std::size_t)n);
if(cache_last && last_){ if(cache_last && l){
this->set_last_node(last_); this->set_last_node(l);
} }
} }
@@ -2100,11 +2161,20 @@ class slist
typedef typename Base::value_traits value_traits; typedef typename Base::value_traits value_traits;
typedef typename Base::iterator iterator; typedef typename Base::iterator iterator;
typedef typename Base::const_iterator const_iterator; typedef typename Base::const_iterator const_iterator;
typedef typename Base::size_type size_type;
typedef typename Base::node_ptr node_ptr;
slist(const value_traits &v_traits = value_traits()) explicit slist(const value_traits &v_traits = value_traits())
: Base(v_traits) : Base(v_traits)
{} {}
struct incorporate_t{};
slist( const node_ptr & f, const node_ptr & before_l
, size_type n, const value_traits &v_traits = value_traits())
: Base(f, before_l, n, v_traits)
{}
template<class Iterator> template<class Iterator>
slist(Iterator b, Iterator e, const value_traits &v_traits = value_traits()) slist(Iterator b, Iterator e, const value_traits &v_traits = value_traits())
: Base(b, e, v_traits) : Base(b, e, v_traits)

View File

@@ -86,8 +86,8 @@ class splay_set_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor of the value_compare object throws. //! or the copy constructor of the value_compare object throws.
splay_set_impl( const value_compare &cmp = value_compare() explicit splay_set_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: tree_(cmp, v_traits) : tree_(cmp, v_traits)
{} {}
@@ -1404,8 +1404,8 @@ class splay_multiset_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor/operator() of the value_compare object throws. //! or the copy constructor/operator() of the value_compare object throws.
splay_multiset_impl( const value_compare &cmp = value_compare() explicit splay_multiset_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: tree_(cmp, v_traits) : tree_(cmp, v_traits)
{} {}

View File

@@ -214,8 +214,8 @@ class splaytree_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructorof the value_compare object throws. Basic guarantee. //! or the copy constructorof the value_compare object throws. Basic guarantee.
splaytree_impl( const value_compare &cmp = value_compare() explicit splaytree_impl( const value_compare &cmp = value_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: data_(cmp, v_traits) : data_(cmp, v_traits)
{ {
node_algorithms::init_header(this->priv_header_ptr()); node_algorithms::init_header(this->priv_header_ptr());
@@ -540,9 +540,9 @@ class splaytree_impl
void insert_equal(Iterator b, Iterator e) void insert_equal(Iterator b, Iterator e)
{ {
if(this->empty()){ if(this->empty()){
iterator end_(this->end()); iterator iend(this->end());
for (; b != e; ++b) for (; b != e; ++b)
this->insert_equal(end_, *b); this->insert_equal(iend, *b);
} }
} }

View File

@@ -9,8 +9,8 @@
// See http://www.boost.org/libs/intrusive for documentation. // See http://www.boost.org/libs/intrusive for documentation.
// //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_INTRUSIVE_TRIE_HPP #ifndef BOOST_INTRUSIVE_TREAP_HPP
#define BOOST_INTRUSIVE_TRIE_HPP #define BOOST_INTRUSIVE_TREAP_HPP
#include <boost/intrusive/detail/config_begin.hpp> #include <boost/intrusive/detail/config_begin.hpp>
#include <algorithm> #include <algorithm>
@@ -232,9 +232,9 @@ class treap_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor of the value_compare/priority_compare objects throw. Basic guarantee. //! or the copy constructor of the value_compare/priority_compare objects throw. Basic guarantee.
treap_impl( const value_compare &cmp = value_compare() explicit treap_impl( const value_compare &cmp = value_compare()
, const priority_compare &pcmp = priority_compare() , const priority_compare &pcmp = priority_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: data_(cmp, pcmp, v_traits) : data_(cmp, pcmp, v_traits)
{ {
node_algorithms::init_header(this->priv_header_ptr()); node_algorithms::init_header(this->priv_header_ptr());
@@ -627,9 +627,9 @@ class treap_impl
template<class Iterator> template<class Iterator>
void insert_equal(Iterator b, Iterator e) void insert_equal(Iterator b, Iterator e)
{ {
iterator end_(this->end()); iterator iend(this->end());
for (; b != e; ++b) for (; b != e; ++b)
this->insert_equal(end_, *b); this->insert_equal(iend, *b);
} }
//! <b>Requires</b>: value must be an lvalue //! <b>Requires</b>: value must be an lvalue
@@ -696,9 +696,9 @@ class treap_impl
void insert_unique(Iterator b, Iterator e) void insert_unique(Iterator b, Iterator e)
{ {
if(this->empty()){ if(this->empty()){
iterator end_(this->end()); iterator iend(this->end());
for (; b != e; ++b) for (; b != e; ++b)
this->insert_unique(end_, *b); this->insert_unique(iend, *b);
} }
else{ else{
for (; b != e; ++b) for (; b != e; ++b)
@@ -1879,4 +1879,4 @@ class treap
#include <boost/intrusive/detail/config_end.hpp> #include <boost/intrusive/detail/config_end.hpp>
#endif //BOOST_INTRUSIVE_TRIE_HPP #endif //BOOST_INTRUSIVE_TREAP_HPP

View File

@@ -87,9 +87,9 @@ class treap_set_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor of the value_compare object throws. //! or the copy constructor of the value_compare object throws.
treap_set_impl( const value_compare &cmp = value_compare() explicit treap_set_impl( const value_compare &cmp = value_compare()
, const priority_compare &pcmp = priority_compare() , const priority_compare &pcmp = priority_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: tree_(cmp, pcmp, v_traits) : tree_(cmp, pcmp, v_traits)
{} {}
@@ -1498,9 +1498,9 @@ class treap_multiset_impl
//! <b>Throws</b>: If value_traits::node_traits::node //! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor of the value_compare/priority_compare objects throw. //! or the copy constructor of the value_compare/priority_compare objects throw.
treap_multiset_impl( const value_compare &cmp = value_compare() explicit treap_multiset_impl( const value_compare &cmp = value_compare()
, const priority_compare &pcmp = priority_compare() , const priority_compare &pcmp = priority_compare()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: tree_(cmp, pcmp, v_traits) : tree_(cmp, pcmp, v_traits)
{} {}

View File

@@ -122,10 +122,10 @@ class unordered_set_impl
//! //!
//! <b>Notes</b>: buckets array must be disposed only after //! <b>Notes</b>: buckets array must be disposed only after
//! *this is disposed. //! *this is disposed.
unordered_set_impl( const bucket_traits &b_traits explicit unordered_set_impl( const bucket_traits &b_traits
, const hasher & hash_func = hasher() , const hasher & hash_func = hasher()
, const key_equal &equal_func = key_equal() , const key_equal &equal_func = key_equal()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: table_(b_traits, hash_func, equal_func, v_traits) : table_(b_traits, hash_func, equal_func, v_traits)
{} {}
@@ -1193,10 +1193,10 @@ class unordered_multiset_impl
//! //!
//! <b>Notes</b>: buckets array must be disposed only after //! <b>Notes</b>: buckets array must be disposed only after
//! *this is disposed. //! *this is disposed.
unordered_multiset_impl ( const bucket_traits &b_traits explicit unordered_multiset_impl ( const bucket_traits &b_traits
, const hasher & hash_func = hasher() , const hasher & hash_func = hasher()
, const key_equal &equal_func = key_equal() , const key_equal &equal_func = key_equal()
, const value_traits &v_traits = value_traits()) , const value_traits &v_traits = value_traits())
: table_(b_traits, hash_func, equal_func, v_traits) : table_(b_traits, hash_func, equal_func, v_traits)
{} {}