Exemplo n.º 1
0
        public static HeuristicSearchOrderBy <TResult, TStep> OrderByDescending <TResult, TKey, TStep>(this HeuristicSearchBase <TResult, TStep> source, Func <TResult, TKey> keySelector, IComparer <TKey> comparer)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (keySelector == null)
            {
                throw new ArgumentNullException(nameof(keySelector));
            }

            return(new HeuristicSearchOrderBy <TResult, TStep>(source, HeuristicSearch.CreateComparer <TResult, TKey, TStep>(keySelector, comparer, true)));
        }
        public HeuristicSearchOrderBy <TResult, TStep> CreateOrderedEnumerable <TKey>(Func <TResult, TKey> keySelector, IComparer <TKey> comparer, bool descending)
        {
            if (keySelector == null)
            {
                throw new ArgumentNullException(nameof(keySelector));
            }

            var comparer1 = _nodeComparer;
            var comparer2 = HeuristicSearch.CreateComparer <TResult, TKey, TStep>(keySelector, comparer, descending);

            _nodeComparer = new CombinedComparer <TResult, TStep>(comparer1, comparer2);

            return(this);
        }