public void Sort(VectorPODRangeAdaptor dataToSort, uint beg, uint end) { if (end == beg) { return; } else { uint pivot = GetPivotPoint(dataToSort, beg, end); if (pivot > beg) { Sort(dataToSort, beg, pivot - 1); } if (pivot < end) { Sort(dataToSort, pivot + 1, end); } } }
private uint GetPivotPoint(VectorPODRangeAdaptor dataToSort, uint begPoint, uint endPoint) { uint pivot = begPoint; uint m = begPoint + 1; uint n = endPoint; while ((m < endPoint) && dataToSort[pivot] >= dataToSort[m]) { m++; } while ((n > begPoint) && (dataToSort[pivot] <= dataToSort[n])) { n--; } while (m < n) { uint temp = dataToSort[m]; dataToSort[m] = dataToSort[n]; dataToSort[n] = temp; while ((m < endPoint) && (dataToSort[pivot] >= dataToSort[m])) { m++; } while ((n > begPoint) && (dataToSort[pivot] <= dataToSort[n])) { n--; } } if (pivot != n) { uint temp2 = dataToSort[n]; dataToSort[n] = dataToSort[pivot]; dataToSort[pivot] = temp2; } return(n); }
public void Sort(VectorPODRangeAdaptor dataToSort) { Sort(dataToSort, 0, (uint)(dataToSort.Size() - 1)); }