Browse Source

avl_tree: moving file in algorithm, adding empty test file and fixing compilation

undefined
Guillaume Bittoun Sam Hocevar <sam@hocevar.net> 10 years ago
parent
commit
7f54caf3c6
4 changed files with 17 additions and 11 deletions
  1. +1
    -1
      src/Makefile.am
  2. +1
    -0
      src/lol/algorithm/all.h
  3. +9
    -9
      src/lol/algorithm/avl_tree.h
  4. +6
    -1
      src/t/Makefile.am

+ 1
- 1
src/Makefile.am View File

@@ -47,7 +47,7 @@ liblolcore_headers = \
lol/math/transform.h \
\
lol/algorithm/all.h \
lol/algorithm/sort.h lol/algorithm/portal.h lol/algorithm/aabb_tree.h \
lol/algorithm/sort.h lol/algorithm/portal.h lol/algorithm/aabb_tree.h lol/algorithm/avl_tree.h \
\
lol/sys/all.h \
lol/sys/init.h lol/sys/file.h lol/sys/thread.h lol/sys/timer.h \


+ 1
- 0
src/lol/algorithm/all.h View File

@@ -12,5 +12,6 @@

#include <lol/algorithm/sort.h>
#include <lol/algorithm/aabb_tree.h>
#include <lol/algorithm/avl_tree.h>
#include <lol/algorithm/portal.h>


src/lol/base/avl_tree.h → src/lol/algorithm/avl_tree.h View File

@@ -56,9 +56,9 @@ private:
m_key(key),
m_value(value),
m_lo(0),
m_hi(0)
m_hi(0),
m_stairs_lo(0),
m_stairs_hi(0),
m_stairs_hi(0)
{
}

@@ -89,9 +89,9 @@ private:
int path_update_balance(K const & key)
{
if (key < this->m_key)
this->m_stairs_lo = lol::max(this->m_lo->path_update_balance(node), this->m_stairs_lo);
this->m_stairs_lo = lol::max(this->m_lo->path_update_balance(key), this->m_stairs_lo);
else if (this->m_key < key)
this->m_stairs_hi = lol::max(this->m_hi->path_update_balance(node), this->m_stairs_hi);
this->m_stairs_hi = lol::max(this->m_hi->path_update_balance(key), this->m_stairs_hi);

return lol::max(this->m_stairs_lo, this->m_stairs_hi) + 1;
}
@@ -104,7 +104,7 @@ private:
if (node)
{
this->m_lo = node;
--this->m_lo;
--this->m_stairs_lo;
}
}
else if (this->m_key < key)
@@ -113,7 +113,7 @@ private:
if (node)
{
this->m_hi = node;
--this->m_hi;
--this->m_stairs_hi;
}
}

@@ -142,7 +142,7 @@ private:
this->m_lo = lo_hi;

this->compute_balance();
lo_hi->compute_balance();
lo->compute_balance();

return lo;
}
@@ -155,9 +155,9 @@ private:
this->m_hi = hi_lo;

this->compute_balance();
hi_lo->compute_balance();
hi->compute_balance();

return lo;
return hi;
}

return 0;

+ 6
- 1
src/t/Makefile.am View File

@@ -7,9 +7,14 @@ TESTS = $(testsuite)

# Conditionally built for now because of STLport issues
if !USE_ANDROID
testsuite = test-base test-math test-sys test-image test-entity
testsuite = test-algorithm test-base test-math test-sys test-image test-entity
endif

test_algorithm_SOURCES = test-common.cpp \
algorithm/avl_tree.cpp
test_algorithm_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tools/lolunit
test_algorithm_DEPENDENCIES = @LOL_DEPS@

test_base_SOURCES = test-common.cpp \
base/array.cpp base/enum.cpp base/map.cpp base/string.cpp \
base/types.cpp


Loading…
Cancel
Save