1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | public static void ShuffleArray<T>(T[] array) { int random1; int random2; T tmp; for (int index = 0; index < array.Length; ++index) { random1 = UnityEngine.Random.Range(0, array.Length); random2 = UnityEngine.Random.Range(0, array.Length); tmp = array[random1]; array[random1] = array[random2]; array[random2] = tmp; } } public static void ShuffleList<T>(List<T> list) { int random1; int random2; T tmp; for (int index = 0; index < list.Count; ++index) { random1 = UnityEngine.Random.Range(0, list.Count); random2 = UnityEngine.Random.Range(0, list.Count); tmp = list[random1]; list[random1] = list[random2]; list[random2] = tmp; } } | cs |
'02.Development > C#' 카테고리의 다른 글
[C#] Convert C# to Java, Java to C# - UTC (0) | 2016.07.07 |
---|---|
[C#] 숫자 문자열에 컴마(,) 찍기 (0) | 2016.02.12 |