internal static INodeComparer <TResult, TStep> CreateComparer <TResult, TKey, TStep>(Func <TResult, TKey> keySelector, IComparer <TKey> keyComparer, bool descending) { if (keyComparer != null) { return(new NormalComparer <TStep, TResult, TKey>(keySelector, keyComparer, descending)); } var comparer = default(INodeComparer <TResult, TStep>); switch (Type.GetTypeCode(typeof(TKey))) { case TypeCode.Byte: case TypeCode.Decimal: case TypeCode.Double: case TypeCode.Int16: case TypeCode.Int32: case TypeCode.Int64: case TypeCode.SByte: case TypeCode.Single: case TypeCode.UInt16: case TypeCode.UInt32: case TypeCode.UInt64: comparer = new HeuristicComparer <TStep, TResult, TKey>(keySelector, descending); break; default: comparer = new NormalComparer <TStep, TResult, TKey>(keySelector, null, descending); break; } return(comparer); }
internal HeuristicSearchOrderBy <TFactor, TStep> CreateOrderedEnumerable(Func <TFactor, double> keySelector, bool descending) { if (keySelector == null) { throw new ArgumentNullException(nameof(keySelector)); } var comparer1 = _nodeComparer; var comparer2 = new HeuristicComparer <TFactor, TStep>(keySelector, descending); _nodeComparer = new CombinedComparer <TFactor, TStep>(comparer1, comparer2); return(this); }