From 441cd8345af32c3ef7d5f773453557680ccd25b3 Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Mon, 24 Jun 2019 16:22:10 +0300 Subject: [PATCH] [generator] Fixed KDTree::_M_for_any --- 3party/kdtree++/kdtree.hpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/3party/kdtree++/kdtree.hpp b/3party/kdtree++/kdtree.hpp index 08ce1a902c..3b2d8badeb 100644 --- a/3party/kdtree++/kdtree.hpp +++ b/3party/kdtree++/kdtree.hpp @@ -402,9 +402,11 @@ namespace KDTree template bool for_any(ToDo toDo) const { + bool wasСalled = false; if (_M_get_root()) - return _M_for_any(_M_get_root(), 0, toDo); - return false; + _M_for_any(_M_get_root(), 0, toDo, wasСalled); + + return wasСalled; } // compares via equality @@ -666,21 +668,24 @@ namespace KDTree } template - bool _M_for_any(_Link_const_type N, size_type const L, ToDo toDo) const + void _M_for_any(_Link_const_type N, size_type const L, ToDo toDo, bool & wasСalled) const { + if (wasСalled) + return; + if (toDo.DoIfIntersects(_S_value(N))) - return true; + { + wasСalled = true; + return; + } if (_S_left(N) && toDo.ScanLeft(L, _S_value(N))) - return _M_for_any(_S_left(N), L+1, toDo); + _M_for_any(_S_left(N), L+1, toDo, wasСalled); if (_S_right(N) && toDo.ScanRight(L, _S_value(N))) - return _M_for_any(_S_right(N), L+1, toDo); - - return false; + _M_for_any(_S_right(N), L+1, toDo, wasСalled); } - _Link_type _M_get_erase_replacement(_Link_type node, size_type const level) {