]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/move/test/random_shuffle.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / move / test / random_shuffle.hpp
1 #ifndef BOOST_MOVE_TEST_RANDOM_SHUFFLE_HPP
2 #define BOOST_MOVE_TEST_RANDOM_SHUFFLE_HPP
3
4
5 #include <boost/move/adl_move_swap.hpp>
6 #include <boost/move/detail/iterator_traits.hpp>
7 #include <stdlib.h>
8
9 template< class RandomIt >
10 void random_shuffle( RandomIt first, RandomIt last )
11 {
12 typedef typename boost::movelib::iterator_traits<RandomIt>::difference_type difference_type;
13 difference_type n = last - first;
14 for (difference_type i = n-1; i > 0; --i) {
15 difference_type j = std::rand() % (i+1);
16 if(j != i) {
17 boost::adl_move_swap(first[i], first[j]);
18 }
19 }
20 }
21
22
23 #endif// BOOST_MOVE_TEST_RANDOM_SHUFFLE_HPP