/// <summary> /// Returns the minimum and maximum value of an iterable using a comparer. In case of /// multiple occurrences the first instance is returned. /// </summary> /// <typeparam name="T"> /// The type of the values in the <paramref name="source"/>. /// </typeparam> /// <param name="source"> /// The enumerable of values from which to get the minimum and maximum. /// </param> /// <param name="comparer"> /// The comparer for the values. /// </param> /// <returns> /// A value tuple containing the minimum (first element) and maximum (second element). /// </returns> /// <exception cref="ArgumentNullException"> /// If the <paramref name="source"/> or <paramref name="comparer"/> is null. /// </exception> /// <exception cref="InvalidOperationException"> /// If the <paramref name="source"/> contains no elements. /// </exception> public static MinMaxResult <T> MinMax <T>(this IEnumerable <T> source, IComparer <T> comparer) => MinMaxOps.MinMax(source, comparer);
/// <summary> /// Returns the minimum and maximum value of an iterable by comparing the results of a /// selector function. In case of multiple occurrences the first instance is returned. /// </summary> /// <typeparam name="TItem"> /// The type of the values in the <paramref name="source"/>. /// </typeparam> /// <typeparam name="TKey"> /// The type of the values returned by the <paramref name="keyFunc"/> function. /// </typeparam> /// <param name="source"> /// The enumerable of values from which to get the minimum and maximum. /// </param> /// <param name="keyFunc"> /// The selector function that converts the values in the <paramref name="source"/> to the /// values that are compared. /// </param> /// <param name="comparer"> /// The comparer for the values returned by the selector. /// </param> /// <returns> /// A value tuple containing the minimum (first element) and maximum (second element). /// </returns> /// <exception cref="ArgumentNullException"> /// If the <paramref name="source"/> or <paramref name="keyFunc"/> or /// <paramref name="comparer"/> is null. /// </exception> /// <exception cref="InvalidOperationException"> /// If the <paramref name="source"/> contains no elements. /// </exception> public static MinMaxResult <TItem> MinMaxBy <TItem, TKey>( this IEnumerable <TItem> source, Func <TItem, TKey> keyFunc, IComparer <TKey> comparer ) => MinMaxOps.MinMaxBy(source, keyFunc, comparer);
/// <summary /// >Returns the minimum and maximum value of an iterable. In case of multiple occurrences /// the first instance is returned. /// </summary> /// <typeparam name="T"> /// The type of the values in the <paramref name="source"/>. /// </typeparam> /// <param name="source"> /// The enumerable of values from which to get the minimum and maximum. /// </param> /// <returns> /// A value tuple containing the minimum (first element) and maximum (second element). /// </returns> /// <exception cref="ArgumentNullException"> /// If the <paramref name="source"/> is null. /// </exception> /// <exception cref="InvalidOperationException"> /// If the <paramref name="source"/> contains no elements. /// </exception> public static MinMaxResult <T> MinMax <T>(this IEnumerable <T> source) where T : IComparable <T> => MinMaxOps.MinMax(source);
/// <summary> /// Returns the minimum and maximum value of an iterable by comparing the results of a /// selector function. In case of multiple occurrences the first instance is returned. /// </summary> /// <typeparam name="TItem"> /// The type of the values in the <paramref name="source"/>. /// </typeparam> /// <typeparam name="TKey"> /// The type of the values returned by the <paramref name="keyFunc"/> function. /// </typeparam> /// <param name="source"> /// The enumerable of values from which to get the minimum and maximum. /// </param> /// <param name="keyFunc"> /// The selector function that converts the values in the <paramref name="source"/> to the /// values that are compared. /// </param> /// <returns> /// A value tuple containing the minimum (first element) and maximum (second element). /// </returns> /// <exception cref="ArgumentNullException"> /// If the <paramref name="source"/> or <paramref name="keyFunc"/> is null. /// </exception> /// <exception cref="InvalidOperationException"> /// If the <paramref name="source"/> contains no elements. /// </exception> public static MinMaxResult <TItem> MinMaxBy <TItem, TKey>( this IEnumerable <TItem> source, Func <TItem, TKey> keyFunc ) where TKey : IComparable <TKey> => MinMaxOps.MinMaxBy(source, keyFunc);