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?

  1. create std::vector containing numbers 0 800
  2. shuffle vector.
    should useful: c++ - how shuffle std::vector? - stack overflow
  3. take elements of vector 1 one, head tail. don't have delete element: store index of last used element.

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -