Skip to content

Commit

Permalink
Rewrite swap more succinctly via tuples (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz authored Nov 4, 2022
1 parent db11510 commit 66cfe26
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions MoreLinq/RandomSubset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ static IEnumerable<T> RandomSubsetImpl<T>(IEnumerable<T> source, Random rand, Fu
while (m < subsetSize)
{
var k = g - rand.Next(w);
var tmp = array[k];
array[k] = array[m];
array[m] = tmp;
(array[k], array[m]) = (array[m], array[k]);
++m;
--w;
}
Expand Down

0 comments on commit 66cfe26

Please sign in to comment.