aboutsummaryrefslogblamecommitdiffstats
path: root/util/random/mersenne.h
blob: b2044604ac7ac9ddf886ddcfa85d20712546c70d (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
            









                                  
                                  


                                  
                                  

      
                   
                  
                                                                                                   
       
                                                                 
 
                                 
     
                                     


                     
                                        


                     
                                                        


                          
#pragma once

#include "mersenne64.h"
#include "mersenne32.h"
#include "common_ops.h"

namespace NPrivate {
    template <class T>
    struct TMersenneTraits;

    template <>
    struct TMersenneTraits<ui64> {
        using TImpl = TMersenne64;
    };

    template <>
    struct TMersenneTraits<ui32> {
        using TImpl = TMersenne32;
    };
}

class IInputStream;

template <class T>
class TMersenne: public TCommonRNG<T, TMersenne<T>>, public ::NPrivate::TMersenneTraits<T>::TImpl {
public:
    using TBase = typename ::NPrivate::TMersenneTraits<T>::TImpl;

    inline TMersenne() noexcept {
    }

    inline TMersenne(T seed) noexcept
        : TBase(seed)
    {
    }

    inline TMersenne(IInputStream& pool)
        : TBase(pool)
    {
    }

    inline TMersenne(const T* keys, size_t len) noexcept
        : TBase(keys, len)
    {
    }
};