move ReverseComparer to spark_core

This commit is contained in:
John Colvin committed 2019-10-19 17:29:23 -05:00
1 parent 8ba1c7a602
commit ff33d0d735
3 files changed
+18 -21

No files matched your search

@@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace mbts.utils {
public class ReverseComparer<T> : IComparer<T> {
private readonly IComparer<T> _wrapped;
public ReverseComparer(IComparer<T> wrapped) {
_wrapped = wrapped;
}
public int Compare(T x, T y) {
// reverse operands
return _wrapped.Compare(y, x);
}
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ namespace bts.utils {
Comparer<T?>.Create(nullable_comparison<T>(comparer.Compare));
public static IComparer<T> reverse<T>(this IComparer<T> comparer) =>
Comparer<T>.Create((a, b) => comparer.Compare(b, a));
new ReverseComparer<T>(comparer);
class NonGenericComparerWrapper<T> : IComparer {
readonly IComparer<T> _comparer;
@@ -0,0 +1,17 @@
using System.Collections.Generic;
namespace bts.utils {
public class ReverseComparer<T> : IComparer<T> {
public static readonly IComparer<T> Default =
new ReverseComparer<T>(Comparer<T>.Default);
readonly IComparer<T> _wrapped;
public ReverseComparer(IComparer<T> wrapped) =>
_wrapped = wrapped;
public int Compare(T x, T y) =>
// reverse operands
_wrapped.Compare(y, x);
}
}