Changeset 978


Ignore:
Timestamp:
Oct 21, 2007, 9:24:38 PM (14 years ago)
Author:
Peter
Message:

using std in our vector::shuffle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/vector.cc

    r916 r978  
    521521  void shuffle(vector& invec)
    522522  {
    523     vector vec(invec);
    524523    random::DiscreteUniform rnd;
    525     for (size_t i=0; i<vec.size(); i++){
    526       size_t index = rnd(vec.size()-i);
    527       invec[i]=vec(index);
    528       vec(index)=vec(vec.size()-i-1);
    529     }
     524    std::random_shuffle(invec.begin(), invec.end(), rnd);
    530525  }
    531526
Note: See TracChangeset for help on using the changeset viewer.