Example #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;
 }
Example #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);
        }
 internal abstract AsyncSortContext <TValue> CreateContext(AsyncSortContext <TValue> current);
Example #4
0
 private QuickSort(IEnumerable <TElement> source, AsyncSortContext <TElement> context)
 {
     this.elements = source.ToArray();
     this.indexes  = CreateIndexes(elements.Length);
     this.context  = context;
 }
Example #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);
        }
Example #6
0
 protected AsyncSortContext(AsyncSortContext <TElement> childContext, bool descending)
 {
     this.childContext = childContext;
     this.descending   = descending;
 }