Exemplo n.º 1
0
 public override int Next(int minValue, int maxValue)
 {
     if (minValue > maxValue)
     {
         throw new ArgumentOutOfRangeException("minValue", "minValue > maxValue");
     }
     else if (minValue == maxValue)
     {
         return(minValue);
     }
     return(rng.RandInt(minValue, maxValue - 1));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Randomizes the order of the list in-place with the Fisher-Yates shuffle.
 /// </summary>
 /// <param name="rng">The random number generator to use.</param>
 /// <returns>The shuffled list.</returns>
 public static IList <T> Shuffle <T>(this IList <T> list, IAltRandom rng)
 {
     for (int i = 0; i < list.Count - 2; i++)
     {
         int j    = rng.RandInt(i, list.Count - 1);
         T   temp = list[i];
         list[i] = list[j];
         list[j] = temp;
     }
     return(list);
 }