Table of Contents

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

source IEnumerable<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

T

The 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

source IEnumerable<T>

The sequence to search. A null sequence counts as empty.

comparer IComparer<T>

The ordering to use. null means Default.

Returns

Maybe<T>

A Maybe<T> containing the largest element, and no value if there is nothing to compare.

Type Parameters

T

The 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

source IEnumerable<T>

The sequence to search. A null sequence counts as empty.

selector Func<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

T

The type of the values in the sequence.

TResult

The type of the values to compare.

Remarks

This returns the largest value selector produced, not the element which produced it.