MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / shuffle

Function shuffle

rtpose_wrapper/include/caffe/util/rng.hpp:22–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20// Fisher–Yates algorithm
21template <class RandomAccessIterator, class RandomGenerator>
22inline void shuffle(RandomAccessIterator begin, RandomAccessIterator end,
23 RandomGenerator* gen) {
24 typedef typename std::iterator_traits<RandomAccessIterator>::difference_type
25 difference_type;
26 typedef typename boost::uniform_int<difference_type> dist_type;
27
28 difference_type length = std::distance(begin, end);
29 if (length <= 0) return;
30
31 for (difference_type i = length - 1; i > 0; --i) {
32 dist_type dist(0, i);
33 std::iter_swap(begin + i, begin + dist(*gen));
34 }
35}
36
37template <class RandomAccessIterator>
38inline void shuffle(RandomAccessIterator begin, RandomAccessIterator end) {

Callers 2

mainFunction · 0.50
ShuffleImagesMethod · 0.50

Calls 1

caffe_rngFunction · 0.85

Tested by

no test coverage detected