Bläddra i källkod

avl_tree: moving avl_tree implementation in lol/base.

undefined
Guillaume Bittoun Sam Hocevar <sam@hocevar.net> 10 år sedan
förälder
incheckning
022e686f5b
6 ändrade filer med 11 tillägg och 30 borttagningar
  1. +3
    -3
      src/Makefile.am
  2. +0
    -1
      src/lol/algorithm/all.h
  3. +1
    -0
      src/lol/base/all.h
  4. +4
    -18
      src/lol/base/avl_tree.h
  5. +3
    -8
      src/t/Makefile.am
  6. +0
    -0
      src/t/base/avl_tree.cpp

+ 3
- 3
src/Makefile.am Visa fil

@@ -36,8 +36,8 @@ liblolcore_headers = \
lol/engine-internal.h lol/engine.h lol/public.h lol/extras.h \
\
lol/base/all.h \
lol/base/features.h lol/base/tuple.h lol/base/types.h lol/base/array.h \
lol/base/assert.h lol/base/string.h lol/base/hash.h lol/base/map.h \
lol/base/avl_tree.h lol/base/features.h lol/base/tuple.h lol/base/types.h \
lol/base/array.h lol/base/assert.h lol/base/string.h lol/base/hash.h lol/base/map.h \
lol/base/enum.h lol/base/log.h \
\
lol/math/all.h \
@@ -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/avl_tree.h \
lol/algorithm/sort.h lol/algorithm/portal.h lol/algorithm/aabb_tree.h \
\
lol/sys/all.h \
lol/sys/init.h lol/sys/file.h lol/sys/thread.h lol/sys/timer.h \


+ 0
- 1
src/lol/algorithm/all.h Visa fil

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

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


+ 1
- 0
src/lol/base/all.h Visa fil

@@ -10,6 +10,7 @@

#pragma once

#include <lol/base/avl_tree.h>
#include <lol/base/features.h>
#include <lol/base/types.h>
#include <lol/base/log.h>


src/lol/algorithm/avl_tree.h → src/lol/base/avl_tree.h Visa fil

@@ -15,6 +15,8 @@
namespace lol
{

#include <lol/base/all.h>

template<typename K, typename V>
class avl_tree
{
@@ -330,8 +332,8 @@ protected:

void update_balance()
{
this->m_stairs[0] = this->m_child[0] ? lol::max(this->m_child[0]->m_stairs[0], this->m_child[0]->m_stairs[1]) + 1 : 0;
this->m_stairs[1] = this->m_child[1] ? lol::max(this->m_child[1]->m_stairs[0], this->m_child[1]->m_stairs[1]) + 1 : 0;
this->m_stairs[0] = this->m_child[0] ? (this->m_child[0]->m_stairs[0] > this->m_child[0]->m_stairs[1] ? this->m_child[0]->m_stairs[0] : this->m_child[0]->m_stairs[1]) + 1 : 0;
this->m_stairs[1] = this->m_child[1] ? (this->m_child[1]->m_stairs[0] > this->m_child[1]->m_stairs[1] ? this->m_child[1]->m_stairs[0] : this->m_child[1]->m_stairs[1]) + 1 : 0;
}

void rebalance_if_needed()
@@ -459,8 +461,6 @@ public:

Iterator & operator++(int)
{
ASSERT(this->m_node);

this->m_node = this->m_node->get_next();

return *this;
@@ -468,8 +468,6 @@ public:

Iterator & operator--(int)
{
ASSERT(this->m_node);

this->m_node = this->m_node->get_previous();

return *this;
@@ -477,8 +475,6 @@ public:

Iterator operator++()
{
ASSERT(this->m_node);

tree_node * ret = this->m_node;
this->m_node = this->m_node->get_next();

@@ -487,8 +483,6 @@ public:

Iterator operator--()
{
ASSERT(this->m_node);

tree_node * ret = this->m_node;
this->m_node = this->m_node->get_previous();

@@ -533,8 +527,6 @@ public:

ConstIterator & operator++(int)
{
ASSERT(this->m_node);

this->m_node = this->m_node->get_next();

return *this;
@@ -542,8 +534,6 @@ public:

ConstIterator & operator--(int)
{
ASSERT(this->m_node);

this->m_node = this->m_node->get_previous();

return *this;
@@ -551,8 +541,6 @@ public:

ConstIterator operator++()
{
ASSERT(this->m_node);

tree_node * ret = this->m_node;
this->m_node = this->m_node->get_next();

@@ -561,8 +549,6 @@ public:

ConstIterator operator--()
{
ASSERT(this->m_node);

tree_node * ret = this->m_node;
this->m_node = this->m_node->get_previous();


+ 3
- 8
src/t/Makefile.am Visa fil

@@ -7,17 +7,12 @@ TESTS = $(testsuite)

# Conditionally built for now because of STLport issues
if !USE_ANDROID
testsuite = test-algorithm test-base test-math test-sys test-image test-entity
testsuite = 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
base/avl_tree.cpp base/array.cpp base/enum.cpp base/map.cpp \
base/string.cpp base/types.cpp
test_base_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tools/lolunit
test_base_DEPENDENCIES = @LOL_DEPS@



src/t/algorithm/avl_tree.cpp → src/t/base/avl_tree.cpp Visa fil


Laddar…
Avbryt
Spara