diff -N -dur --strip-trailing-cr old/boost_1_47_0/boost/multi_index/detail/bucket_array.hpp new/boost_1_47_0/boost/multi_index/detail/bucket_array.hpp --- old/boost_1_47_0/boost/multi_index/detail/bucket_array.hpp 2008-07-03 20:51:53.000000000 +0400 +++ new/boost_1_47_0/boost/multi_index/detail/bucket_array.hpp 2011-05-17 15:44:38.000000000 +0400 @@ -16,7 +16,8 @@ #include /* keep it first to prevent nasty warns in MSVC */ #include #include -#include +//#include +//#include #include #include #include @@ -82,18 +83,11 @@ } }; -template +template class bucket_array:public bucket_array_base { - typedef typename prevent_eti< - Allocator, - hashed_index_node_impl< - typename boost::detail::allocator::rebind_to< - Allocator, - char - >::type - > - >::type node_impl_type; + typedef typename prevent_eti::type + node_impl_type; public: typedef typename node_impl_type::pointer pointer; @@ -164,8 +158,9 @@ #endif }; -template -void swap(bucket_array& x,bucket_array& y) +template +void swap(bucket_array& x, + bucket_array& y) { x.swap(y); } @@ -188,9 +183,9 @@ namespace detail{ #endif -template +template inline void load_construct_data( - Archive&,boost::multi_index::detail::bucket_array*, + Archive&,boost::multi_index::detail::bucket_array*, const unsigned int) { throw_exception( diff -N -dur --strip-trailing-cr old/boost_1_47_0/boost/multi_index/detail/hash_index_dbl_node.hpp new/boost_1_47_0/boost/multi_index/detail/hash_index_dbl_node.hpp --- old/boost_1_47_0/boost/multi_index/detail/hash_index_dbl_node.hpp 1970-01-01 03:00:00.000000000 +0300 +++ new/boost_1_47_0/boost/multi_index/detail/hash_index_dbl_node.hpp 2011-05-17 08:40:03.000000000 +0400 @@ -0,0 +1,168 @@ +/* Copyright 2003-2008 Joaquin M Lopez Munoz. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * See http://www.boost.org/libs/multi_index for library home page. + */ + +#ifndef BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_DBL_NODE_HPP +#define BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_DBL_NODE_HPP + +#if defined(_MSC_VER)&&(_MSC_VER>=1200) +#pragma once +#endif + +#include /* keep it first to prevent nasty warns in MSVC */ +#include +#include +#include + +namespace boost{ + +namespace multi_index{ + +namespace detail{ + +/* double-linked node for use by hashed_index */ + +template +struct hashed_index_dbl_node_impl +{ + typedef typename prevent_eti< + Allocator, + typename boost::detail::allocator::rebind_to< + Allocator,hashed_index_dbl_node_impl + >::type + >::type::pointer pointer; + typedef typename prevent_eti< + Allocator, + typename boost::detail::allocator::rebind_to< + Allocator,hashed_index_dbl_node_impl + >::type + >::type::const_pointer const_pointer; + + pointer& next(){return next_;} + pointer next()const{return next_;} + pointer& prev(){return prev_;} + pointer prev()const{return prev_;} + + /* algorithmic stuff */ + + static void increment(pointer& x,pointer bbegin,pointer bend) + { + std::less_equal leq; + + x=x->next(); + if(leq(bbegin,x)&&leq(x,bend)){ /* bucket node */ + do{ + ++x; + }while(x->next()==x); + x=x->next(); + } + } + + static void link(pointer x,pointer pos) + { + x->next()=pos->next(); + pos->next()=x; + x->prev()=pos; + x->next()->prev()=x; + }; + + static void unlink(pointer x) + { + x->prev()->next()=x->next(); + x->next()->prev()=x->prev(); + } + + static pointer prev(pointer x) + { + return x->prev(); + } + + static void unlink_next(pointer x) + { + x->next()=x->next()->next(); + x->next()->prev()=x; + } + +private: + pointer next_; + pointer prev_; +}; + +template +struct hashed_index_dbl_node_trampoline: + prevent_eti< + Super, + hashed_index_dbl_node_impl< + typename boost::detail::allocator::rebind_to< + typename Super::allocator_type, + char + >::type + > + >::type +{ + typedef typename prevent_eti< + Super, + hashed_index_dbl_node_impl< + typename boost::detail::allocator::rebind_to< + typename Super::allocator_type, + char + >::type + > + >::type impl_type; +}; + +template +struct hashed_index_dbl_node:Super,hashed_index_dbl_node_trampoline +{ +private: + typedef hashed_index_dbl_node_trampoline trampoline; + +public: + typedef typename trampoline::impl_type impl_type; + typedef typename trampoline::pointer impl_pointer; + typedef typename trampoline::const_pointer const_impl_pointer; + + impl_pointer impl() + { + return static_cast( + static_cast(static_cast(this))); + } + + const_impl_pointer impl()const + { + return static_cast( + static_cast(static_cast(this))); + } + + static hashed_index_dbl_node* from_impl(impl_pointer x) + { + return static_cast( + static_cast(&*x)); + } + + static const hashed_index_dbl_node* from_impl(const_impl_pointer x) + { + return static_cast( + static_cast(&*x)); + } + + static void increment( + hashed_index_dbl_node*& x,impl_pointer bbegin,impl_pointer bend) + { + impl_pointer xi=x->impl(); + trampoline::increment(xi,bbegin,bend); + x=from_impl(xi); + } +}; + +} /* namespace multi_index::detail */ + +} /* namespace multi_index */ + +} /* namespace boost */ + +#endif diff -N -dur --strip-trailing-cr old/boost_1_47_0/boost/multi_index/hashed_index.hpp new/boost_1_47_0/boost/multi_index/hashed_index.hpp --- old/boost_1_47_0/boost/multi_index/hashed_index.hpp 2011-05-08 15:38:13.000000000 +0400 +++ new/boost_1_47_0/boost/multi_index/hashed_index.hpp 2011-05-25 18:34:52.000000000 +0400 @@ -1,4 +1,4 @@ -/* Copyright 2003-2011 Joaquin M Lopez Munoz. +/* Copyright 2003-2010 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include @@ -67,7 +69,8 @@ template< typename KeyFromValue,typename Hash,typename Pred, - typename SuperMeta,typename TagList,typename Category + typename SuperMeta,typename TagList,typename Category, + template class NodeType > class hashed_index: BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS SuperMeta::type @@ -76,12 +79,18 @@ #if BOOST_WORKAROUND(BOOST_MSVC,<1300) ,public safe_ctr_proxy_impl< hashed_index_iterator< - hashed_index_node, - bucket_array >, - hashed_index > + NodeType, + bucket_array< + typename SuperMeta::type::final_allocator_type, + typename NodeType::impl_type + > + >, + hashed_index > > #else ,public safe_mode::safe_container< - hashed_index > + hashed_index > > #endif #endif @@ -99,14 +108,16 @@ typedef typename SuperMeta::type super; protected: - typedef hashed_index_node< - typename super::node_type> node_type; + typedef NodeType< + typename SuperMeta::type::node_type> node_type; private: typedef typename node_type::impl_type node_impl_type; typedef typename node_impl_type::pointer node_impl_pointer; typedef bucket_array< - typename super::final_allocator_type> bucket_array_type; + typename super::final_allocator_type, + typename NodeType::impl_type + > bucket_array_type; public: /* types */ @@ -196,8 +207,9 @@ * not supposed to be created on their own. No range ctor either. */ - hashed_index& operator=( - const hashed_index& x) + hashed_index& + operator=(const hashed_index< + KeyFromValue,Hash,Pred,SuperMeta,TagList,Category,NodeType>& x) { this->final()=x.final(); return *this; @@ -405,7 +417,8 @@ this->final_clear_(); } - void swap(hashed_index& x) + void swap(hashed_index< + KeyFromValue,Hash,Pred,SuperMeta,TagList,Category,NodeType>& x) { BOOST_MULTI_INDEX_HASHED_INDEX_CHECK_INVARIANT; this->final_swap_(x.final()); @@ -605,14 +618,14 @@ hash(tuples::get<2>(args_list.get_head())), eq(tuples::get<3>(args_list.get_head())), buckets(al,header()->impl(),tuples::get<0>(args_list.get_head())), - mlf(1.0f), + mlf(1.0), first_bucket(buckets.size()) { calculate_max_load(); } - hashed_index( - const hashed_index& x): + hashed_index(const hashed_index< + KeyFromValue,Hash,Pred,SuperMeta,TagList,Category,NodeType>& x): super(x), #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) @@ -663,7 +676,8 @@ #endif void copy_( - const hashed_index& x, + const hashed_index< + KeyFromValue,Hash,Pred,SuperMeta,TagList,Category,NodeType>& x, const copy_map_type& map) { for(node_impl_pointer begin_org=x.buckets.begin(), @@ -757,7 +771,7 @@ } void swap_( - hashed_index& x) + hashed_index& x) { std::swap(key,x.key); std::swap(hash,x.hash); @@ -1094,7 +1108,10 @@ node_impl_pointer bend=buckets.end(); node_impl_pointer pbuc=x->next(); - while(!leq(bbegin,pbuc)||!leq(pbuc,bend))pbuc=pbuc->next(); + /*while(!leq(bbegin,pbuc)||!leq(pbuc,bend))pbuc=pbuc->next();*/ + if(!leq(bbegin,pbuc)||!leq(pbuc,bend)) + pbuc = buckets.at(buckets.position( + hash(key(node_type::from_impl(pbuc)->value())))); if(buc!=static_cast(pbuc-bbegin))return false; node_impl_pointer y=x; @@ -1115,9 +1132,12 @@ node_impl_pointer bend=buckets.end(); node_impl_pointer pbuc=x->next(); - while(!leq(bbegin,pbuc)||!leq(pbuc,bend))pbuc=pbuc->next(); + /*while(!leq(bbegin,pbuc)||!leq(pbuc,bend))pbuc=pbuc->next();*/ + if(!leq(bbegin,pbuc)||!leq(pbuc,bend)) + pbuc = buckets.at(buckets.position( + hash(key(node_type::from_impl(pbuc)->value())))); if(buc!=static_cast(pbuc-bbegin))return false; - + node_impl_pointer y=x->next(); if(y!=pbuc){ if(eq(k,key(node_type::from_impl(y)->value()))){ @@ -1173,11 +1193,12 @@ template< typename KeyFromValue,typename Hash,typename Pred, - typename SuperMeta,typename TagList,typename Category + typename SuperMeta,typename TagList,typename Category, + template class NodeType > void swap( - hashed_index& x, - hashed_index& y) + hashed_index& x, + hashed_index& y) { x.swap(y); } @@ -1207,7 +1228,8 @@ { typedef detail::hashed_index< key_from_value_type,hash_type,pred_type, - SuperMeta,tag_list_type,detail::hashed_unique_tag> type; + SuperMeta,tag_list_type,detail::hashed_unique_tag, + detail::hashed_index_node> type; }; }; @@ -1232,7 +1254,60 @@ { typedef detail::hashed_index< key_from_value_type,hash_type,pred_type, - SuperMeta,tag_list_type,detail::hashed_non_unique_tag> type; + SuperMeta,tag_list_type,detail::hashed_non_unique_tag, + detail::hashed_index_node> type; + }; +}; + +template +struct hashed_dbl_unique +{ + typedef typename detail::hashed_index_args< + Arg1,Arg2,Arg3,Arg4> index_args; + typedef typename index_args::tag_list_type::type tag_list_type; + typedef typename index_args::key_from_value_type key_from_value_type; + typedef typename index_args::hash_type hash_type; + typedef typename index_args::pred_type pred_type; + + template + struct node_class + { + typedef detail::hashed_index_dbl_node type; + }; + + template + struct index_class + { + typedef detail::hashed_index< + key_from_value_type,hash_type,pred_type, + SuperMeta,tag_list_type,detail::hashed_unique_tag, + detail::hashed_index_dbl_node> type; + }; +}; + +template +struct hashed_dbl_non_unique +{ + typedef typename detail::hashed_index_args< + Arg1,Arg2,Arg3,Arg4> index_args; + typedef typename index_args::tag_list_type::type tag_list_type; + typedef typename index_args::key_from_value_type key_from_value_type; + typedef typename index_args::hash_type hash_type; + typedef typename index_args::pred_type pred_type; + + template + struct node_class + { + typedef detail::hashed_index_dbl_node type; + }; + + template + struct index_class + { + typedef detail::hashed_index< + key_from_value_type,hash_type,pred_type, + SuperMeta,tag_list_type,detail::hashed_non_unique_tag, + detail::hashed_index_dbl_node> type; }; }; diff -N -dur --strip-trailing-cr old/boost_1_47_0/boost/multi_index/hashed_index_fwd.hpp new/boost_1_47_0/boost/multi_index/hashed_index_fwd.hpp --- old/boost_1_47_0/boost/multi_index/hashed_index_fwd.hpp 2008-07-03 20:51:53.000000000 +0400 +++ new/boost_1_47_0/boost/multi_index/hashed_index_fwd.hpp 2011-05-17 14:32:19.000000000 +0400 @@ -23,17 +23,19 @@ template< typename KeyFromValue,typename Hash,typename Pred, - typename SuperMeta,typename TagList,typename Category + typename SuperMeta,typename TagList,typename Category, + template class NodeType > class hashed_index; template< typename KeyFromValue,typename Hash,typename Pred, - typename SuperMeta,typename TagList,typename Category + typename SuperMeta,typename TagList,typename Category, + template class NodeType > void swap( - hashed_index& x, - hashed_index& y); + hashed_index& x, + hashed_index& y); } /* namespace multi_index::detail */ @@ -51,6 +53,18 @@ > struct hashed_non_unique; +template< + typename Arg1,typename Arg2=mpl::na, + typename Arg3=mpl::na,typename Arg4=mpl::na +> +struct hashed_dbl_unique; + +template< + typename Arg1,typename Arg2=mpl::na, + typename Arg3=mpl::na,typename Arg4=mpl::na +> +struct hashed_dbl_non_unique; + } /* namespace multi_index */ } /* namespace boost */