Beispiel #1
0
        public void SwapBar(int index1, int index2)
        {
            SortBar temp = DataValue[index1];

            DataValue[index1].MoveBar(index2);
            DataValue[index2].MoveBar(index1);
            DataValue[index1] = DataValue[index2];
            DataValue[index2] = temp;
        }
Beispiel #2
0
        public void AdjustHeap(int i, int length)
        {
            SortBar temp = dataSet.DataValue[i];

            for (int k = i * 2 + 1; k < length; k = k * 2 + 1)
            {
                if (k + 1 < length && dataSet.DataValue[k] < dataSet.DataValue[k + 1])
                {
                    k++;//如果左子结点小于右子结点,k指向右子结点
                }
                this.Dispatcher.Invoke(new Action(() => { dataSet.IndicateA.MoveBar(i); dataSet.IndicateB.MoveBar(k); }));
                Thread.Sleep(Settings.TimeSpanMs);
                if (dataSet.DataValue[k] > temp)
                {
                    SwapAnimation(i, k); i = k;
                }
                else
                {
                    break;
                }
            }
        }