Free cookie consent management tool by TermsFeed Policy Generator

source: branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/IListExtensions.cs @ 7128

Last change on this file since 7128 was 7128, checked in by epitzer, 12 years ago

#1696 Integrate fitness landscape analysis plugins from Heureka! repository.

File size: 494 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6
7namespace HeuristicLab.Analysis.FitnessLandscape {
8  public static class IListExtensions {
9    public static void Shuffle<T>(this IList<T> list, IRandom random) {
10      int n = list.Count;
11      while (n > 1) {
12        n--;
13        int k = random.Next(n + 1);
14        T value = list[k];
15        list[k] = list[n];
16        list[n] = value;
17      }
18    }
19  }
20}
Note: See TracBrowser for help on using the repository browser.