Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/IListExtensions.cs @ 17712

Last change on this file since 17712 was 16995, checked in by gkronber, 6 years ago

#2520 Update plugin dependencies and references for HL.FLA for new persistence

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.