24 #ifndef GRAPHLAB_INPLACE_SHUFFLE_HPP
25 #define GRAPHLAB_INPLACE_SHUFFLE_HPP
44 template <
typename Iterator,
typename sizetype>
47 std::vector<sizetype> &targets) {
48 size_t len = std::distance(begin, end);
49 assert(len == targets.size());
51 for (
size_t i = 0;i < len; ++i) {
53 if (i != targets[i]) {
54 typename std::iterator_traits<Iterator>::value_type v = *(begin + i);
56 while(j != targets[j]) {
57 size_t next = targets[j];
59 *(begin + j) = *(begin + next);
79 template <
typename Container,
typename sizetype>
81 const std::vector<sizetype> &targets) {
82 Container result(targets.size());
84 #pragma omp parallel for
86 for (ssize_t i = 0;i < ssize_t(targets.size()); ++i) {
87 result[i] = c[targets[i]];