q(n); for (D i = 0; i < n; ++i) q[i] = i; std::sort(make_shadow_iter(first, q.begin()), make_shadow_iter(last, q.end()), shadow_cmp(cmp)); invert_permutation(q.begin(), q.end()); std::copy(q.begin(), q.end(), p); } template inline void sortp(Iter first, Iter last, IterP p, Cmp cmp) { typedef typename std::iterator_traits::value_type P; sortp(first, last, p, cmp, std::allocator()); } template inline void sortp(Iter first, Iter last, IterP p) { typedef typename std::iterator_traits::value_type T; typedef typename std::iterator_traits::value_type P; sortp(first, last, p, std::less(), std::allocator()); } template inline void sortv(Iter first, Iter last, IterP p, Cmp cmp, Alloc alloc) { typedef typename std::iterator_traits::value_type P; typedef typename std::iterator_traits::difference_type D; D n = last - first; std::vector q(n), q_inv(n); for (D i = 0; i < n; ++i) q_inv[i] = i; std::sort(make_shadow_iter(first, q_inv.begin()), make_shadow_iter(last, q_inv.end()), shadow_cmp(cmp)); std::copy(q_inv, q_inv.end(), q.begin()); invert_permutation(q.begin(), q.end()); serialize_permutation(q.begin(), q.end(), q_inv.end(), p); } } // namespace boost #endif // BOOST_PERMUTATION_HPP
()); } template inline void sortp(Iter first, Iter last, IterP p) { typedef typename std::iterator_traits::value_type T; typedef typename std::iterator_traits::value_type P; sortp(first, last, p, std::less(), std::allocator()); } template inline void sortv(Iter first, Iter last, IterP p, Cmp cmp, Alloc alloc) { typedef typename std::iterator_traits::value_type P; typedef typename std::iterator_traits::difference_type D; D n = last - first; std::vector q(n), q_inv(n); for (D i = 0; i < n; ++i) q_inv[i] = i; std::sort(make_shadow_iter(first, q_inv.begin()), make_shadow_iter(last, q_inv.end()), shadow_cmp(cmp)); std::copy(q_inv, q_inv.end(), q.begin()); invert_permutation(q.begin(), q.end()); serialize_permutation(q.begin(), q.end(), q_inv.end(), p); } } // namespace boost #endif // BOOST_PERMUTATION_HPP
()); } template inline void sortv(Iter first, Iter last, IterP p, Cmp cmp, Alloc alloc) { typedef typename std::iterator_traits::value_type P; typedef typename std::iterator_traits::difference_type D; D n = last - first; std::vector q(n), q_inv(n); for (D i = 0; i < n; ++i) q_inv[i] = i; std::sort(make_shadow_iter(first, q_inv.begin()), make_shadow_iter(last, q_inv.end()), shadow_cmp(cmp)); std::copy(q_inv, q_inv.end(), q.begin()); invert_permutation(q.begin(), q.end()); serialize_permutation(q.begin(), q.end(), q_inv.end(), p); } } // namespace boost #endif // BOOST_PERMUTATION_HPP
q(n), q_inv(n); for (D i = 0; i < n; ++i) q_inv[i] = i; std::sort(make_shadow_iter(first, q_inv.begin()), make_shadow_iter(last, q_inv.end()), shadow_cmp(cmp)); std::copy(q_inv, q_inv.end(), q.begin()); invert_permutation(q.begin(), q.end()); serialize_permutation(q.begin(), q.end(), q_inv.end(), p); } } // namespace boost #endif // BOOST_PERMUTATION_HPP