no message

[SVN r37976]
This commit is contained in:
Ion Gaztañaga
2007-06-12 17:13:44 +00:00
parent a574da08ed
commit ad5dcdf8b3
8 changed files with 94 additions and 87 deletions

View File

@@ -8,9 +8,9 @@
# 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 ;
doxygen intrusive_doxygen
@@ -28,7 +28,7 @@ doxygen intrusive_doxygen
xml intrusive_xml : intrusive.qbk ;
boostbook standalone
boostbook intrusive
:
intrusive_xml
intrusive_doxygen

View File

@@ -2393,8 +2393,11 @@ all the objects to be inserted in intrusive containers in containers like `std::
* Visual 7.1/WinXP
* Visual 8.0/WinXP
* GCC 4.1.1/MinGW
* GCC 3.4.4/Cygwin
* Intel 9.1/WinXP
* GCC 4.1.2/Linux
* Codewarrior 9.4/WinXP
* GCC 3.4.3 Solaris 11
[endsect]

View File

@@ -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.
#if defined(BOOST_MSVC) || defined(__GNUC__) || \
defined(BOOST_INTEL) || defined(__HP_aCC) || \
defined(__EDG_VERSION__)
//This works with gcc, msvc, edg, ac++
defined(BOOST_INTEL) || defined(__HP_aCC)
//This works with gcc, msvc, ac++
return *(const std::size_t*)(const void*)&ptr_to_member;
#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;
#endif
}

View File

@@ -26,6 +26,7 @@
#include <boost/type_traits/is_convertible.hpp>
#endif
#include <boost/intrusive/pointer_plus_bit.hpp>
#include <boost/type_traits/alignment_of.hpp>
namespace boost {
namespace intrusive {
@@ -170,10 +171,8 @@ struct rbtree_node_traits
: public rbtree_node_traits_dispatch
<VoidPointer
,has_pointer_plus_bit
< typename pointer_to_other
<VoidPointer
, compact_rbtree_node<VoidPointer>
>::type
<VoidPointer, boost::alignment_of<compact_rbtree_node<VoidPointer>
>::value
>::value
>
{};

View File

@@ -648,20 +648,27 @@ class hashtable
try{
size_type n = 0;
bool same_buffer = old_buckets == new_buckets;
//If we are shrinking the bucket array, just rehash the last nodes
if(same_buffer && (old_buckets_len > new_buckets_len)){
const bool same_buffer = old_buckets == new_buckets;
//If the new bucket length is a common factor
//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;
}
//Iterate through nodes
for(; n < old_buckets_len; ++n){
bucket_type &old_bucket = old_buckets[n];
if(!fast_shrink){
local_iterator before_i(old_bucket.before_begin());
local_iterator end(old_bucket.end());
local_iterator i(old_bucket.begin());
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(same_buffer && new_n == n){
++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_len() = new_buckets_len;

View File

@@ -116,7 +116,7 @@ class list
list()
{
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.
@@ -131,7 +131,7 @@ class list
list(Iterator b, Iterator e)
{
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);
}
@@ -166,7 +166,7 @@ class list
node_ptr to_insert = ValueTraits::to_node_ptr(value);
if(safemode_or_autounlink)
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();
}
@@ -185,7 +185,7 @@ class list
node_ptr to_insert = ValueTraits::to_node_ptr(value);
if(safemode_or_autounlink)
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();
}
@@ -199,7 +199,7 @@ class list
//! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element.
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);
size_traits::decrement();
if(safemode_or_autounlink)
@@ -220,7 +220,7 @@ class list
template<class 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);
size_traits::decrement();
if(safemode_or_autounlink)
@@ -238,7 +238,7 @@ class list
//! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element.
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);
size_traits::decrement();
if(safemode_or_autounlink)
@@ -259,7 +259,7 @@ class list
template<class 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);
size_traits::decrement();
if(safemode_or_autounlink)
@@ -273,7 +273,7 @@ class list
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -281,7 +281,7 @@ class list
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -289,7 +289,7 @@ class list
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -297,7 +297,7 @@ class list
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -305,7 +305,7 @@ class list
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -321,7 +321,7 @@ class list
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -329,7 +329,7 @@ class list
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -345,7 +345,7 @@ class list
//!
//! <b>Complexity</b>: Constant.
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
//! of the reversed list.
@@ -436,7 +436,7 @@ class list
if(ConstantTimeSize)
return size_traits::get_size();
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.
@@ -447,7 +447,7 @@ class list
//!
//! <b>Note</b>: Does not affect the validity of iterators and references.
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.
//!
@@ -458,7 +458,7 @@ class list
//! <b>Note</b>: Does not affect the validity of iterators and references.
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){
size_type backup = size_traits::get_size();
size_traits::set_size(other.get_size());
@@ -479,7 +479,7 @@ class list
{
//Null shift, nothing to do
if(!n) return;
node_ptr root = get_root_node();
node_ptr root = this->get_root_node();
node_ptr last = node_traits::get_previous(root);
//size() == 0 or 1, nothing to do
if(last == node_traits::get_next(root)) return;
@@ -505,7 +505,7 @@ class list
{
//Null shift, nothing to do
if(!n) return;
node_ptr root = get_root_node();
node_ptr root = this->get_root_node();
node_ptr first = node_traits::get_next(root);
//size() == 0 or 1, nothing to do
if(first == node_traits::get_previous(root)) return;
@@ -636,7 +636,7 @@ class list
this->erase(this->begin(), this->end());
}
else{
node_algorithms::init(get_root_node());
node_algorithms::init(this->get_root_node());
size_traits::set_size(size_type(0));
}
}
@@ -898,8 +898,8 @@ class list
template<class Predicate>
void sort(Predicate p)
{
if(node_traits::get_next(get_root_node())
!= node_traits::get_previous(get_root_node())){
if(node_traits::get_next(this->get_root_node())
!= node_traits::get_previous(this->get_root_node())){
list carry;
list counter[64];
int fill = 0;
@@ -975,7 +975,7 @@ class list
//!
//! <b>Note</b>: Iterators and references are not invalidated
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.
//! No destructors are called.

View File

@@ -13,9 +13,6 @@
#ifndef 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 intrusive {
@@ -23,7 +20,7 @@ namespace intrusive {
//!can embed an extra bit of information if
//!it's going to be used to point to objects
//!with an alignment of "Alignment" bytes.
template<class Pointer>
template<class VoidPointer, std::size_t Alignment>
struct has_pointer_plus_bit
{
enum { value = false };
@@ -32,11 +29,10 @@ struct has_pointer_plus_bit
//!This is an specialization for raw pointers.
//!Raw pointers can embed an extra bit in the lower bit
//!if the alignment is multiple of 2.
template<class T>
struct has_pointer_plus_bit<T*>
template<std::size_t N>
struct has_pointer_plus_bit<void*, N>
{
enum { value = (boost::alignment_of<T>::value % 2u) == 0 };
enum { value = N % 2u == 0 };
};
//!This is class that is supposed to have static methods
@@ -57,9 +53,6 @@ struct pointer_plus_bit<T*>
{
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)
{ return pointer(std::size_t(n) & std::size_t(~1u)); }

View File

@@ -137,7 +137,7 @@ class slist
slist()
{
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.
@@ -152,7 +152,7 @@ class slist
slist(Iterator b, Iterator e)
{
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);
}
@@ -182,7 +182,7 @@ class slist
this->erase_after(this->before_begin(), this->end());
}
else{
node_algorithms::init(get_root_node());
node_algorithms::init(this->get_root_node());
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.
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)
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();
}
@@ -230,8 +230,8 @@ class slist
//! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element.
void pop_front()
{
node_ptr to_erase = node_traits::get_next(get_root_node());
node_algorithms::unlink_after(get_root_node());
node_ptr to_erase = node_traits::get_next(this->get_root_node());
node_algorithms::unlink_after(this->get_root_node());
size_traits::decrement();
if(safemode_or_autounlink)
node_algorithms::init(to_erase);
@@ -250,7 +250,7 @@ class slist
template<class 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();
destroyer(ValueTraits::to_value_ptr(to_erase));
}
@@ -261,7 +261,7 @@ class slist
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -269,7 +269,7 @@ class slist
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -277,7 +277,7 @@ class slist
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -285,7 +285,7 @@ class slist
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -293,7 +293,7 @@ class slist
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -301,7 +301,7 @@ class slist
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -309,7 +309,7 @@ class slist
//!
//! <b>Complexity</b>: Constant.
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.
//!
@@ -317,7 +317,7 @@ class slist
//!
//! <b>Complexity</b>: Constant.
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
//! before the first element. Equivalent to "end()"
@@ -381,7 +381,7 @@ class slist
if(ConstantTimeSize)
return size_traits::get_size();
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.
@@ -392,7 +392,7 @@ class slist
//!
//! <b>Note</b>: Does not affect the validity of iterators and references.
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.
//!
@@ -403,7 +403,7 @@ class slist
//! <b>Note</b>: Does not affect the validity of iterators and references.
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){
size_type backup = size_traits::get_size();
size_traits::set_size(other.get_size());
@@ -424,7 +424,7 @@ class slist
{
//Null shift, nothing to do
if(!n) return;
node_ptr root = get_root_node();
node_ptr root = this->get_root_node();
node_ptr first = node_traits::get_next(root);
//size() == 0 or 1, nothing to do
@@ -474,7 +474,7 @@ class slist
{
//Null shift, nothing to do
if(!n) return;
node_ptr root = get_root_node();
node_ptr root = this->get_root_node();
node_ptr first = node_traits::get_next(root);
//size() == 0 or 1, nothing to do
@@ -1029,7 +1029,7 @@ class slist
template<class Predicate>
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()) {
slist carry;
slist counter[64];
@@ -1159,7 +1159,7 @@ class slist
//!
//! <b>Note</b>: Iterators and references are not invalidated
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.
//! No destructors are called.