9 #ifndef BOOST_MULTI_INDEX_DETAIL_SEQ_INDEX_OPS_HPP
10 #define BOOST_MULTI_INDEX_DETAIL_SEQ_INDEX_OPS_HPP
26 namespace multi_index{
34 template <
typename SequencedIndex,
typename Predicate>
37 typedef typename SequencedIndex::iterator iterator;
38 iterator first=x.begin(),last=x.end();
40 if(pred(*first))x.erase(first++);
45 template <
typename SequencedIndex,
class BinaryPredicate>
48 typedef typename SequencedIndex::iterator iterator;
49 iterator first=x.begin();
50 iterator last=x.end();
52 for(iterator middle=first;++middle!=last;middle=first){
53 if(binary_pred(*middle,*first))x.erase(middle);
59 template <
typename SequencedIndex,
typename Compare>
62 typedef typename SequencedIndex::iterator iterator;
64 iterator first0=x.begin(),last0=x.end();
65 iterator first1=y.begin(),last1=y.end();
66 while(first0!=last0&&first1!=last1){
67 if(comp(*first1,*first0))x.splice(first0,y,first1++);
70 x.splice(last0,y,first1,last1);
78 template<
typename Node,
typename Compare>
84 typedef typename Node::impl_type impl_type;
85 typedef typename Node::impl_pointer impl_pointer;
87 impl_pointer first0=x->next();
89 impl_pointer first1=y->next();
91 while(first0!=last0&&first1!=last1){
93 Node::from_impl(first1)->value(),Node::from_impl(first0)->value())){
94 impl_pointer tmp=first1->next();
95 impl_type::relink(first0,first1);
98 else first0=first0->next();
100 impl_type::relink(last0,first1,last1);
110 sequenced_index_sort_max_fill=
111 (std::size_t)std::numeric_limits<std::size_t>::digits+1);
113 template<
typename Node,
typename Compare>
129 typedef typename Node::impl_type impl_type;
130 typedef typename Node::impl_pointer impl_pointer;
135 >::
type carry_spc_type;
136 carry_spc_type carry_spc;
138 *
reinterpret_cast<impl_type*
>(&carry_spc);
142 [sequenced_index_sort_max_fill]),
145 [sequenced_index_sort_max_fill]
147 >::
type counter_spc_type;
148 counter_spc_type counter_spc;
150 reinterpret_cast<impl_type*
>(&counter_spc);
153 carry.prior()=carry.next()=
static_cast<impl_pointer
>(&carry);
154 counter[0].prior()=counter[0].next()=
static_cast<impl_pointer
>(&counter[0]);
158 impl_type::relink(carry.next(),
header->next());
160 while(
i<fill&&counter[
i].
next()!=
static_cast<impl_pointer
>(&counter[
i])){
161 sequenced_index_collate<Node>(&carry,&counter[
i++],comp);
164 static_cast<impl_pointer
>(&carry),
165 static_cast<impl_pointer
>(&counter[
i]));
168 counter[fill].prior()=counter[fill].next()=
169 static_cast<impl_pointer
>(&counter[fill]);
173 for(std::size_t
i=1;
i<fill;++
i){
174 sequenced_index_collate<Node>(&counter[
i],&counter[
i-1],comp);
177 header->impl(),
static_cast<impl_pointer
>(&counter[fill-1]));
182 header->impl(),carry.next(),
static_cast<impl_pointer
>(&carry));
183 for(std::size_t
i=0;
i<=fill;++
i){
185 header->impl(),counter[
i].next(),
186 static_cast<impl_pointer
>(&counter[
i]));