foobar2000 SDK  2015-08-03
genrand.h
Go to the documentation of this file.
1 class NOVTABLE genrand_service : public service_base
3 {
4 public:
6  virtual void seed(unsigned val) = 0;
8  virtual unsigned genrand(unsigned range)=0;
9 
10  double genrand_f() { return (double)genrand(0xFFFFFFFF) / (double)0xFFFFFFFF; }
11 
12  static service_ptr_t<genrand_service> g_create() {return standard_api_create_t<genrand_service>();}
13 
14  void generate_random_order(t_size * out, t_size count) {
15  unsigned genrandMax = (unsigned) pfc::min_t<size_t>(count, 0xFFFFFFFF);
16  t_size n;
17  for(n=0;n<count;n++) out[n]=n;
18  for(n=0;n<count;n++) pfc::swap_t(out[n],out[genrand(genrandMax)]);
19  }
20 
21  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(genrand_service);
22 };
double genrand_f()
Definition: genrand.h:10
PRNG service. Implemented by the core, do not reimplement. Use g_create() helper function to instanti...
Definition: genrand.h:2
void generate_random_order(t_size *out, t_size count)
Definition: genrand.h:14
static service_ptr_t< genrand_service > g_create()
Definition: genrand.h:12
size_t t_size
Definition: int_types.h:48
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
void swap_t(T &p_item1, T &p_item2)
Definition: primitives.h:285