-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathExtensions.cs
More file actions
31 lines (29 loc) · 753 Bytes
/
Copy pathExtensions.cs
File metadata and controls
31 lines (29 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
namespace CustomVisionEnd2End
{
static class Extensions
{
public static void ForEach<T>(this IEnumerable<T> ie, Action<T> action)
{
foreach (var i in ie)
{
action(i);
}
}
//https://stackoverflow.com/questions/273313/randomize-a-listt
public static void Shuffle<T>(this IList<T> list)
{
var rng = new Random();
var n = list.Count;
while (n > 1)
{
n--;
var k = rng.Next(n + 1);
var value = list[k];
list[k] = list[n];
list[n] = value;
}
}
}
}