Example #1
0
        public override int Compare(T x, T y)
        {
            TKey xKey = _keySelector(x);
            TKey yKey = _keySelector(y);

            return(NullFilter.Filter(xKey, yKey) ?? Comparer.Compare(x, y));
        }
Example #2
0
        public static IComparer <T> GetComparer(IComparer <T> comparer, Func <T, TKey> keySelector, bool nullsFirst)
        {
            NullFilter <TKey> filter = NullFilterFactory.GetNullFilter <TKey>(nullsFirst);

            if (filter == null)
            {
                return(comparer);
            }
            return(new KeyedNullPlacementComparer <T, TKey>(comparer, keySelector, filter));
        }
Example #3
0
        public static IComparer <T> GetComparer(IComparer <T> comparer, bool nullsFirst)
        {
            NullFilter <T> filter = NullFilterFactory.GetNullFilter <T>(nullsFirst);

            if (filter == null)
            {
                return(comparer);
            }
            return(new UnkeyedNullPlacementComparer <T>(comparer, filter));
        }
Example #4
0
 internal KeyedNullPlacementComparer(IComparer <T> comparer, Func <T, TKey> keySelector, NullFilter <TKey> filter)
     : base(comparer, filter)
 {
     _keySelector = keySelector;
 }
Example #5
0
 public override int Compare(T x, T y)
 {
     return(NullFilter.Filter(x, y) ?? Comparer.Compare(x, y));
 }
Example #6
0
 internal UnkeyedNullPlacementComparer(IComparer <T> comparer, NullFilter <T> filter)
     : base(comparer, filter)
 {
 }
Example #7
0
 protected NullPlacementComparer(IComparer <T> comparer, NullFilter <TCompared> filter)
 {
     Comparer   = comparer;
     NullFilter = filter;
 }