Ugly Code

This is part of the quicksort algorithm in my text book.

template<class Type> 
int Partition(datalist<Type>& list, const int low, const int high)
{
    int pivotpos=low;Element<Type> pivot=list.Vector[low];
    for(int i=low+1;i<=high;i++)
        if(list.Vector[i].getKey()<pivot.getKey() && ++pivotpos!=i) //terrible expression
            Swap(list.Vector[pivotpos], list.Vector[i]);
    Swap(list.Vector[low],list.Vector[pivotpos]);
    return pivotpos;
}
Page tags: code
page_revision: 0, last_edited: 1199625298|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License