Method MinOrNone
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
MinOrNone<T>(IEnumerable<T>?)
Returns the smallest element of a sequence, if it has any.
[Pure]
public static Maybe<T> MinOrNone<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 smallest element by Default, and no value if there is nothing to compare.
Type Parameters
TThe type of the values in the sequence.
Remarks
Min<TSource>(IEnumerable<TSource>) throws on an empty sequence of a non-nullable type. On one of a nullable type it gives null, which is the same answer as a sequence whose smallest element is null. The two are not good answers, and the two are not necessary after the result can say there was nothing to compare.
MinOrNone<T>(IEnumerable<T>?, IComparer<T>?)
Returns the smallest element of a sequence by the given comparer, if it has any.
[Pure]
public static Maybe<T> MinOrNone<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.
MinOrNone<T, TResult>(IEnumerable<T>?, Func<T, TResult>)
Returns the smallest value produced from a sequence, if it has any elements.
[Pure]
public static Maybe<TResult> MinOrNone<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 smallest 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 smallest value selector produced, not
the element which gave it. For the element, order by the key and use
FirstOrNone<T>(IEnumerable<T>?).