X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Frand%2FGaloisLFSR.hpp;h=2ee476b6e321cc5d0298993b75e134b0727aeaad;hb=3a487f44c26f9bb9d1a1c831406b6497b2b3b425;hp=b0714432c77eb20e8cdeff74d6b2ce7dc7220f43;hpb=bb83e2c9db0fc9746eb076a0ecbd5c64f899d7eb;p=blank.git diff --git a/src/rand/GaloisLFSR.hpp b/src/rand/GaloisLFSR.hpp index b071443..2ee476b 100644 --- a/src/rand/GaloisLFSR.hpp +++ b/src/rand/GaloisLFSR.hpp @@ -48,6 +48,15 @@ public: return (*this)(next); } + template + typename Container::reference From(Container &c) { + return c[Next() % c.size()]; + } + template + typename Container::const_reference From(const Container &c) { + return c[Next() % c.size()]; + } + private: std::uint64_t state; // bits 64, 63, 61, and 60 set to 1 (counting from 1 lo to hi)