c++ - Generate random numbers exaclty once -
i need create set of random numbers between 0 , 800. problem @ moment need fast , each number shall returned once.
my current approach is:
- create
std::vector
containing numbers 0 800 - pick number using
numbervector[rand() % numbervector.length()]
- delete number vector
i have , current approach slow. there way speed things here?
- create
std::vector
containing numbers 0 800 - shuffle vector.
should useful: c++ - how shuffle std::vector? - stack overflow - take elements of vector 1 one, head tail. don't have delete element: store index of last used element.
Comments
Post a Comment