Class EnumerableExtensions
Namespace: GGL.Extensions
Assembly: GGL.dll
Syntax
public static class EnumerableExtensions
Methods
| Edit this page View SourceForEach<T>(IEnumerable<T>, Action<T, int>)
Simulate the foreach keyword with a lambda expresion.
Declaration
public static IEnumerable<T> ForEach<T>(this IEnumerable<T> collection, Action<T, int> callback)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The emurable collection you want to explore. |
Action<T, int> | callback | Code to execute for each item of the collection. (with the index in params) |
Returns
Type | Description |
---|---|
IEnumerable<T> | The same collection as a list. |
Type Parameters
Name | Description |
---|---|
T | Collection items type. |
Remarks
A simple foreach will have slightly better performances than a lambda conversion. Please do not use this method in a hot path. Thank you.
ForEach<T>(IEnumerable<T>, Action<T>)
Simulate the foreach keyword with a lambda expression.
Declaration
public static IEnumerable<T> ForEach<T>(this IEnumerable<T> collection, Action<T> callback)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The emurable collection you want to explore. |
Action<T> | callback | Code to execute for each item of the collection. (with the index in params) |
Returns
Type | Description |
---|---|
IEnumerable<T> | The same collection as a list. |
Type Parameters
Name | Description |
---|---|
T | Collection items type. |
Remarks
A simple foreach will have slightly better performances than a lambda conversion. Please do not use this method in a hot path. Thank you.
Shuffle<T>(IEnumerable<T>)
Randomly set a new order of items in a collection and returns it.
Declaration
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The emurable collection you want to shuffle. |
Returns
Type | Description |
---|---|
IEnumerable<T> | The shuffled collection as a list. |
Type Parameters
Name | Description |
---|---|
T | Collection items type. |