Changeset 9072
- Timestamp:
- 12/18/12 13:03:12 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Random/3.3/RandomEnumerable.cs
r7828 r9072 121 121 /// <param name="random">The random number generator to use, its NextDouble() method must produce values in the range [0;1)</param> 122 122 /// <param name="count">The number of items to be selected.</param> 123 /// <param name="sourceCount">Optional parameter specifying the number of elements in the source enumerations</param> 123 124 /// <returns>A sequence of elements that have been chosen randomly.</returns> 124 public static IEnumerable<T> SampleRandomWithoutRepetition<T>(this IEnumerable<T> source, IRandom random, int count) { 125 int remaining = source.Count(); 125 public static IEnumerable<T> SampleRandomWithoutRepetition<T>(this IEnumerable<T> source, IRandom random, int count, int sourceCount = -1) { 126 if (sourceCount == -1) sourceCount = source.Count(); 127 int remaining = sourceCount; 126 128 foreach (var item in source) { 127 129 if (random.NextDouble() * remaining < count) {
Note: See TracChangeset
for help on using the changeset viewer.