Chromium Code Reviews| 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 24 matching lines...) Expand all Loading... | |
| 35 | 35 |
| 36 // This class adds additional random number generator utilities. The | 36 // This class adds additional random number generator utilities. The |
| 37 // reason for the wrapper class is that we want to keep the | 37 // reason for the wrapper class is that we want to keep the |
| 38 // RandomNumberGenerator interface identical to LLVM's. | 38 // RandomNumberGenerator interface identical to LLVM's. |
| 39 class RandomNumberGeneratorWrapper { | 39 class RandomNumberGeneratorWrapper { |
| 40 RandomNumberGeneratorWrapper(const RandomNumberGeneratorWrapper &) = delete; | 40 RandomNumberGeneratorWrapper(const RandomNumberGeneratorWrapper &) = delete; |
| 41 RandomNumberGeneratorWrapper & | 41 RandomNumberGeneratorWrapper & |
| 42 operator=(const RandomNumberGeneratorWrapper &) = delete; | 42 operator=(const RandomNumberGeneratorWrapper &) = delete; |
| 43 | 43 |
| 44 public: | 44 public: |
| 45 uint64_t operator()(uint64_t Max) { return RNG.next(Max); } | |
| 45 uint64_t next(uint64_t Max) { return RNG.next(Max); } | 46 uint64_t next(uint64_t Max) { return RNG.next(Max); } |
|
JF
2014/12/17 18:56:18
I'd only have operator() or next(), not both.
Jim Stichnoth
2014/12/18 18:52:03
Done. Leaving operator() for its use in std::rand
| |
| 46 bool getTrueWithProbability(float Probability); | 47 bool getTrueWithProbability(float Probability); |
| 47 RandomNumberGeneratorWrapper(RandomNumberGenerator &RNG) : RNG(RNG) {} | 48 RandomNumberGeneratorWrapper(RandomNumberGenerator &RNG) : RNG(RNG) {} |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 RandomNumberGenerator &RNG; | 51 RandomNumberGenerator &RNG; |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 } // end of namespace Ice | 54 } // end of namespace Ice |
| 54 | 55 |
| 55 #endif // SUBZERO_SRC_ICERNG_H | 56 #endif // SUBZERO_SRC_ICERNG_H |
| OLD | NEW |