Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 /* Copyright 2003-2006 Joaquín M López Muñoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * See http://www.boost.org/libs/multi_index for library home page.
9 #ifndef BOOST_MULTI_INDEX_DETAIL_RND_INDEX_NODE_HPP
10 #define BOOST_MULTI_INDEX_DETAIL_RND_INDEX_NODE_HPP
12 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
18 #include <boost/math/common_factor_rt.hpp>
24 namespace multi_index{
28 struct random_access_index_node_impl
30 random_access_index_node_impl**& up(){return up_;}
31 random_access_index_node_impl** up()const{return up_;}
33 /* interoperability with rnd_node_iterator */
35 static void increment(random_access_index_node_impl*& x)
40 static void decrement(random_access_index_node_impl*& x)
46 random_access_index_node_impl*& x,std::ptrdiff_t n)
51 static std::ptrdiff_t distance(
52 random_access_index_node_impl* x,random_access_index_node_impl* y)
54 return y->up()-x->up();
57 /* algorithmic stuff */
60 random_access_index_node_impl** pos,
61 random_access_index_node_impl** x)
63 random_access_index_node_impl* n=*x;
81 random_access_index_node_impl** pos,
82 random_access_index_node_impl** first,
83 random_access_index_node_impl** last)
85 random_access_index_node_impl** begin,**middle,**end;
97 std::ptrdiff_t n=end-begin;
98 std::ptrdiff_t m=middle-begin;
99 std::ptrdiff_t n_m=n-m;
100 std::ptrdiff_t p=math::gcd(n,m);
102 for(std::ptrdiff_t i=0;i<p;++i){
103 random_access_index_node_impl* tmp=begin[i];
104 for(std::ptrdiff_t j=i,k;;){
109 begin[j]->up()=&begin[j];
114 begin[j]->up()=&begin[j];
121 begin[k]->up()=&begin[k];
126 begin[k]->up()=&begin[k];
133 random_access_index_node_impl** x,
134 random_access_index_node_impl** pend)
144 static void transfer(
145 random_access_index_node_impl** pbegin0,
146 random_access_index_node_impl** pend0,
147 random_access_index_node_impl** pbegin1)
149 while(pbegin0!=pend0){
151 (*pbegin1)->up()=pbegin1;
157 random_access_index_node_impl** pbegin,
158 random_access_index_node_impl** pend)
160 std::ptrdiff_t d=(pend-pbegin)/2;
161 for(std::ptrdiff_t i=0;i<d;++i){
162 std::swap(*pbegin,*--pend);
163 (*pbegin)->up()=pbegin;
170 random_access_index_node_impl** up_;
173 template<typename Super>
174 struct random_access_index_node_trampoline:random_access_index_node_impl{};
176 template<typename Super>
177 struct random_access_index_node:
178 Super,random_access_index_node_trampoline<Super>
180 random_access_index_node_impl**& up(){return impl_type::up();}
181 random_access_index_node_impl** up()const{return impl_type::up();}
183 random_access_index_node_impl* impl()
184 {return static_cast<impl_type*>(this);}
185 const random_access_index_node_impl* impl()const
186 {return static_cast<const impl_type*>(this);}
188 static random_access_index_node* from_impl(random_access_index_node_impl *x)
190 return static_cast<random_access_index_node*>(
191 static_cast<impl_type*>(x));
194 static const random_access_index_node* from_impl(
195 const random_access_index_node_impl* x)
197 return static_cast<const random_access_index_node*>(
198 static_cast<const impl_type*>(x));
201 /* interoperability with rnd_node_iterator */
203 static void increment(random_access_index_node*& x)
205 random_access_index_node_impl* xi=x->impl();
206 impl_type::increment(xi);
210 static void decrement(random_access_index_node*& x)
212 random_access_index_node_impl* xi=x->impl();
213 impl_type::decrement(xi);
217 static void advance(random_access_index_node*& x,std::ptrdiff_t n)
219 random_access_index_node_impl* xi=x->impl();
220 impl_type::advance(xi,n);
224 static std::ptrdiff_t distance(
225 random_access_index_node* x,random_access_index_node* y)
227 return impl_type::distance(x->impl(),y->impl());
231 typedef random_access_index_node_trampoline<Super> impl_type;
234 } /* namespace multi_index::detail */
236 } /* namespace multi_index */
238 } /* namespace boost */