27#ifndef TREEDEC_BUCKET_SORTER_HPP
28#define TREEDEC_BUCKET_SORTER_HPP
31#define BOOST_GRAPH_DETAIL_BUCKET_SORTER_HPP
39#if defined(BOOST_CLANG) && (1 == BOOST_CLANG) && defined(__FreeBSD__)
40#define ITERATOR_CONSTRUCTOR_WORKAROUND
45 template <
class BucketType,
class ValueType,
class Bucket,
53 typedef typename std::vector<value_type>::size_type
size_type;
56 const Bucket& _bucket = Bucket(),
57 const ValueIndexMap& _id = ValueIndexMap())
71 for(; l < _length + _max_bucket; ++l){
83 std::cerr <<
"rm " << i <<
"\n";
84 std::cerr <<
"rm " << x <<
" " << i <<
" " <<
bucket[x] <<
"\n";
86 std::cerr <<
"rm " <<
prev[i] <<
" " <<
next[i] <<
"\n";
88 auto next_node =
next[i];
89 auto prev_node =
prev[i];
92 prev[next_node] = prev_node;
93 next[prev_node] = next_node;
98 assert(x<
next.size());
100 (*this)[
bucket[x]].push_back(x);
105 assert(x<
next.size());
107 (*this)[
bucket[x]].push_front(x);
118 (*this)[
bucket[x]].push(x);
127 (*this)[
bucket[x]].push_back(x);
134 return (std::numeric_limits<size_type>::max)();
137 typedef typename std::vector<size_type>::iterator
Iter;
138 typedef typename std::vector<size_type>::const_iterator
ConstIter;
144 template<
class Iter_,
class IndexValueMap_>
218 const ValueIndexMap& _id)
219#ifdef ITERATOR_CONSTRUCTOR_WORKAROUND
232#ifdef ITERATOR_CONSTRUCTOR_WORKAROUND
244 assert(new_head <
size());
246 if(new_head == current){
untested();
250 assert(current!=new_head);
251 prev[current] = new_head;
257 next[new_head] = current;
262 assert(new_tail <
size());
265 if(new_tail == current){
untested();
269 assert(current!=new_tail);
270 next[current] = new_tail;
275 prev[new_tail] = current;
331 assert(i <
next.size());
336 assert(i <
next.size());
345 typename std::vector<size_type>::iterator
head;
346 typename std::vector<size_type>::iterator
tail;
Definition bucket_sorter.hpp:150
bool operator==(const_iterator const &o)
Definition bucket_sorter.hpp:187
const_iterator(const const_iterator &p)
Definition bucket_sorter.hpp:156
const_iterator()
Definition bucket_sorter.hpp:152
bool operator!=(const_iterator const &o)
Definition bucket_sorter.hpp:184
const_iterator & operator++()
Definition bucket_sorter.hpp:178
size_type b
Definition bucket_sorter.hpp:191
value_type operator*() const
Definition bucket_sorter.hpp:174
const_iterator(const const_iterator &&p)
Definition bucket_sorter.hpp:158
stack_ const & s
Definition bucket_sorter.hpp:190
const_iterator & operator=(const const_iterator &&o)
Definition bucket_sorter.hpp:168
~const_iterator()
Definition bucket_sorter.hpp:160
const_iterator(size_type t, stack_ const &s_)
Definition bucket_sorter.hpp:154
const_iterator & operator=(const const_iterator &o)
Definition bucket_sorter.hpp:162
Definition bucket_sorter.hpp:145
const_iterator end() const
Definition bucket_sorter.hpp:312
IndexValueMap_ value
Definition bucket_sorter.hpp:323
const_iterator rbegin() const
Definition bucket_sorter.hpp:309
stack_(bucket_type _bucket_id, Iter_ h, Iter_ n, Iter_ p, Iter_ t, IndexValueMap_ v, const ValueIndexMap &_id)
Definition bucket_sorter.hpp:217
void push_back(const value_type &x)
Definition bucket_sorter.hpp:260
value_type const & front() const
Definition bucket_sorter.hpp:299
bool empty() const
Definition bucket_sorter.hpp:301
const_iterator begin() const
Definition bucket_sorter.hpp:305
bucket_type bucket_id
Definition bucket_sorter.hpp:318
value_type & front()
Definition bucket_sorter.hpp:300
value_type const & top() const
Definition bucket_sorter.hpp:297
void push(const value_type &x)
Definition bucket_sorter.hpp:279
size_t size() const
Definition bucket_sorter.hpp:316
stack_(const stack_ &p)
Definition bucket_sorter.hpp:194
ValueIndexMap id
Definition bucket_sorter.hpp:324
bucket_sorter base
Definition bucket_sorter.hpp:147
bucket_sorter::value_type value_type
Definition bucket_sorter.hpp:148
Iter_ next
Definition bucket_sorter.hpp:320
Iter_ head
Definition bucket_sorter.hpp:319
void pop()
Definition bucket_sorter.hpp:282
value_type & top()
Definition bucket_sorter.hpp:298
stack_ & operator=(const stack_ &p)
Definition bucket_sorter.hpp:205
Iter_ prev
Definition bucket_sorter.hpp:321
void push_front(const value_type &x)
Definition bucket_sorter.hpp:242
Iter_ tail
Definition bucket_sorter.hpp:322
stack_(bucket_type _bucket_id, Iter_ h, Iter_ n, Iter_ p, Iter_ t, IndexValueMap_ v)
Definition bucket_sorter.hpp:231
Definition bucket_sorter.hpp:47
std::vector< size_type >::const_iterator ConstIter
Definition bucket_sorter.hpp:138
void update_back(const value_type &x)
Definition bucket_sorter.hpp:123
bucket_sorter()
Definition bucket_sorter.hpp:76
stack_< Iter, IndexValueMap > stack
Definition bucket_sorter.hpp:327
BucketType bucket_type
Definition bucket_sorter.hpp:49
std::vector< value_type >::iterator IndexValueMap
Definition bucket_sorter.hpp:139
ValueType value_type
Definition bucket_sorter.hpp:50
std::vector< value_type >::const_iterator ConstIndexValueMap
Definition bucket_sorter.hpp:140
void push(const value_type &x)
Definition bucket_sorter.hpp:109
std::vector< size_type > prev
Definition bucket_sorter.hpp:344
std::vector< size_type > next
Definition bucket_sorter.hpp:343
bucket_sorter(size_type _length, bucket_type _max_bucket, const Bucket &_bucket=Bucket(), const ValueIndexMap &_id=ValueIndexMap())
Definition bucket_sorter.hpp:55
void push_back(const value_type &x)
Definition bucket_sorter.hpp:97
ValueIndexMap id
Definition bucket_sorter.hpp:349
std::vector< value_type >::size_type size_type
Definition bucket_sorter.hpp:53
const_stack operator[](const bucket_type &i) const
Definition bucket_sorter.hpp:330
size_t size() const
Definition bucket_sorter.hpp:341
void remove(const value_type &x)
Definition bucket_sorter.hpp:79
Bucket Bucket_type
Definition bucket_sorter.hpp:51
void push_front(const value_type &x)
Definition bucket_sorter.hpp:102
stack_< ConstIter, ConstIndexValueMap > const_stack
Definition bucket_sorter.hpp:328
std::vector< value_type > id_to_value
Definition bucket_sorter.hpp:347
stack operator[](const bucket_type &i)
Definition bucket_sorter.hpp:335
std::vector< size_type >::iterator Iter
Definition bucket_sorter.hpp:137
ValueIndexMap value_index_map
Definition bucket_sorter.hpp:52
static size_type invalid_value()
Definition bucket_sorter.hpp:133
void update(const value_type &x)
Definition bucket_sorter.hpp:120
std::vector< size_type >::iterator tail
Definition bucket_sorter.hpp:346
Bucket bucket
Definition bucket_sorter.hpp:348
void update_front(const value_type &x)
Definition bucket_sorter.hpp:114
std::vector< size_type >::iterator head
Definition bucket_sorter.hpp:345
#define untested()
Definition lua_table_handle.cpp:15
Definition boost_serialization_routines.h:49
SM_edge_weight_map< typename T::value_type, ug::BidirectionalMatrix< T > > get(edge_weight_t, ug::BidirectionalMatrix< T > const &g)
Definition bidirectional_boost.h:157
#define unreachable()
Definition trace.h:13
#define itested()
Definition trace.h:9