forked from ArduPilot/MissionPlanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollectionExtensions.cs
47 lines (44 loc) · 1.61 KB
/
CollectionExtensions.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MissionPlanner.Utilities
{
public static class CollectionExtensions
{
/// <summary>
/// Performs the specified <paramref name="action"/> on each element of the <paramref name="enumerable"/>.
///
/// </summary>
/// <param name="enumerable">An enumerable instance.
/// </param><param name="action"/>
public static void ForEach(this IEnumerable enumerable, Action<object> action)
{
foreach (object obj in enumerable)
action(obj);
}
/// <summary>
/// Performs the specified <paramref name="action"/> on each element of the <paramref name="enumerable"/>.
///
/// </summary>
/// <param name="enumerable">An enumerable instance.
/// </param><param name="action"/>
public static void ForEach<T>(this IEnumerable enumerable, Action<T> action)
{
foreach (T obj in enumerable)
action(obj);
}
/// <summary>
/// Performs the specified <paramref name="action"/> on each element of the <paramref name="enumerable"/>.
///
/// </summary>
/// <typeparam name="T">The type contained in the <paramref name="enumerable"/>.
/// </typeparam><param name="enumerable"/><param name="action"/>
public static void ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
{
foreach (T obj in enumerable)
action(obj);
}
}
}