Fix bug in insertion sort algorithm

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8105 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2011-03-29 22:03:02 +00:00
parent 2e3a953004
commit 952a8ed312

View File

@@ -251,7 +251,9 @@ public:
// ------------------------------------------------------------------------
void insertionSort(unsigned int start=0)
{
for(unsigned int j=start; j<(unsigned)m_contents_vector.size()-1; j++)
// We should not used unsigned ints here, because if the vector is empty
// j needs to be compared against -1
for(int j=(int)start; j<(int)m_contents_vector.size()-1; j++)
{
if(*(m_contents_vector[j])<*(m_contents_vector[j+1])) continue;
// Now search the proper place for m_contents_vector[j+1]