Esempio n. 1
0
        static Tshirt[] SizeDesc()
        {
            Tshirt[] shirts = PrepareSignature(out int n);
            //instatiate the delegate
            QuickSortDelegate sortingDelegate = QuickSortHardCoded.SizeDesc;

            //call the delegate
            sortingDelegate(shirts, 0, n);

            return(shirts);
        }
Esempio n. 2
0
        public static void Sort(FixedArray moves)
        {
            if (moves.Size == 0)
            {
                return;
            }

            QuickSortDelegate quicksort = null;

            quicksort =
                (items, first, last) =>
            {
                int left  = first;
                int right = last;
                int mid   = items[(left + right) >> 1].Value;

                while (left <= right)
                {
                    while (items[left].Value > mid)
                    {
                        ++left;
                    }

                    while (items[right].Value < mid)
                    {
                        --right;
                    }

                    if (left <= right)
                    {
                        var tempItem = items[left];
                        items[left]  = items[right];
                        items[right] = tempItem;

                        ++left;
                        --right;
                    }
                }

                if (first < right)
                {
                    quicksort(items, first, right);
                }

                if (left < last)
                {
                    quicksort(items, left, last);
                }
            };

            quicksort(moves.InnerArray, 0, moves.Size - 1);
        }