source:
branches/3133_ProblemModifiers/HeuristicLab.Problems.Modifiers/IListExtensions.cs
Last change on this file was 18029, checked in by bwerth, 3 years ago | |
---|---|
File size: 439 bytes |
Line | |
---|---|
1 | using System.Collections.Generic; |
2 | using HeuristicLab.Core; |
3 | |
4 | namespace HeuristicLab.Analysis.FitnessLandscape { |
5 | public static class IListExtensions { |
6 | public static void Shuffle<T>(this IList<T> list, IRandom random) { |
7 | int n = list.Count; |
8 | while (n > 1) { |
9 | n--; |
10 | int k = random.Next(n + 1); |
11 | T value = list[k]; |
12 | list[k] = list[n]; |
13 | list[n] = value; |
14 | } |
15 | } |
16 | } |
17 | } |
Note: See TracBrowser
for help on using the repository browser.