random.h 586 B

123456789101112131415161718192021222324252627282930
  1. #pragma once
  2. /*
  3. * thread-safe random number generator.
  4. *
  5. * specialized for:
  6. * all unsigned types (return value in range [0, MAX_VALUE_FOR_TYPE])
  7. * bool
  8. * long double (return value in range [0, 1))
  9. * double (return value in range [0, 1))
  10. * float (return value in range [0, 1))
  11. */
  12. template <class T>
  13. T RandomNumber();
  14. /*
  15. * returns value in range [0, max)
  16. */
  17. template <class T>
  18. T RandomNumber(T max);
  19. /*
  20. * Re-initialize random state - useful after forking in multi-process programs.
  21. */
  22. void ResetRandomState();
  23. /*
  24. * Set random SEED
  25. */
  26. void SetRandomSeed(int seed);