31 template<
typename order_iterator,
typename value_iterator>
34 const order_iterator order_end,
35 const value_iterator v) {
36 using index_t =
typename std::iterator_traits<order_iterator>::value_type;
37 using diff_t =
typename std::iterator_traits<order_iterator>::difference_type;
39 auto remaining = order_end - 1 - order_begin;
40 for(index_t s = index_t(), d; remaining > 0; ++s) {
41 for(d = order_begin[diff_t(s)]; d > s; d = order_begin[diff_t(d)])
45 auto temp = v[diff_t(s)];
46 while(d = order_begin[diff_t(d)], d != s) {
47 std::swap(temp, v[diff_t(d)]);
62 template<
typename order_iterator,
typename value_iterator>
65 const order_iterator order_end,
66 const value_iterator v) {
67 using index_t =
typename std::iterator_traits<order_iterator>::value_type;
68 using diff_t =
typename std::iterator_traits<order_iterator>::difference_type;
70 auto remaining = order_end - 1 - order_begin;
71 for(
auto s = index_t(); remaining > 0; ++s) {
72 auto d = order_begin[diff_t(s)];
76 auto temp = v[diff_t(s)];
77 for(index_t d2; d != s; d = d2) {
78 std::swap(temp, v[diff_t(d)]);
79 std::swap(order_begin[diff_t(d)], d2 = index_t(-1));
void reorder(const order_iterator order_begin, const order_iterator order_end, const value_iterator v)
Reorders an array in place.
Definition: reorder.hh:33
void reorder_destructive(const order_iterator order_begin, const order_iterator order_end, const value_iterator v)
Reorders an array in place.
Definition: reorder.hh:64
Definition: control.hh:31