Description:
Add Extensions class I left out.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -0,0 +1,26 | |||
|
1 | ||
|
2 | using System; | |
|
3 | using System.Collections.Generic; | |
|
4 | ||
|
5 | ||
|
6 | namespace isometricparkfna | |
|
7 | { | |
|
8 | public static class Extensions | |
|
9 | { | |
|
10 | public static List<T> Shuffle<T> (this List<T> source) { | |
|
11 | Random rnd = new Random(); | |
|
12 | ||
|
13 | for(int i = (source.Count-1); i >= 0 ; i--) { | |
|
14 | var j = rnd.Next(0, (source.Count-1)); | |
|
15 | var tmp = source[j]; | |
|
16 | source[j] = source[i]; | |
|
17 | source[i] = tmp; | |
|
18 | } | |
|
19 | ||
|
20 | ||
|
21 | return source; | |
|
22 | ||
|
23 | } | |
|
24 | } | |
|
25 | } | |
|
26 |
You need to be logged in to leave comments.
Login now