X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Frand%2FGaloisLFSR.hpp;fp=src%2Frand%2FGaloisLFSR.hpp;h=2ee476b6e321cc5d0298993b75e134b0727aeaad;hb=825f479edf9867938b6789215ad7ae6303596cba;hp=b0714432c77eb20e8cdeff74d6b2ce7dc7220f43;hpb=78dcbeb7a905c4c153cb1b20e23f5adc1efc6d7e;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)