Browse Source

algorithm: tweak the sort routines so that they only use the "<" operator.

undefined
Sam Hocevar 10 years ago
parent
commit
4d298c9e39
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      src/lol/algorithm/sort.h

+ 3
- 3
src/lol/algorithm/sort.h View File

@@ -27,7 +27,7 @@ void ArrayBase<T, ARRAY>::Sort(int sort)
int d = 1; int d = 1;
for (int i = 0; i < Count() - 1; i = lol::max(i + d, 0)) for (int i = 0; i < Count() - 1; i = lol::max(i + d, 0))
{ {
if (m_data[i] < m_data[i + 1] || i <= 0)
if (i <= 0 || m_data[i] < m_data[i + 1])
d = 1; d = 1;
if (m_data[i + 1] < m_data[i]) if (m_data[i + 1] < m_data[i])
{ {
@@ -72,7 +72,7 @@ void ArrayBase<T, ARRAY>::SortQuickSwap(int start, int stop)
bool swap = false; bool swap = false;
while (i0 < i1) while (i0 < i1)
{ {
if (m_data[i0] >= median && m_data[i1] < median)
if (!(m_data[i0] < median) && m_data[i1] < median)
{ {
Swap(i0, i1); Swap(i0, i1);
i0++; i0++;
@@ -83,7 +83,7 @@ void ArrayBase<T, ARRAY>::SortQuickSwap(int start, int stop)
{ {
if (m_data[i0] < median) if (m_data[i0] < median)
i0++; i0++;
if (m_data[i1] >= median)
if (!(m_data[i1] < median))
i1--; i1--;
} }
} }


Loading…
Cancel
Save