示例#1
0
		public void Sort(cell_aa[] dataToSort, int beg, int end)
		{
			if (end == beg)
			{
				return;
			}
			else
			{
				int pivot = getPivotPoint(dataToSort, beg, end);
				if (pivot > beg)
				{
					Sort(dataToSort, beg, pivot - 1);
				}

				if (pivot < end)
				{
					Sort(dataToSort, pivot + 1, end);
				}
			}
		}
示例#2
0
        private int getPivotPoint(cell_aa[] dataToSort, int begPoint, int endPoint)
        {
            int pivot = begPoint;
            int m     = begPoint + 1;
            int n     = endPoint;

            while ((m < endPoint) &&
                   dataToSort[pivot].x >= dataToSort[m].x)
            {
                m++;
            }

            while ((n > begPoint) && (dataToSort[pivot].x <= dataToSort[n].x))
            {
                n--;
            }
            while (m < n)
            {
                cell_aa temp = dataToSort[m];
                dataToSort[m] = dataToSort[n];
                dataToSort[n] = temp;

                while ((m < endPoint) && (dataToSort[pivot].x >= dataToSort[m].x))
                {
                    m++;
                }

                while ((n > begPoint) && (dataToSort[pivot].x <= dataToSort[n].x))
                {
                    n--;
                }
            }
            if (pivot != n)
            {
                cell_aa temp2 = dataToSort[n];
                dataToSort[n]     = dataToSort[pivot];
                dataToSort[pivot] = temp2;
            }
            return(n);
        }
示例#3
0
		private int getPivotPoint(cell_aa[] dataToSort, int begPoint, int endPoint)
		{
			int pivot = begPoint;
			int m = begPoint + 1;
			int n = endPoint;
			while ((m < endPoint)
				&& dataToSort[pivot].x >= dataToSort[m].x)
			{
				m++;
			}

			while ((n > begPoint) && (dataToSort[pivot].x <= dataToSort[n].x))
			{
				n--;
			}
			while (m < n)
			{
				cell_aa temp = dataToSort[m];
				dataToSort[m] = dataToSort[n];
				dataToSort[n] = temp;

				while ((m < endPoint) && (dataToSort[pivot].x >= dataToSort[m].x))
				{
					m++;
				}

				while ((n > begPoint) && (dataToSort[pivot].x <= dataToSort[n].x))
				{
					n--;
				}
			}
			if (pivot != n)
			{
				cell_aa temp2 = dataToSort[n];
				dataToSort[n] = dataToSort[pivot];
				dataToSort[pivot] = temp2;
			}
			return n;
		}
示例#4
0
		public void Sort(cell_aa[] dataToSort)
		{
			Sort(dataToSort, 0, (int)(dataToSort.Length - 1));
		}