source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Extensions/CollectionExtensions.cs @ 14834

Last change on this file since 14834 was 14834, checked in by pkimmesw, 3 years ago

#2665 LexicaseSelector, Performance improvements, UI Fixes, Debugger only shows used stacks, fixed Debugger stepping, Added vector expressions, ERCOptions,

File size: 433 bytes
Line 
1using System.Collections.Generic;
2
3namespace HeuristicLab.Problems.ProgramSynthesis.Push.Extensions {
4  using HeuristicLab.Core;
5  using HeuristicLab.Random;
6
7  public static class CollectionExtensions {
8    public static T Random<T>(this IReadOnlyList<T> source, IRandom random = null) {
9      random = random ?? new MersenneTwister();
10      var x = random.Next(source.Count);
11
12      return source[x];
13    }
14  }
15}
Note: See TracBrowser for help on using the repository browser.