示例#1
0
 public AsyncSortSequenceContext(
     AsyncSortContext <TElement> childContext,
     Func <TElement, Task <TKey> > keySelector,
     IComparer <TKey> comparer,
     bool descending
     )
     : base(childContext, @descending)
 {
     this.keySelector = keySelector;
     this.comparer    = comparer;
 }
示例#2
0
        internal override AsyncSortContext <TElement> CreateContext(AsyncSortContext <TElement> current)
        {
            AsyncSortContext <TElement> context = new AsyncSortSequenceContext <TElement, TKey> (current, keySelector, comparer, descending);

            return(parent != null?parent.CreateContext(context) : context);
        }
示例#3
0
 internal abstract AsyncSortContext <TValue> CreateContext(AsyncSortContext <TValue> current);
示例#4
0
 private QuickSort(IEnumerable <TElement> source, AsyncSortContext <TElement> context)
 {
     this.elements = source.ToArray();
     this.indexes  = CreateIndexes(elements.Length);
     this.context  = context;
 }
示例#5
0
        internal static async Task <IEnumerable <TElement> > Sort(IEnumerable <TElement> source, AsyncSortContext <TElement> context)
        {
            var sorter = new QuickSort <TElement>(source, context);

            await sorter.PerformSort().ConfigureAwait(false);

            var result = new TElement[sorter.indexes.Length];

            for (var i = 0; i < sorter.indexes.Length; i++)
            {
                result[i] = sorter.elements[sorter.indexes[i]];
            }

            return(result);
        }
示例#6
0
 protected AsyncSortContext(AsyncSortContext <TElement> childContext, bool descending)
 {
     this.childContext = childContext;
     this.descending   = descending;
 }