forked from boostorg/intrusive
no message
[SVN r37976]
This commit is contained in:
@@ -8,9 +8,9 @@
|
|||||||
# See http://www.boost.org/libs/intrusive for documentation.
|
# See http://www.boost.org/libs/intrusive for documentation.
|
||||||
|
|
||||||
|
|
||||||
project boost/intrusive/libs/doc ;
|
project boost/intrusive/doc ;
|
||||||
|
|
||||||
import doxygen ;
|
import boostbook : boostbook ;
|
||||||
import quickbook ;
|
import quickbook ;
|
||||||
|
|
||||||
doxygen intrusive_doxygen
|
doxygen intrusive_doxygen
|
||||||
@@ -28,7 +28,7 @@ doxygen intrusive_doxygen
|
|||||||
|
|
||||||
xml intrusive_xml : intrusive.qbk ;
|
xml intrusive_xml : intrusive.qbk ;
|
||||||
|
|
||||||
boostbook standalone
|
boostbook intrusive
|
||||||
:
|
:
|
||||||
intrusive_xml
|
intrusive_xml
|
||||||
intrusive_doxygen
|
intrusive_doxygen
|
||||||
|
@@ -2393,8 +2393,11 @@ all the objects to be inserted in intrusive containers in containers like `std::
|
|||||||
* Visual 7.1/WinXP
|
* Visual 7.1/WinXP
|
||||||
* Visual 8.0/WinXP
|
* Visual 8.0/WinXP
|
||||||
* GCC 4.1.1/MinGW
|
* GCC 4.1.1/MinGW
|
||||||
|
* GCC 3.4.4/Cygwin
|
||||||
* Intel 9.1/WinXP
|
* Intel 9.1/WinXP
|
||||||
* GCC 4.1.2/Linux
|
* GCC 4.1.2/Linux
|
||||||
|
* Codewarrior 9.4/WinXP
|
||||||
|
* GCC 3.4.3 Solaris 11
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@@ -23,12 +23,11 @@ std::size_t offset_from_pointer_to_member(const Member Parent::* ptr_to_member)
|
|||||||
{
|
{
|
||||||
//The implementation of a pointer to member is compiler dependent.
|
//The implementation of a pointer to member is compiler dependent.
|
||||||
#if defined(BOOST_MSVC) || defined(__GNUC__) || \
|
#if defined(BOOST_MSVC) || defined(__GNUC__) || \
|
||||||
defined(BOOST_INTEL) || defined(__HP_aCC) || \
|
defined(BOOST_INTEL) || defined(__HP_aCC)
|
||||||
defined(__EDG_VERSION__)
|
//This works with gcc, msvc, ac++
|
||||||
//This works with gcc, msvc, edg, ac++
|
|
||||||
return *(const std::size_t*)(const void*)&ptr_to_member;
|
return *(const std::size_t*)(const void*)&ptr_to_member;
|
||||||
#else
|
#else
|
||||||
//This is the traditional C-front approach: CW 9.4, dmc
|
//This is the traditional C-front approach: __MWERKS__, __DMC__, __SUNPRO_CC
|
||||||
return *(const std::size_t*)(const void*)&ptr_to_member - 1;
|
return *(const std::size_t*)(const void*)&ptr_to_member - 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include <boost/type_traits/is_convertible.hpp>
|
#include <boost/type_traits/is_convertible.hpp>
|
||||||
#endif
|
#endif
|
||||||
#include <boost/intrusive/pointer_plus_bit.hpp>
|
#include <boost/intrusive/pointer_plus_bit.hpp>
|
||||||
|
#include <boost/type_traits/alignment_of.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace intrusive {
|
namespace intrusive {
|
||||||
@@ -170,10 +171,8 @@ struct rbtree_node_traits
|
|||||||
: public rbtree_node_traits_dispatch
|
: public rbtree_node_traits_dispatch
|
||||||
<VoidPointer
|
<VoidPointer
|
||||||
,has_pointer_plus_bit
|
,has_pointer_plus_bit
|
||||||
< typename pointer_to_other
|
<VoidPointer, boost::alignment_of<compact_rbtree_node<VoidPointer>
|
||||||
<VoidPointer
|
>::value
|
||||||
, compact_rbtree_node<VoidPointer>
|
|
||||||
>::type
|
|
||||||
>::value
|
>::value
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
|
@@ -648,20 +648,27 @@ class hashtable
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
size_type n = 0;
|
size_type n = 0;
|
||||||
bool same_buffer = old_buckets == new_buckets;
|
const bool same_buffer = old_buckets == new_buckets;
|
||||||
//If we are shrinking the bucket array, just rehash the last nodes
|
//If the new bucket length is a common factor
|
||||||
if(same_buffer && (old_buckets_len > new_buckets_len)){
|
//of the old one we can avoid hash calculations.
|
||||||
|
const bool fast_shrink = (old_buckets_len > new_buckets_len) &&
|
||||||
|
(old_buckets_len % new_buckets_len) == 0;
|
||||||
|
//If we are shrinking the same bucket array and it's
|
||||||
|
//is a fast shrink, just rehash the last nodes
|
||||||
|
if(same_buffer && fast_shrink){
|
||||||
n = new_buckets_len;
|
n = new_buckets_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Iterate through nodes
|
//Iterate through nodes
|
||||||
for(; n < old_buckets_len; ++n){
|
for(; n < old_buckets_len; ++n){
|
||||||
bucket_type &old_bucket = old_buckets[n];
|
bucket_type &old_bucket = old_buckets[n];
|
||||||
|
|
||||||
|
if(!fast_shrink){
|
||||||
local_iterator before_i(old_bucket.before_begin());
|
local_iterator before_i(old_bucket.before_begin());
|
||||||
local_iterator end(old_bucket.end());
|
local_iterator end(old_bucket.end());
|
||||||
local_iterator i(old_bucket.begin());
|
local_iterator i(old_bucket.begin());
|
||||||
for(;i != end; ++i){
|
for(;i != end; ++i){
|
||||||
size_type new_n = this->priv_hasher()(*i) % new_buckets_len;
|
const size_type new_n = (this->priv_hasher()(*i) % new_buckets_len);
|
||||||
//If this is a buffer expansion don't move if it's not necessary
|
//If this is a buffer expansion don't move if it's not necessary
|
||||||
if(same_buffer && new_n == n){
|
if(same_buffer && new_n == n){
|
||||||
++before_i;
|
++before_i;
|
||||||
@@ -673,6 +680,12 @@ class hashtable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
const size_type new_n = n % new_buckets_len;
|
||||||
|
bucket_type &new_b = new_buckets[new_n];
|
||||||
|
new_b.splice_after(new_b.before_begin(), old_bucket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->priv_buckets() = new_buckets;
|
this->priv_buckets() = new_buckets;
|
||||||
this->priv_buckets_len() = new_buckets_len;
|
this->priv_buckets_len() = new_buckets_len;
|
||||||
|
@@ -116,7 +116,7 @@ class list
|
|||||||
list()
|
list()
|
||||||
{
|
{
|
||||||
size_traits::set_size(size_type(0));
|
size_traits::set_size(size_type(0));
|
||||||
node_algorithms::init(get_root_node());
|
node_algorithms::init(this->get_root_node());
|
||||||
}
|
}
|
||||||
|
|
||||||
//! <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.
|
||||||
@@ -131,7 +131,7 @@ class list
|
|||||||
list(Iterator b, Iterator e)
|
list(Iterator b, Iterator e)
|
||||||
{
|
{
|
||||||
size_traits::set_size(size_type(0));
|
size_traits::set_size(size_type(0));
|
||||||
node_algorithms::init(get_root_node());
|
node_algorithms::init(this->get_root_node());
|
||||||
this->insert(this->end(), b, e);
|
this->insert(this->end(), b, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ class list
|
|||||||
node_ptr to_insert = ValueTraits::to_node_ptr(value);
|
node_ptr to_insert = ValueTraits::to_node_ptr(value);
|
||||||
if(safemode_or_autounlink)
|
if(safemode_or_autounlink)
|
||||||
BOOST_ASSERT(node_algorithms::unique(to_insert));
|
BOOST_ASSERT(node_algorithms::unique(to_insert));
|
||||||
node_algorithms::link_before(get_root_node(), to_insert);
|
node_algorithms::link_before(this->get_root_node(), to_insert);
|
||||||
size_traits::increment();
|
size_traits::increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ class list
|
|||||||
node_ptr to_insert = ValueTraits::to_node_ptr(value);
|
node_ptr to_insert = ValueTraits::to_node_ptr(value);
|
||||||
if(safemode_or_autounlink)
|
if(safemode_or_autounlink)
|
||||||
BOOST_ASSERT(node_algorithms::unique(to_insert));
|
BOOST_ASSERT(node_algorithms::unique(to_insert));
|
||||||
node_algorithms::link_before(node_traits::get_next(get_root_node()), to_insert);
|
node_algorithms::link_before(node_traits::get_next(this->get_root_node()), to_insert);
|
||||||
size_traits::increment();
|
size_traits::increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ class list
|
|||||||
//! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element.
|
//! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element.
|
||||||
void pop_back()
|
void pop_back()
|
||||||
{
|
{
|
||||||
node_ptr to_erase = node_traits::get_previous(get_root_node());
|
node_ptr to_erase = node_traits::get_previous(this->get_root_node());
|
||||||
node_algorithms::unlink(to_erase);
|
node_algorithms::unlink(to_erase);
|
||||||
size_traits::decrement();
|
size_traits::decrement();
|
||||||
if(safemode_or_autounlink)
|
if(safemode_or_autounlink)
|
||||||
@@ -220,7 +220,7 @@ class list
|
|||||||
template<class Destroyer>
|
template<class Destroyer>
|
||||||
void pop_back_and_destroy(Destroyer destroyer)
|
void pop_back_and_destroy(Destroyer destroyer)
|
||||||
{
|
{
|
||||||
node_ptr to_erase = node_traits::get_previous(get_root_node());
|
node_ptr to_erase = node_traits::get_previous(this->get_root_node());
|
||||||
node_algorithms::unlink(to_erase);
|
node_algorithms::unlink(to_erase);
|
||||||
size_traits::decrement();
|
size_traits::decrement();
|
||||||
if(safemode_or_autounlink)
|
if(safemode_or_autounlink)
|
||||||
@@ -238,7 +238,7 @@ class list
|
|||||||
//! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element.
|
//! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element.
|
||||||
void pop_front()
|
void pop_front()
|
||||||
{
|
{
|
||||||
node_ptr to_erase = node_traits::get_next(get_root_node());
|
node_ptr to_erase = node_traits::get_next(this->get_root_node());
|
||||||
node_algorithms::unlink(to_erase);
|
node_algorithms::unlink(to_erase);
|
||||||
size_traits::decrement();
|
size_traits::decrement();
|
||||||
if(safemode_or_autounlink)
|
if(safemode_or_autounlink)
|
||||||
@@ -259,7 +259,7 @@ class list
|
|||||||
template<class Destroyer>
|
template<class Destroyer>
|
||||||
void pop_front_and_destroy(Destroyer destroyer)
|
void pop_front_and_destroy(Destroyer destroyer)
|
||||||
{
|
{
|
||||||
node_ptr to_erase = node_traits::get_next(get_root_node());
|
node_ptr to_erase = node_traits::get_next(this->get_root_node());
|
||||||
node_algorithms::unlink(to_erase);
|
node_algorithms::unlink(to_erase);
|
||||||
size_traits::decrement();
|
size_traits::decrement();
|
||||||
if(safemode_or_autounlink)
|
if(safemode_or_autounlink)
|
||||||
@@ -273,7 +273,7 @@ class list
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
reference front()
|
reference front()
|
||||||
{ return *ValueTraits::to_value_ptr(node_traits::get_next(get_root_node())); }
|
{ return *ValueTraits::to_value_ptr(node_traits::get_next(this->get_root_node())); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns a const_reference to the first element of the list.
|
//! <b>Effects</b>: Returns a const_reference to the first element of the list.
|
||||||
//!
|
//!
|
||||||
@@ -281,7 +281,7 @@ class list
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
const_reference front() const
|
const_reference front() const
|
||||||
{ return *ValueTraits::to_value_ptr(uncast(node_traits::get_next(get_root_node()))); }
|
{ return *ValueTraits::to_value_ptr(uncast(node_traits::get_next(this->get_root_node()))); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns a reference to the last element of the list.
|
//! <b>Effects</b>: Returns a reference to the last element of the list.
|
||||||
//!
|
//!
|
||||||
@@ -289,7 +289,7 @@ class list
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
reference back()
|
reference back()
|
||||||
{ return *ValueTraits::to_value_ptr(node_traits::get_previous(get_root_node())); }
|
{ return *ValueTraits::to_value_ptr(node_traits::get_previous(this->get_root_node())); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns a const_reference to the last element of the list.
|
//! <b>Effects</b>: Returns a const_reference to the last element of the list.
|
||||||
//!
|
//!
|
||||||
@@ -297,7 +297,7 @@ class list
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
const_reference back() const
|
const_reference back() const
|
||||||
{ return *ValueTraits::to_value_ptr(uncast(node_traits::get_previous(get_root_node()))); }
|
{ return *ValueTraits::to_value_ptr(uncast(node_traits::get_previous(this->get_root_node()))); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns an iterator to the first element contained in the list.
|
//! <b>Effects</b>: Returns an iterator to the first element contained in the list.
|
||||||
//!
|
//!
|
||||||
@@ -305,7 +305,7 @@ class list
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
iterator begin()
|
iterator begin()
|
||||||
{ return iterator(node_traits::get_next(get_root_node())); }
|
{ return iterator(node_traits::get_next(this->get_root_node())); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
|
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
|
||||||
//!
|
//!
|
||||||
@@ -321,7 +321,7 @@ class list
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
const_iterator cbegin() const
|
const_iterator cbegin() const
|
||||||
{ return const_iterator(node_traits::get_next(get_root_node())); }
|
{ return const_iterator(node_traits::get_next(this->get_root_node())); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns an iterator to the end of the list.
|
//! <b>Effects</b>: Returns an iterator to the end of the list.
|
||||||
//!
|
//!
|
||||||
@@ -329,7 +329,7 @@ class list
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
iterator end()
|
iterator end()
|
||||||
{ return iterator(get_root_node()); }
|
{ return iterator(this->get_root_node()); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
|
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
|
||||||
//!
|
//!
|
||||||
@@ -345,7 +345,7 @@ class list
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
const_iterator cend() const
|
const_iterator cend() const
|
||||||
{ return const_iterator(uncast(get_root_node())); }
|
{ return const_iterator(uncast(this->get_root_node())); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
|
//! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
|
||||||
//! of the reversed list.
|
//! of the reversed list.
|
||||||
@@ -436,7 +436,7 @@ class list
|
|||||||
if(ConstantTimeSize)
|
if(ConstantTimeSize)
|
||||||
return size_traits::get_size();
|
return size_traits::get_size();
|
||||||
else
|
else
|
||||||
return node_algorithms::count(get_root_node()) - 1;
|
return node_algorithms::count(this->get_root_node()) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns true if the list contains no elements.
|
//! <b>Effects</b>: Returns true if the list contains no elements.
|
||||||
@@ -447,7 +447,7 @@ class list
|
|||||||
//!
|
//!
|
||||||
//! <b>Note</b>: Does not affect the validity of iterators and references.
|
//! <b>Note</b>: Does not affect the validity of iterators and references.
|
||||||
bool empty() const
|
bool empty() const
|
||||||
{ return node_algorithms::unique(get_root_node()); }
|
{ return node_algorithms::unique(this->get_root_node()); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Swaps the elements of x and *this.
|
//! <b>Effects</b>: Swaps the elements of x and *this.
|
||||||
//!
|
//!
|
||||||
@@ -458,7 +458,7 @@ class list
|
|||||||
//! <b>Note</b>: Does not affect the validity of iterators and references.
|
//! <b>Note</b>: Does not affect the validity of iterators and references.
|
||||||
void swap(list& other)
|
void swap(list& other)
|
||||||
{
|
{
|
||||||
node_algorithms::swap_nodes(get_root_node(), other.get_root_node());
|
node_algorithms::swap_nodes(this->get_root_node(), other.get_root_node());
|
||||||
if(ConstantTimeSize){
|
if(ConstantTimeSize){
|
||||||
size_type backup = size_traits::get_size();
|
size_type backup = size_traits::get_size();
|
||||||
size_traits::set_size(other.get_size());
|
size_traits::set_size(other.get_size());
|
||||||
@@ -479,7 +479,7 @@ class list
|
|||||||
{
|
{
|
||||||
//Null shift, nothing to do
|
//Null shift, nothing to do
|
||||||
if(!n) return;
|
if(!n) return;
|
||||||
node_ptr root = get_root_node();
|
node_ptr root = this->get_root_node();
|
||||||
node_ptr last = node_traits::get_previous(root);
|
node_ptr last = node_traits::get_previous(root);
|
||||||
//size() == 0 or 1, nothing to do
|
//size() == 0 or 1, nothing to do
|
||||||
if(last == node_traits::get_next(root)) return;
|
if(last == node_traits::get_next(root)) return;
|
||||||
@@ -505,7 +505,7 @@ class list
|
|||||||
{
|
{
|
||||||
//Null shift, nothing to do
|
//Null shift, nothing to do
|
||||||
if(!n) return;
|
if(!n) return;
|
||||||
node_ptr root = get_root_node();
|
node_ptr root = this->get_root_node();
|
||||||
node_ptr first = node_traits::get_next(root);
|
node_ptr first = node_traits::get_next(root);
|
||||||
//size() == 0 or 1, nothing to do
|
//size() == 0 or 1, nothing to do
|
||||||
if(first == node_traits::get_previous(root)) return;
|
if(first == node_traits::get_previous(root)) return;
|
||||||
@@ -636,7 +636,7 @@ class list
|
|||||||
this->erase(this->begin(), this->end());
|
this->erase(this->begin(), this->end());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
node_algorithms::init(get_root_node());
|
node_algorithms::init(this->get_root_node());
|
||||||
size_traits::set_size(size_type(0));
|
size_traits::set_size(size_type(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -898,8 +898,8 @@ class list
|
|||||||
template<class Predicate>
|
template<class Predicate>
|
||||||
void sort(Predicate p)
|
void sort(Predicate p)
|
||||||
{
|
{
|
||||||
if(node_traits::get_next(get_root_node())
|
if(node_traits::get_next(this->get_root_node())
|
||||||
!= node_traits::get_previous(get_root_node())){
|
!= node_traits::get_previous(this->get_root_node())){
|
||||||
list carry;
|
list carry;
|
||||||
list counter[64];
|
list counter[64];
|
||||||
int fill = 0;
|
int fill = 0;
|
||||||
@@ -975,7 +975,7 @@ class list
|
|||||||
//!
|
//!
|
||||||
//! <b>Note</b>: Iterators and references are not invalidated
|
//! <b>Note</b>: Iterators and references are not invalidated
|
||||||
void reverse()
|
void reverse()
|
||||||
{ node_algorithms::reverse(get_root_node()); }
|
{ node_algorithms::reverse(this->get_root_node()); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Removes all the elements that compare equal to value.
|
//! <b>Effects</b>: Removes all the elements that compare equal to value.
|
||||||
//! No destructors are called.
|
//! No destructors are called.
|
||||||
|
@@ -13,9 +13,6 @@
|
|||||||
#ifndef BOOST_INTRUSIVE_POINTER_PLUS_BIT_HPP
|
#ifndef BOOST_INTRUSIVE_POINTER_PLUS_BIT_HPP
|
||||||
#define BOOST_INTRUSIVE_POINTER_PLUS_BIT_HPP
|
#define BOOST_INTRUSIVE_POINTER_PLUS_BIT_HPP
|
||||||
|
|
||||||
#include<boost/type_traits/alignment_of.hpp>
|
|
||||||
#include<boost/static_assert.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace intrusive {
|
namespace intrusive {
|
||||||
|
|
||||||
@@ -23,7 +20,7 @@ namespace intrusive {
|
|||||||
//!can embed an extra bit of information if
|
//!can embed an extra bit of information if
|
||||||
//!it's going to be used to point to objects
|
//!it's going to be used to point to objects
|
||||||
//!with an alignment of "Alignment" bytes.
|
//!with an alignment of "Alignment" bytes.
|
||||||
template<class Pointer>
|
template<class VoidPointer, std::size_t Alignment>
|
||||||
struct has_pointer_plus_bit
|
struct has_pointer_plus_bit
|
||||||
{
|
{
|
||||||
enum { value = false };
|
enum { value = false };
|
||||||
@@ -32,11 +29,10 @@ struct has_pointer_plus_bit
|
|||||||
//!This is an specialization for raw pointers.
|
//!This is an specialization for raw pointers.
|
||||||
//!Raw pointers can embed an extra bit in the lower bit
|
//!Raw pointers can embed an extra bit in the lower bit
|
||||||
//!if the alignment is multiple of 2.
|
//!if the alignment is multiple of 2.
|
||||||
|
template<std::size_t N>
|
||||||
template<class T>
|
struct has_pointer_plus_bit<void*, N>
|
||||||
struct has_pointer_plus_bit<T*>
|
|
||||||
{
|
{
|
||||||
enum { value = (boost::alignment_of<T>::value % 2u) == 0 };
|
enum { value = N % 2u == 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
//!This is class that is supposed to have static methods
|
//!This is class that is supposed to have static methods
|
||||||
@@ -57,9 +53,6 @@ struct pointer_plus_bit<T*>
|
|||||||
{
|
{
|
||||||
typedef T* pointer;
|
typedef T* pointer;
|
||||||
|
|
||||||
//Check that the pointer can embed the bit
|
|
||||||
BOOST_STATIC_ASSERT((has_pointer_plus_bit<T*>::value));
|
|
||||||
|
|
||||||
static pointer get_pointer(pointer n)
|
static pointer get_pointer(pointer n)
|
||||||
{ return pointer(std::size_t(n) & std::size_t(~1u)); }
|
{ return pointer(std::size_t(n) & std::size_t(~1u)); }
|
||||||
|
|
||||||
|
@@ -137,7 +137,7 @@ class slist
|
|||||||
slist()
|
slist()
|
||||||
{
|
{
|
||||||
size_traits::set_size(size_type(0));
|
size_traits::set_size(size_type(0));
|
||||||
node_algorithms::init(get_root_node());
|
node_algorithms::init(this->get_root_node());
|
||||||
}
|
}
|
||||||
|
|
||||||
//! <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.
|
||||||
@@ -152,7 +152,7 @@ class slist
|
|||||||
slist(Iterator b, Iterator e)
|
slist(Iterator b, Iterator e)
|
||||||
{
|
{
|
||||||
size_traits::set_size(size_type(0));
|
size_traits::set_size(size_type(0));
|
||||||
node_algorithms::init(get_root_node());
|
node_algorithms::init(this->get_root_node());
|
||||||
insert_after(before_begin(), b, e);
|
insert_after(before_begin(), b, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ class slist
|
|||||||
this->erase_after(this->before_begin(), this->end());
|
this->erase_after(this->before_begin(), this->end());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
node_algorithms::init(get_root_node());
|
node_algorithms::init(this->get_root_node());
|
||||||
size_traits::set_size(size_type(0));
|
size_traits::set_size(size_type(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,10 +213,10 @@ class slist
|
|||||||
//! <b>Note</b>: Does not affect the validity of iterators and references.
|
//! <b>Note</b>: Does not affect the validity of iterators and references.
|
||||||
void push_front(reference value)
|
void push_front(reference value)
|
||||||
{
|
{
|
||||||
node_ptr to_insert(ValueTraits::to_node_ptr(value));
|
node_ptr to_insert = ValueTraits::to_node_ptr(value);
|
||||||
if(safemode_or_autounlink)
|
if(safemode_or_autounlink)
|
||||||
BOOST_ASSERT(node_algorithms::unique(to_insert));
|
BOOST_ASSERT(node_algorithms::unique(to_insert));
|
||||||
node_algorithms::link_after(get_root_node(), to_insert);
|
node_algorithms::link_after(this->get_root_node(), to_insert);
|
||||||
size_traits::increment();
|
size_traits::increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,8 +230,8 @@ class slist
|
|||||||
//! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element.
|
//! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element.
|
||||||
void pop_front()
|
void pop_front()
|
||||||
{
|
{
|
||||||
node_ptr to_erase = node_traits::get_next(get_root_node());
|
node_ptr to_erase = node_traits::get_next(this->get_root_node());
|
||||||
node_algorithms::unlink_after(get_root_node());
|
node_algorithms::unlink_after(this->get_root_node());
|
||||||
size_traits::decrement();
|
size_traits::decrement();
|
||||||
if(safemode_or_autounlink)
|
if(safemode_or_autounlink)
|
||||||
node_algorithms::init(to_erase);
|
node_algorithms::init(to_erase);
|
||||||
@@ -250,7 +250,7 @@ class slist
|
|||||||
template<class Destroyer>
|
template<class Destroyer>
|
||||||
void pop_front_and_destroy(Destroyer destroyer)
|
void pop_front_and_destroy(Destroyer destroyer)
|
||||||
{
|
{
|
||||||
node_ptr to_erase = node_traits::get_next(get_root_node());
|
node_ptr to_erase = node_traits::get_next(this->get_root_node());
|
||||||
this->pop_front();
|
this->pop_front();
|
||||||
destroyer(ValueTraits::to_value_ptr(to_erase));
|
destroyer(ValueTraits::to_value_ptr(to_erase));
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ class slist
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
reference front()
|
reference front()
|
||||||
{ return *ValueTraits::to_value_ptr(node_traits::get_next(get_root_node())); }
|
{ return *ValueTraits::to_value_ptr(node_traits::get_next(this->get_root_node())); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns a const_reference to the first element of the list.
|
//! <b>Effects</b>: Returns a const_reference to the first element of the list.
|
||||||
//!
|
//!
|
||||||
@@ -269,7 +269,7 @@ class slist
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
const_reference front() const
|
const_reference front() const
|
||||||
{ return *ValueTraits::to_value_ptr(uncast(node_traits::get_next(get_root_node()))); }
|
{ return *ValueTraits::to_value_ptr(uncast(node_traits::get_next(this->get_root_node()))); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns an iterator to the first element contained in the list.
|
//! <b>Effects</b>: Returns an iterator to the first element contained in the list.
|
||||||
//!
|
//!
|
||||||
@@ -277,7 +277,7 @@ class slist
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
iterator begin()
|
iterator begin()
|
||||||
{ return iterator (node_traits::get_next(get_root_node())); }
|
{ return iterator (node_traits::get_next(this->get_root_node())); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
|
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
|
||||||
//!
|
//!
|
||||||
@@ -285,7 +285,7 @@ class slist
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
const_iterator begin() const
|
const_iterator begin() const
|
||||||
{ return const_iterator (node_traits::get_next(get_root_node())); }
|
{ return const_iterator (node_traits::get_next(this->get_root_node())); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
|
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
|
||||||
//!
|
//!
|
||||||
@@ -293,7 +293,7 @@ class slist
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
const_iterator cbegin() const
|
const_iterator cbegin() const
|
||||||
{ return const_iterator (node_traits::get_next(get_root_node())); }
|
{ return const_iterator (node_traits::get_next(this->get_root_node())); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns an iterator to the end of the list.
|
//! <b>Effects</b>: Returns an iterator to the end of the list.
|
||||||
//!
|
//!
|
||||||
@@ -301,7 +301,7 @@ class slist
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
iterator end()
|
iterator end()
|
||||||
{ return iterator (get_root_node()); }
|
{ return iterator (this->get_root_node()); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
|
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
|
||||||
//!
|
//!
|
||||||
@@ -309,7 +309,7 @@ class slist
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
const_iterator end() const
|
const_iterator end() const
|
||||||
{ return const_iterator (uncast(get_root_node())); }
|
{ return const_iterator (uncast(this->get_root_node())); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
|
//! <b>Effects</b>: Returns a const_iterator to the end of the list.
|
||||||
//!
|
//!
|
||||||
@@ -317,7 +317,7 @@ class slist
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: Constant.
|
//! <b>Complexity</b>: Constant.
|
||||||
const_iterator cend() const
|
const_iterator cend() const
|
||||||
{ return const_iterator (uncast(get_root_node())); }
|
{ return const_iterator (uncast(this->get_root_node())); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns an iterator that points to a position
|
//! <b>Effects</b>: Returns an iterator that points to a position
|
||||||
//! before the first element. Equivalent to "end()"
|
//! before the first element. Equivalent to "end()"
|
||||||
@@ -381,7 +381,7 @@ class slist
|
|||||||
if(ConstantTimeSize)
|
if(ConstantTimeSize)
|
||||||
return size_traits::get_size();
|
return size_traits::get_size();
|
||||||
else
|
else
|
||||||
return node_algorithms::count(get_root_node()) - 1;
|
return node_algorithms::count(this->get_root_node()) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns true if the list contains no elements.
|
//! <b>Effects</b>: Returns true if the list contains no elements.
|
||||||
@@ -392,7 +392,7 @@ class slist
|
|||||||
//!
|
//!
|
||||||
//! <b>Note</b>: Does not affect the validity of iterators and references.
|
//! <b>Note</b>: Does not affect the validity of iterators and references.
|
||||||
bool empty() const
|
bool empty() const
|
||||||
{ return node_algorithms::unique(get_root_node()); }
|
{ return node_algorithms::unique(this->get_root_node()); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Swaps the elements of x and *this.
|
//! <b>Effects</b>: Swaps the elements of x and *this.
|
||||||
//!
|
//!
|
||||||
@@ -403,7 +403,7 @@ class slist
|
|||||||
//! <b>Note</b>: Does not affect the validity of iterators and references.
|
//! <b>Note</b>: Does not affect the validity of iterators and references.
|
||||||
void swap(slist& other)
|
void swap(slist& other)
|
||||||
{
|
{
|
||||||
node_algorithms::swap_nodes(get_root_node(), other.get_root_node());
|
node_algorithms::swap_nodes(this->get_root_node(), other.get_root_node());
|
||||||
if(ConstantTimeSize){
|
if(ConstantTimeSize){
|
||||||
size_type backup = size_traits::get_size();
|
size_type backup = size_traits::get_size();
|
||||||
size_traits::set_size(other.get_size());
|
size_traits::set_size(other.get_size());
|
||||||
@@ -424,7 +424,7 @@ class slist
|
|||||||
{
|
{
|
||||||
//Null shift, nothing to do
|
//Null shift, nothing to do
|
||||||
if(!n) return;
|
if(!n) return;
|
||||||
node_ptr root = get_root_node();
|
node_ptr root = this->get_root_node();
|
||||||
node_ptr first = node_traits::get_next(root);
|
node_ptr first = node_traits::get_next(root);
|
||||||
|
|
||||||
//size() == 0 or 1, nothing to do
|
//size() == 0 or 1, nothing to do
|
||||||
@@ -474,7 +474,7 @@ class slist
|
|||||||
{
|
{
|
||||||
//Null shift, nothing to do
|
//Null shift, nothing to do
|
||||||
if(!n) return;
|
if(!n) return;
|
||||||
node_ptr root = get_root_node();
|
node_ptr root = this->get_root_node();
|
||||||
node_ptr first = node_traits::get_next(root);
|
node_ptr first = node_traits::get_next(root);
|
||||||
|
|
||||||
//size() == 0 or 1, nothing to do
|
//size() == 0 or 1, nothing to do
|
||||||
@@ -1029,7 +1029,7 @@ class slist
|
|||||||
template<class Predicate>
|
template<class Predicate>
|
||||||
void sort(Predicate p)
|
void sort(Predicate p)
|
||||||
{
|
{
|
||||||
if (node_traits::get_next(node_traits::get_next(get_root_node()))
|
if (node_traits::get_next(node_traits::get_next(this->get_root_node()))
|
||||||
!= this->get_root_node()) {
|
!= this->get_root_node()) {
|
||||||
slist carry;
|
slist carry;
|
||||||
slist counter[64];
|
slist counter[64];
|
||||||
@@ -1159,7 +1159,7 @@ class slist
|
|||||||
//!
|
//!
|
||||||
//! <b>Note</b>: Iterators and references are not invalidated
|
//! <b>Note</b>: Iterators and references are not invalidated
|
||||||
void reverse()
|
void reverse()
|
||||||
{ node_algorithms::reverse(get_root_node()); }
|
{ node_algorithms::reverse(this->get_root_node()); }
|
||||||
|
|
||||||
//! <b>Effects</b>: Removes all the elements that compare equal to value.
|
//! <b>Effects</b>: Removes all the elements that compare equal to value.
|
||||||
//! No destructors are called.
|
//! No destructors are called.
|
||||||
|
Reference in New Issue
Block a user