refactoring
This commit is contained in:
parent
c293490995
commit
4dfbcff460
14 changed files with 240 additions and 82 deletions
23
Sledgemapper.Shared/ExtensionMethods.cs
Normal file
23
Sledgemapper.Shared/ExtensionMethods.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SignalRChat.Hubs
|
||||
{
|
||||
public static class ExtensionMethods
|
||||
{
|
||||
private static Random rng = new Random();
|
||||
|
||||
public static void Shuffle<T>(this IList<T> list)
|
||||
{
|
||||
int n = list.Count;
|
||||
while (n > 1)
|
||||
{
|
||||
n--;
|
||||
int k = rng.Next(n + 1);
|
||||
T value = list[k];
|
||||
list[k] = list[n];
|
||||
list[n] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue