예제 #1
0
 private static Comparer <T> Create()
 {
     // The compiler will overwrite the Create method with optimized
     // instantiation-specific implementation.
     // This body serves as a fallback when instantiation-specific implementation is unavailable.
     return(_default = ComparerHelpers.GetUnknownComparer <T>());
 }
예제 #2
0
 private static Comparer <T> Create()
 {
     // The compiler will overwrite the Create method with optimized
     // instantiation-specific implementation.
     // This body serves as a fallback when instantiation-specific implementation is unavailable.
     Interlocked.CompareExchange(ref s_default, Unsafe.As <Comparer <T> >(ComparerHelpers.GetComparer(typeof(T).TypeHandle)), null);
     return(s_default);
 }
예제 #3
0
파일: Comparer.cs 프로젝트: samcov/corert
        private static Comparer <T> Create()
        {
#if PROJECTN
            // The compiler will overwrite the Create method with optimized
            // instantiation-specific implementation.
            throw new NotSupportedException();
#else
            // The compiler will overwrite the Create method with optimized
            // instantiation-specific implementation.
            // This body serves as a fallback when instantiation-specific implementation is unavailable.
            return(_default = ComparerHelpers.GetUnknownComparer <T>());
#endif
        }
예제 #4
0
 private static Comparer <T> Create()
 {
     // The compiler will overwrite the Create method with optimized
     // instantiation-specific implementation.
     // This body serves as a fallback when instantiation-specific implementation is unavailable.
     // If that happens, the compiler ensures we generate data structures to make the fallback work
     // when this method is compiled.
     Interlocked.CompareExchange(ref s_default,
                                 SupportsGenericIComparableInterfaces
         ? Unsafe.As <Comparer <T> >(ComparerHelpers.GetComparer(typeof(T).TypeHandle))
         : new ObjectComparer <T>(),
                                 null);
     return(s_default);
 }
예제 #5
0
 public sealed override int Compare(T x, T y)
 {
     return(ComparerHelpers.CompareObjects(x, y));
 }
예제 #6
0
 public override int Compare(T x, T y)
 {
     return(ComparerHelpers.EnumOnlyCompare(x, y));
 }