#pragma once #include #include #include #include #include #include namespace rng { template inline void shuffle(R& rng, span span) { if(!span.size()) return; std::cout << " -> shuffling " << span.size() << " objects..."; for(std::size_t i=span.size()-1;i>0;i--) { auto j = rng.next_long(i); std::swap(span[i], span[j]); } std::cout << " OK" << std::endl; } template inline void unshuffle(R& rng, span span) { if(!span.size()) return; #ifdef _FS_SPILL_BUFFER #warning "_FS_SPILL_BUFFER is still experimental" file_vector rng_values(span.size()); #else std::vector rng_values(span.size()); #endif std::cout << " -> unshuffling " << span.size() << " objects..."; for(std::size_t i=span.size()-1;i>0;i--) rng_values.push_back(rng.next_long(i)); for(std::size_t i=1;i