Method MaxOrNone
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
MaxOrNone<T>(IEnumerable<T>?)
Returns the largest element of a sequence, if it has any.
[Pure]
public static Maybe<T> MaxOrNone<T>(this IEnumerable<T>? source)
Parameters
sourceIEnumerable<T>The sequence to search. A null sequence counts as empty.
Returns
- Maybe<T>
A Maybe<T> containing the largest element by Default, and no value if there is nothing to compare.
Type Parameters
TThe type of the values in the sequence.
Remarks
See MinOrNone<T>(IEnumerable<T>?) for why this exists.
MaxOrNone<T>(IEnumerable<T>?, IComparer<T>?)
Returns the largest element of a sequence by the given comparer, if it has any.
[Pure]
public static Maybe<T> MaxOrNone<T>(this IEnumerable<T>? source, IComparer<T>? comparer)
Parameters
sourceIEnumerable<T>The sequence to search. A null sequence counts as empty.
comparerIComparer<T>
Returns
Type Parameters
TThe type of the values in the sequence.
MaxOrNone<T, TResult>(IEnumerable<T>?, Func<T, TResult>)
Returns the largest value produced from a sequence, if it has any elements.
[Pure]
public static Maybe<TResult> MaxOrNone<T, TResult>(this IEnumerable<T>? source, Func<T, TResult> selector)
Parameters
sourceIEnumerable<T>The sequence to search. A null sequence counts as empty.
selectorFunc<T, TResult>Applied to each element to give the value to compare.
Returns
- Maybe<TResult>
A Maybe<T> containing the largest produced value by Default, and no value if there is nothing to compare.
Type Parameters
TThe type of the values in the sequence.
TResultThe type of the values to compare.
Remarks
This returns the largest value selector produced, not
the element which produced it.