webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
random_utils.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // random_utils:
7 // Helper functions for random number generation.
8 //
9 
10 #ifndef UTIL_RANDOM_UTILS_H
11 #define UTIL_RANDOM_UTILS_H
12 
13 // TODO(jmadill): Rework this if Chromium decides to ban <random>
14 #include <random>
15 
16 #include <export.h>
17 
18 namespace angle
19 {
20 
22 {
23  public:
24  // Seed from clock
25  RNG();
26  // Seed from fixed number.
27  RNG(unsigned int seed);
28  ~RNG();
29 
30  void reseed(unsigned int newSeed);
31 
32  int randomInt();
33  int randomIntBetween(int min, int max);
34  unsigned int randomUInt();
35  float randomFloat();
36  float randomFloatBetween(float min, float max);
37  float randomNegativeOneToOne();
38 
39  private:
40  std::default_random_engine mGenerator;
41 };
42 
43 } // namespace angle
44 
45 #endif // UTIL_RANDOM_UTILS_H
long seed
Definition: float-mm.c:84
Definition: random_utils.h:21
#define ANGLE_EXPORT
Definition: export.h:27
Definition: Platform.h:33
double max
Definition: DeviceProximityEvent.idl:32
#define min(a, b)
Definition: user_environment.h:66