OLD | NEW |
---|---|
1 //===- subzero/src/IceRNG.h - Random number generator -----------*- C++ -*-===// | 1 //===- subzero/src/IceRNG.h - Random number generator -----------*- C++ -*-===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file declares a random number generator. | 10 // This file declares a random number generator. |
(...skipping 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 class RandomNumberGenerator { | 22 class RandomNumberGenerator { |
23 public: | 23 public: |
24 RandomNumberGenerator(llvm::StringRef Salt); | 24 RandomNumberGenerator(llvm::StringRef Salt); |
25 uint64_t next(uint64_t Max); | 25 uint64_t next(uint64_t Max); |
26 | 26 |
27 private: | 27 private: |
28 uint64_t State; | 28 uint64_t State; |
29 }; | 29 }; |
30 | 30 |
31 // This class adds additional random number generator utilities. The | |
32 // reason for the wrapper class is that we want to keep the | |
33 // RandomNumberGenerator interface identical to LLVM's. | |
34 class RandomNumberGeneratorWrapper { | |
Jim Stichnoth
2014/08/14 01:10:29
Here and above, add the usual boilerplate disablin
wala
2014/08/15 03:37:23
Done.
| |
35 public: | |
36 uint64_t next(uint64_t Max) { return RNG.next(Max); } | |
37 uint64_t operator()(uint64_t Max) { return RNG.next(Max); } | |
38 bool getTrueWithProbability(float Probability); | |
39 RandomNumberGeneratorWrapper(RandomNumberGenerator &RNG) : RNG(RNG) {} | |
40 private: | |
41 RandomNumberGenerator &RNG; | |
42 }; | |
43 | |
31 } // end of namespace Ice | 44 } // end of namespace Ice |
32 | 45 |
33 #endif // SUBZERO_SRC_ICERNG_H | 46 #endif // SUBZERO_SRC_ICERNG_H |
OLD | NEW |