Changeset 1004 for trunk/yat/random


Ignore:
Timestamp:
Jan 23, 2008, 7:24:53 PM (14 years ago)
Author:
Peter
Message:

adding a wrapper around std::random_shuffle that uses the RNG class. Changed all calls to random_shuffle to use the added function. Acctually all calls already used the RNG class so essentially this change is only cosmetic, but by providing a function I think it is easier to avoid using multiple random generators.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/random/random.h

    r1000 r1004  
    3030#include <gsl/gsl_randist.h>
    3131
     32#include <algorithm>
    3233#include <string>
    3334
     
    555556  };
    556557
     558  /**
     559     \brief Convenience function to shuffle a range with singleton RNG.
     560
     561     Wrapper around std::random_shuffle using DiscreteUniform as
     562     random generator and thereby using the underlying RNG class,
     563     which is singleton.
     564   */
     565  template<typename T>
     566  void random_shuffle(T first, T last)
     567  {
     568    DiscreteUniform rnd;
     569    std::random_shuffle(first, last, rnd);
     570  }
     571
    557572}}} // of namespace random, yat, and theplu
    558573
Note: See TracChangeset for help on using the changeset viewer.