mersenne.h 854 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include "mersenne64.h"
  3. #include "mersenne32.h"
  4. #include "common_ops.h"
  5. namespace NPrivate {
  6. template <class T>
  7. struct TMersenneTraits;
  8. template <>
  9. struct TMersenneTraits<ui64> {
  10. using TImpl = TMersenne64;
  11. };
  12. template <>
  13. struct TMersenneTraits<ui32> {
  14. using TImpl = TMersenne32;
  15. };
  16. }
  17. class IInputStream;
  18. template <class T>
  19. class TMersenne: public TCommonRNG<T, TMersenne<T>>, public ::NPrivate::TMersenneTraits<T>::TImpl {
  20. public:
  21. using TBase = typename ::NPrivate::TMersenneTraits<T>::TImpl;
  22. inline TMersenne() noexcept {
  23. }
  24. inline TMersenne(T seed) noexcept
  25. : TBase(seed)
  26. {
  27. }
  28. inline TMersenne(IInputStream& pool)
  29. : TBase(pool)
  30. {
  31. }
  32. inline TMersenne(const T* keys, size_t len) noexcept
  33. : TBase(keys, len)
  34. {
  35. }
  36. };