PseudoRandom.h 348 B

123456789101112131415161718
  1. #pragma once
  2. #include <random>
  3. namespace ZXing {
  4. class PseudoRandom {
  5. std::minstd_rand _random;
  6. public:
  7. PseudoRandom(size_t seed) : _random(static_cast<std::minstd_rand::result_type>(seed)) {}
  8. template <typename IntType>
  9. IntType next(IntType low, IntType high) {
  10. return std::uniform_int_distribution<IntType>(low, high)(_random);
  11. }
  12. };
  13. }