Пример #1
0
        public static void Sort(Func <long, long> value, Action <long, long> swap, long left, long right)
        {
            if (left >= right)
            {
                return;
            }
            Stack <QuickSort.Pair> pairStack = new Stack <QuickSort.Pair>();

            pairStack.Push(new QuickSort.Pair(left, right));
            while (pairStack.Count > 0)
            {
                QuickSort.Pair pair = pairStack.Pop();
                long           num  = QuickSort.Partition(value, swap, pair.Left, pair.Right);
                if (pair.Left < num)
                {
                    pairStack.Push(new QuickSort.Pair(pair.Left, num - 1L));
                }
                if (num < pair.Right)
                {
                    pairStack.Push(new QuickSort.Pair(num + 1L, pair.Right));
                }
            }
        }
Пример #2
0
 public Pair(long left, long right)
 {
     this       = new QuickSort.Pair();
     this.Left  = left;
     this.Right = right;
 }