Method MaxItemsBy
- Namespace
- Gamelogic.Extensions.Algorithms
- Assembly
- Gamelogic.Extensions.dll
MaxItemsBy<T, TComparable>(IEnumerable<T>, Func<T, TComparable>)
Returns the maximum elements in the source collection based on a selector function. This overload uses the default comparer for the type TComparable.
[Version(3, 2, 0)]
public static IEnumerable<T> MaxItemsBy<T, TComparable>(this IEnumerable<T> source, Func<T, TComparable> selector) where TComparable : IComparable<TComparable>
Parameters
source
IEnumerable<T>The source collection.
selector
Func<T, TComparable>A function to extract a comparable value from each element.
Returns
- IEnumerable<T>
An IEnumerable<T> that contains the maximum elements in the source collection.
Type Parameters
T
The type of elements in the source collection.
TComparable
The type of the value returned by the selector function.
MaxItemsBy<T, TComparable>(IEnumerable<T>, Func<T, TComparable>, Comparer<TComparable>)
Returns the maximum elements in the source collection based on a selector function and a specified comparer.
[Version(3, 2, 0)]
public static IEnumerable<T> MaxItemsBy<T, TComparable>(this IEnumerable<T> source, Func<T, TComparable> selector, Comparer<TComparable> comparer) where TComparable : IComparable<TComparable>
Parameters
source
IEnumerable<T>The source collection.
selector
Func<T, TComparable>A function to extract a comparable value from each element.
comparer
Comparer<TComparable>The comparer to use when comparing elements.
Returns
- IEnumerable<T>
An IEnumerable<T> that contains the maximum elements in the source collection.
Type Parameters
T
The type of elements in the source collection.
TComparable
The type of the value returned by the selector function.