Class EnumerableExtensions
- Namespace
- Stride.Core.Extensions
- Assembly
- Stride.Core.dll
public static class EnumerableExtensions
- Inheritance
-
EnumerableExtensions
Methods
ForEach<T>(IEnumerable<T>, Action<T>)
Executes an action for each item of the given enumerable.
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
Parameters
source
IEnumerable<T>Input enumerable to work on.
action
Action<T>Action performed for each item in the enumerable.
Type Parameters
T
Type of the item value in the enumerable.
Remarks
This extension method do not yield. It acts just like a foreach statement.
ForEach<T>(IEnumerable, Action<T>)
Executes an action for each (casted) item of the given enumerable.
public static void ForEach<T>(this IEnumerable source, Action<T> action)
Parameters
source
IEnumerableInput enumerable to work on.
action
Action<T>Action performed for each item in the enumerable.
Type Parameters
T
Type of the item value in the enumerable.
Remarks
This extension method do not yield. It acts just like a foreach statement, and performs a cast to a typed enumerable in the middle.
IndexOf<T>(IEnumerable<T>, Func<T, bool>)
An IEnumerable<T> extension method that searches for the first match and returns its index.
[Pure]
public static int IndexOf<T>(this IEnumerable<T> source, Func<T, bool> predicate)
Parameters
source
IEnumerable<T>Input enumerable to work on.
predicate
Func<T, bool>The predicate.
Returns
- int
The index of the first element matching.
Type Parameters
T
Generic type parameter.
IsNullOrEmpty(IEnumerable)
Tells whether a sequence is null or empty.
[Pure]
public static bool IsNullOrEmpty(this IEnumerable source)
Parameters
source
IEnumerableThe source sequence.
Returns
- bool
Returns true if the sequence is null or empty, false if it is not null and contains at least one element.
LastIndexOf<T>(IEnumerable<T>, Func<T, bool>)
An IEnumerable<T> extension method that searches for the last match and returns its index.
[Pure]
public static int LastIndexOf<T>(this IEnumerable<T> source, Func<T, bool> predicate)
Parameters
source
IEnumerable<T>Input enumerable to work on.
predicate
Func<T, bool>The predicate.
Returns
- int
The index of the last element matching.
Type Parameters
T
Generic type parameter.
NotNull<T>(IEnumerable<T?>)
Filters out null items from the enumerable.
[Pure]
public static IEnumerable<T> NotNull<T>(this IEnumerable<T?> source) where T : struct
Parameters
source
IEnumerable<T?>Input enumerable to work on.
Returns
- IEnumerable<T>
An enumeration of all items in
source
that are notnull
.
Type Parameters
T
Generic type parameter.
NotNull<T>(IEnumerable<T>)
Filters out null items from the enumerable.
[Pure]
public static IEnumerable<T> NotNull<T>(this IEnumerable<T> source) where T : class
Parameters
source
IEnumerable<T>Input enumerable to work on.
Returns
- IEnumerable<T>
An enumeration of all items in
source
that are notnull
.
Type Parameters
T
Generic type parameter.
ToHashCode<T>(IEnumerable<T>)
Calculates a combined hash code for items of the enumerbale.
[Pure]
public static int ToHashCode<T>(this IEnumerable<T> source) where T : class
Parameters
source
IEnumerable<T>Input enumerable to work on.
Returns
- int
A combined hash code or 0 if the source is empty.
Type Parameters
T
Generic type parameter.