Ejemplo n.º 1
0
        static public void Sort8(T[] Arr, IMerger <T> merger = null)
        {
            if (merger == null)
            {
                merger = new Merger <T>();
            }

            var half = Arr.Length >> 1;

            var tail = Arr.Length - half;

            var t1 = Task.Run(() => { var o = new ParallelSort <T>();  o._Sort4(Arr, 0, half, merger); });
            var t2 = Task.Run(() => { var o = new ParallelSort <T>();  o._Sort4(Arr, half, tail, merger); });

            Task.WaitAll(t1, t2);

            merger.Merge(Arr, 0, half, tail);
        }
Ejemplo n.º 2
0
        static public async Task Sort8Async(T[] Arr, IMerger <T> merger = null)
        {
            if (merger == null)
            {
                merger = new Merger <T>();
            }

            var half = Arr.Length >> 1;

            var tail = Arr.Length - half;

            var o1 = new ParallelSort <T>();
            var o2 = new ParallelSort <T>();
            await o1._Sort4Async(Arr, 0, half, merger);

            await o2._Sort4Async(Arr, half, tail, merger);

            await Task.Run(() => { merger.Merge(Arr, 0, half, tail); });
        }