Ver código fonte

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

undefined
Sam Hocevar 10 anos atrás
pai
commit
4d298c9e39
1 arquivos alterados com 3 adições e 3 exclusões
  1. +3
    -3
      src/lol/algorithm/sort.h

+ 3
- 3
src/lol/algorithm/sort.h Ver arquivo

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


Carregando…
Cancelar
Salvar