Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AggregationMinMaxHelpers.cs
Go to the documentation of this file.
3
4namespace System.Linq;
5
6internal static class AggregationMinMaxHelpers<T>
7{
16
17 internal static T ReduceMin(IEnumerable<T> source)
18 {
19 return Reduce(source, -1);
20 }
21
22 internal static T ReduceMax(IEnumerable<T> source)
23 {
24 return Reduce(source, 1);
25 }
26
28 {
29 Comparer<T> comparer = Util.GetDefaultComparer<T>();
30 return (Pair<bool, T> accumulator, T element) => ((default(T) != null || element != null) && (!accumulator.First || Util.Sign(comparer.Compare(element, accumulator.Second)) == sign)) ? new Pair<bool, T>(first: true, element) : accumulator;
31 }
32
34 {
35 Comparer<T> comparer = Util.GetDefaultComparer<T>();
36 return (Pair<bool, T> accumulator, Pair<bool, T> element) => (element.First && (!accumulator.First || Util.Sign(comparer.Compare(element.Second, accumulator.Second)) == sign)) ? new Pair<bool, T>(first: true, element.Second) : accumulator;
37 }
38
40 {
41 return (Pair<bool, T> accumulator) => accumulator.Second;
42 }
43}
static Func< Pair< bool, T >, T, Pair< bool, T > > MakeIntermediateReduceFunction(int sign)
static T ReduceMin(IEnumerable< T > source)
static T ReduceMax(IEnumerable< T > source)
static Func< Pair< bool, T >, Pair< bool, T >, Pair< bool, T > > MakeFinalReduceFunction(int sign)
static Func< Pair< bool, T >, T > MakeResultSelectorFunction()
static T Reduce(IEnumerable< T > source, int sign)
static int Sign(int x)
Definition Util.cs:57