コード例 #1
0
ファイル: Compare.cs プロジェクト: lanicon/Theta
 public static Compare <T> FromComparer <T>(System.Collections.Generic.Comparer <T> comparer)
 {
     return((T a, T b) =>
     {
         int result = comparer.Compare(a, b);
         if (result == 0)
         {
             return Comparison.Equal;
         }
         else if (result < 0)
         {
             return Comparison.Less;
         }
         else if (result > 0)
         {
             return Comparison.Greater;
         }
         else
         {
             throw new System.NotImplementedException();
         }
     });
 }
コード例 #2
0
 /// <summary>Converts a System.Collection.Generic.Comparer into a Towel.Compare delegate.</summary>
 /// <typeparam name="T">The generic type that the comparing methods operate on.</typeparam>
 /// <param name="comparer">The system.Collections.Generic.Comparer to convert into a Towel.Compare delegate.</param>
 /// <returns>The converted Towel.Compare delegate.</returns>
 public static Compare <T> ToCompare <T>(System.Collections.Generic.Comparer <T> comparer) =>
 (a, b) => Wrap(comparer.Compare(a, b));