Example #1
0
 public static void AddNext(IRNG rng)
 {
     if (rng is IRNG64 rng64)
     {
         RandList64[Head] = rng64.Nextulong();
         if (++Tail == BufferSize)
         {
             Tail = 0;
         }
         return;
     }
     RNGStateStr[Head] = (rng as IRNGState)?.CurrentState();
     RandList[Head]    = rng.Nextuint();
     if (++Tail == BufferSize)
     {
         Tail = 0;
     }
 }
Example #2
0
 public static void CreateBuffer(int buffersize, IRNG rng)
 {
     BufferSize = buffersize;
     Tail       = buffersize - 1;
     if (rng is IRNG64 rng64)
     {
         RandList64 = new ulong[buffersize];
         for (int i = 0; i < buffersize; i++)
         {
             RandList64[i] = rng64.Nextulong();
         }
         return;
     }
     RandList    = new uint[buffersize];
     RNGStateStr = new PRNGState[buffersize];
     for (int i = 0; i < buffersize; i++)
     {
         RNGStateStr[i] = (rng as IRNGState)?.CurrentState();
         RandList[i]    = rng.Nextuint();
     }
 }