-
Notifications
You must be signed in to change notification settings - Fork 0
Description
idea: is it possible to shuffle with something else than fisher yates? think about how to get rid of that division.
one way is to generate an index vector the same size as the elements, fill it with a random permutation (for instance by encrypting a counter, like i do in the random foreach repository).
then the vector can be resized by looping over the data, putting the data where it belongs, one at a time. it the element swapped with is not in the right position, put it there. eventually one can proceed with the next position.
could one use std::sort, but with a comparator that hashes the elements before comparing them? one problem is that the order between equivalent elements will not be the same, but that could perhaps be fixed in a second pass over the elements, where all equal ranges are shuffled with some other algorithm.