Ignore:
Timestamp:
Mar 19, 2007, 1:46:10 PM (15 years ago)
Author:
Peter
Message:

removed minmax functions and moved shuffle into vector.*

File:
1 edited

Legend:

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

    r737 r825  
    9393
    9494
    95   std::pair<size_t, size_t> minmax_index(const vector& vec,
    96                                          const std::vector<size_t>& subset)
    97   {
    98     size_t min_index = subset[0];
    99     size_t max_index = subset[0];
    100     for (unsigned int i=1; i<subset.size(); i++)
    101       if (vec[subset[i]] < vec[min_index])
    102         min_index = subset[i];
    103       else if (vec[subset[i]] > vec[max_index])
    104         max_index = subset[i];
    105     return std::pair<size_t,size_t>(min_index, max_index);
    106   }
    107 
    108 
    109   void shuffle(vector& invec)
    110   {
    111     vector vec(invec);
    112     random::DiscreteUniform rnd;
    113     for (size_t i=0; i<vec.size(); i++){
    114       size_t index = rnd(vec.size()-i);
    115       invec[i]=vec(index);
    116       vec(index)=vec(vec.size()-i-1);
    117     }
    118   }
    119 
    12095
    12196}}} // end of namespace utility, yat and thep
Note: See TracChangeset for help on using the changeset viewer.