Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3133_ProblemModifiers/HeuristicLab.Problems.Modifiers/IListExtensions.cs

Last change on this file was 18029, checked in by bwerth, 3 years ago

#3133 added implementation of problem modifiers

File size: 439 bytes
Line 
1using System.Collections.Generic;
2using HeuristicLab.Core;
3
4namespace 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.