Table of Contents

Method MinItemsBy

Namespace
Gamelogic.Extensions.Algorithms
Assembly
Gamelogic.Extensions.dll

MinItemsBy<T, TComparable>(IEnumerable<T>, Func<T, TComparable>)

Returns the minimum 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> MinItemsBy<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 minimum 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.

MinItemsBy<T, TComparable>(IEnumerable<T>, Func<T, TComparable>, Comparer<TComparable>)

Returns the minimum elements in the source collection based on a selector function and a specified comparer.

[Version(3, 2, 0)]
public static IEnumerable<T> MinItemsBy<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 minimum 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.