mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
made worst case quicksort run nearly impossible by using a random element
git-svn-id: http://svn.osgeo.org/qgis/trunk@279 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
78b59e91f2
commit
a94e54422a
@ -237,6 +237,10 @@ void QgsAttributeTable::qsort(int lower, int upper, int col, bool ascending, boo
|
||||
QString v;
|
||||
if(upper>lower)
|
||||
{
|
||||
//chose a random element (this avoids n^2 worst case)
|
||||
int element=double(rand())/RAND_MAX*(upper-lower)+lower;
|
||||
|
||||
swapRows(element,upper);
|
||||
v=text(upper,col);
|
||||
i=lower-1;
|
||||
j=upper;
|
||||
|
Loading…
x
Reference in New Issue
Block a user