SHARE
TWEET

Fisher Yates

teleias Jun 30th, 2020 983 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public static void Shuffle<T>(this IList<T> l)
  2.     {
  3.         int n = l.Count;
  4.         for(int i = 0; i < n - 1; i++)
  5.         {
  6.             int j = UnityEngine.Random.Range(i, n);
  7.             if (j == i) continue;
  8.             T temp = l[i];
  9.             l[i] = l[j];
  10.             l[j] = temp;
  11.         }
  12.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top