/usr/include/boost/multi_index/detail
NameSizeModeActions
access_specifier.hpp21150644editdlrm
adl_swap.hpp8580644editdlrm
allocator_traits.hpp49570644editdlrm
archive_constructed.hpp19910644editdlrm
auto_space.hpp29070644editdlrm
base_type.hpp19810644editdlrm
bidir_node_iterator.hpp25840644editdlrm
bucket_array.hpp77300644editdlrm
cons_stdtuple.hpp22060644editdlrm
converter.hpp13720644editdlrm
copy_map.hpp47130644editdlrm
define_if_constexpr_macro.hpp8760644editdlrm
do_not_copy_elements_tag.hpp7620644editdlrm
duplicates_iterator.hpp25740644editdlrm
hash_index_args.hpp30660644editdlrm
hash_index_iterator.hpp44070644editdlrm
hash_index_node.hpp231700644editdlrm
has_tag.hpp9150644editdlrm
header_holder.hpp12960644editdlrm
ignore_wstrict_aliasing.hpp5480644editdlrm
index_base.hpp91890644editdlrm
index_loader.hpp34720644editdlrm
index_matcher.hpp61340644editdlrm
index_node_base.hpp35000644editdlrm
index_saver.hpp37870644editdlrm
invariant_assert.hpp5780644editdlrm
is_function.hpp14390644editdlrm
is_index_list.hpp9780644editdlrm
is_transparent.hpp36160644editdlrm
iter_adaptor.hpp75910644editdlrm
modify_key_adaptor.hpp10660644editdlrm
node_handle.hpp62490644editdlrm
node_type.hpp17830644editdlrm
no_duplicate_tags.hpp22130644editdlrm
ord_index_args.hpp23630644editdlrm
ord_index_impl.hpp498500644editdlrm
ord_index_impl_fwd.hpp40240644editdlrm
ord_index_node.hpp201370644editdlrm
ord_index_ops.hpp76290644editdlrm
promotes_arg.hpp18860644editdlrm
raw_ptr.hpp11870644editdlrm
restore_wstrict_aliasing.hpp4570644editdlrm
rnd_index_loader.hpp48860644editdlrm
rnd_index_node.hpp64530644editdlrm
rnd_index_ops.hpp60030644editdlrm
rnd_index_ptr_array.hpp34990644editdlrm
rnd_node_iterator.hpp31350644editdlrm
rnk_index_ops.hpp86210644editdlrm
safe_mode.hpp181030644editdlrm
scope_guard.hpp137030644editdlrm
seq_index_node.hpp54550644editdlrm
seq_index_ops.hpp61520644editdlrm
serialization_version.hpp18010644editdlrm
uintptr_type.hpp24460644editdlrm
unbounded.hpp15560644editdlrm
undef_if_constexpr_macro.hpp4590644editdlrm
value_compare.hpp12400644editdlrm
vartempl_support.hpp109650644editdlrm
Edit: /usr/include/boost/multi_index/detail/rnd_index_loader.hpp (4886B)
/* Copyright 2003-2018 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_RND_INDEX_LOADER_HPP #define BOOST_MULTI_INDEX_DETAIL_RND_INDEX_LOADER_HPP #if defined(_MSC_VER) #pragma once #endif #include /* keep it first to prevent nasty warns in MSVC */ #include #include #include #include #include namespace boost{ namespace multi_index{ namespace detail{ /* This class implements a serialization rearranger for random access * indices. In order to achieve O(n) performance, the following strategy * is followed: the nodes of the index are handled as if in a bidirectional * list, where the next pointers are stored in the original * random_access_index_ptr_array and the prev pointers are stored in * an auxiliary array. Rearranging of nodes in such a bidirectional list * is constant time. Once all the arrangements are performed (on destruction * time) the list is traversed in reverse order and * pointers are swapped and set accordingly so that they recover its * original semantics ( *(node->up())==node ) while retaining the * new order. */ template class random_access_index_loader_base:private noncopyable { protected: typedef random_access_index_node_impl< typename rebind_alloc_for< Allocator, char >::type > node_impl_type; typedef typename node_impl_type::pointer node_impl_pointer; typedef random_access_index_ptr_array ptr_array; random_access_index_loader_base(const Allocator& al_,ptr_array& ptrs_): al(al_), ptrs(ptrs_), header(*ptrs.end()), prev_spc(al,0), preprocessed(false) {} ~random_access_index_loader_base() { if(preprocessed) { node_impl_pointer n=header; next(n)=n; for(size_type i=ptrs.size();i--;){ n=prev(n); size_type d=position(n); if(d!=i){ node_impl_pointer m=prev(next_at(i)); std::swap(m->up(),n->up()); next_at(d)=next_at(i); std::swap(prev_at(d),prev_at(i)); } next(n)=n; } } } void rearrange(node_impl_pointer position_,node_impl_pointer x) { preprocess(); /* only incur this penalty if rearrange() is ever called */ if(position_==node_impl_pointer(0))position_=header; next(prev(x))=next(x); prev(next(x))=prev(x); prev(x)=position_; next(x)=next(position_); next(prev(x))=prev(next(x))=x; } private: typedef allocator_traits alloc_traits; typedef typename alloc_traits::size_type size_type; void preprocess() { if(!preprocessed){ /* get space for the auxiliary prev array */ auto_space tmp(al,ptrs.size()+1); prev_spc.swap(tmp); /* prev_spc elements point to the prev nodes */ std::rotate_copy( &*ptrs.begin(),&*ptrs.end(),&*ptrs.end()+1,&*prev_spc.data()); /* ptrs elements point to the next nodes */ std::rotate(&*ptrs.begin(),&*ptrs.begin()+1,&*ptrs.end()+1); preprocessed=true; } } size_type position(node_impl_pointer x)const { return (size_type)(x->up()-ptrs.begin()); } node_impl_pointer& next_at(size_type n)const { return *ptrs.at(n); } node_impl_pointer& prev_at(size_type n)const { return *(prev_spc.data()+n); } node_impl_pointer& next(node_impl_pointer x)const { return *(x->up()); } node_impl_pointer& prev(node_impl_pointer x)const { return prev_at(position(x)); } Allocator al; ptr_array& ptrs; node_impl_pointer header; auto_space prev_spc; bool preprocessed; }; template class random_access_index_loader: private random_access_index_loader_base { typedef random_access_index_loader_base super; typedef typename super::node_impl_pointer node_impl_pointer; typedef typename super::ptr_array ptr_array; public: random_access_index_loader(const Allocator& al_,ptr_array& ptrs_): super(al_,ptrs_) {} void rearrange(Node* position_,Node *x) { super::rearrange( position_?position_->impl():node_impl_pointer(0),x->impl()); } }; } /* namespace multi_index::detail */ } /* namespace multi_index */ } /* namespace boost */ #endif