diff options
Diffstat (limited to 'meowpp/dsa/VP_Tree.hpp')
-rw-r--r-- | meowpp/dsa/VP_Tree.hpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/meowpp/dsa/VP_Tree.hpp b/meowpp/dsa/VP_Tree.hpp index 2026050..bb6b5f1 100644 --- a/meowpp/dsa/VP_Tree.hpp +++ b/meowpp/dsa/VP_Tree.hpp @@ -69,8 +69,6 @@ namespace meow{ VP_Tree<Vector, Scalar>::split(ssize_t __first, ssize_t __last, size_t __order, Vector const& __center){ ssize_t first0 = __first; - ssize_t last0 = __last; - ssize_t order0 = __order; std::vector<Scalar> dist2(__last - __first + 1); for(ssize_t i = __first; i <= __last; i++){ dist2[i - first0] = distance2(_vectors[i], __center); @@ -79,10 +77,10 @@ namespace meow{ size_t threshold_index = __first + rand() % (__last - __first + 1); Scalar threshold(dist2[threshold_index - first0]); size_t large_first = __last + 1; - for(size_t i = __first; __first <= large_first - 1; large_first--){ + for(ssize_t i=__first; __first<=(ssize_t)large_first-1; large_first--){ if(threshold < dist2[large_first - 1 - first0]) continue; - while(i < large_first - 1 && !(threshold < dist2[i - first0])) i++; - if(i < large_first - 1){ + while(i < (ssize_t)large_first-1&&!(threshold < dist2[i-first0])) i++; + if(i < (ssize_t)large_first - 1){ std::swap(dist2 [large_first - 1 - first0], dist2 [i - first0]); std::swap(_vectors[large_first - 1 ], _vectors[i ]); i++; @@ -90,10 +88,10 @@ namespace meow{ break; } } - if(large_first == __last + 1){ + if(large_first == (size_t)__last + 1){ std::swap(dist2 [threshold_index-first0], dist2 [__last-first0]); std::swap(_vectors[threshold_index ], _vectors[__last ]); - if(__order == __last - __first){ + if((ssize_t)__order == __last - __first){ __first = __last; break; } @@ -182,15 +180,18 @@ namespace meow{ template<class Vector, class Scalar> inline VP_Tree<Vector, Scalar>::VP_Tree(VP_Tree<Vector, Scalar> const& __tree2): - _root(dup(__tree2._root)), _vectors(__tree2._vectors), + _root(dup(__tree2._root)), _dimension(__tree2._dimension), _needRebuild(__tree2._needRebuild){ } template<class Vector, class Scalar> inline VP_Tree<Vector, Scalar>::VP_Tree(size_t __dimension): - _root(NULL), _vectors(0), _dimension(0), _needRebuild(false){ + _vectors(0), + _root(NULL), + _dimension(0), + _needRebuild(false){ reset(__dimension); } template<class Vector, class Scalar> |