Browse Source

Reordering members in Min and Max.

Bart De Smet 8 years ago
parent
commit
81751c5744

+ 15 - 15
Ix.NET/Source/System.Interactive.Async/Max.cs

@@ -10,14 +10,12 @@ namespace System.Linq
 {
     public static partial class AsyncEnumerable
     {
-        public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
+        public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
-            if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
 
-            return Max_(source, comparer, cancellationToken);
+            return Max(source, CancellationToken.None);
         }
 
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
@@ -29,23 +27,24 @@ namespace System.Linq
             return source.Aggregate((x, y) => comparer.Compare(x, y) >= 0 ? x : y, cancellationToken);
         }
 
-        public static Task<TResult> Max<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken)
+        public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
-            if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+            if (comparer == null)
+                throw new ArgumentNullException(nameof(comparer));
 
-            return source.Select(selector)
-                         .Max(cancellationToken);
+            return source.Max(comparer, CancellationToken.None);
         }
 
-        public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source)
+        public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
+            if (comparer == null)
+                throw new ArgumentNullException(nameof(comparer));
 
-            return Max(source, CancellationToken.None);
+            return Max_(source, comparer, cancellationToken);
         }
 
         public static Task<TResult> Max<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector)
@@ -58,14 +57,15 @@ namespace System.Linq
             return Max(source, selector, CancellationToken.None);
         }
 
-        public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer)
+        public static Task<TResult> Max<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
-            if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+            if (selector == null)
+                throw new ArgumentNullException(nameof(selector));
 
-            return source.Max(comparer, CancellationToken.None);
+            return source.Select(selector)
+                         .Max(cancellationToken);
         }
 
         public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)

+ 17 - 17
Ix.NET/Source/System.Interactive.Async/Min.cs

@@ -10,51 +10,51 @@ namespace System.Linq
 {
     public static partial class AsyncEnumerable
     {
-        public static Task<TResult> Min<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector)
+        public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
-            if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
 
-            return Min(source, selector, CancellationToken.None);
+            return Min(source, CancellationToken.None);
         }
 
-        public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
+        public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
-            if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
 
-            return Min_(source, comparer, cancellationToken);
+            var comparer = Comparer<TSource>.Default;
+            return source.Aggregate((x, y) => comparer.Compare(x, y) <= 0 ? x : y, cancellationToken);
         }
 
-        public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source)
+        public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
+            if (comparer == null)
+                throw new ArgumentNullException(nameof(comparer));
 
-            return Min(source, CancellationToken.None);
+            return source.Min(comparer, CancellationToken.None);
         }
 
-        public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
+        public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
+            if (comparer == null)
+                throw new ArgumentNullException(nameof(comparer));
 
-            var comparer = Comparer<TSource>.Default;
-            return source.Aggregate((x, y) => comparer.Compare(x, y) <= 0 ? x : y, cancellationToken);
+            return Min_(source, comparer, cancellationToken);
         }
 
-        public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer)
+        public static Task<TResult> Min<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
-            if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+            if (selector == null)
+                throw new ArgumentNullException(nameof(selector));
 
-            return source.Min(comparer, CancellationToken.None);
+            return Min(source, selector, CancellationToken.None);
         }
 
         public static Task<TResult> Min<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken)