21 typedef _Node_base* _Base_ptr;
22 typedef _Node_base
const* _Base_const_ptr;
28 _Node_base(_Base_ptr
const __PARENT = NULL,
29 _Base_ptr
const __LEFT = NULL,
30 _Base_ptr
const __RIGHT = NULL)
31 : _M_parent(__PARENT), _M_left(__LEFT), _M_right(__RIGHT) {}
34 _S_minimum(_Base_ptr __x)
36 while (__x->_M_left) __x = __x->_M_left;
41 _S_maximum(_Base_ptr __x)
43 while (__x->_M_right) __x = __x->_M_right;
49 struct _Node :
public _Node_base
51 using _Node_base::_Base_ptr;
52 typedef _Node* _Link_type;
56 _Node(_Val
const& __VALUE = _Val(),
57 _Base_ptr
const __PARENT = NULL,
58 _Base_ptr
const __LEFT = NULL,
59 _Base_ptr
const __RIGHT = NULL)
60 : _Node_base(__PARENT, __LEFT, __RIGHT), _M_value(__VALUE) {}
62#ifdef KDTREE_DEFINE_OSTREAM_OPERATORS
64 template <
typename Char,
typename Traits>
66 std::basic_ostream<Char, Traits>&
67 operator<<(
typename std::basic_ostream<Char, Traits>& out,
68 _Node_base
const& node)
71 out <<
" parent: " << node._M_parent;
72 out <<
"; left: " << node._M_left;
73 out <<
"; right: " << node._M_right;
77 template <
typename Char,
typename Traits>
79 std::basic_ostream<Char, Traits>&
80 operator<<(
typename std::basic_ostream<Char, Traits>& out,
81 _Node<_Val>
const& node)
84 out <<
' ' << node._M_value;
85 out <<
"; parent: " << node._M_parent;
86 out <<
"; left: " << node._M_left;
87 out <<
"; right: " << node._M_right;
201 const _Node<_Val>* __best,
typename _Dist::distance_type __max,
202 const _Cmp& __cmp,
const _Acc& __acc,
const _Dist& __dist,
207 size_t cur_dim = __dim+1;
211 if (__p(
static_cast<const _Node<_Val>*
>(cur)->_M_value))
213 typename _Dist::distance_type d = 0;
214 for (
size_t i=0; i != __k; ++i)
241 size_t probe_dim = cur_dim;
243 near_node = probe->_M_right;
245 near_node = probe->_M_left;
259 near_node = probe->_M_left;
260 far_node = probe->_M_right;
264 near_node = probe->_M_right;
265 far_node = probe->_M_left;
267 if (pprobe == probe->_M_parent)
269 if (__p(
static_cast<const _Node<_Val>*
>(probe)->_M_value))
271 typename _Dist::distance_type d = 0;
272 for (
size_t i=0; i < __k; ++i)
297 probe = probe->_M_parent;
303 if (pprobe == near_node && far_node
314 probe = probe->_M_parent;
320 cur = cur->_M_parent;
327 if (pcur == cur->_M_left)
328 near_node = cur->_M_right;
330 near_node = cur->_M_left;
340 return std::pair<const _Node<_Val>*,
341 std::pair<size_t, typename _Dist::distance_type> >
342 (__best, std::pair<size_t, typename _Dist::distance_type>
std::pair< const _Node< _Val > *, std::pair< size_t, typename _Dist::distance_type > > _S_node_nearest(const size_t __k, size_t __dim, SearchVal const &__val, const _Node< _Val > *__node, const _Node_base *__end, const _Node< _Val > *__best, typename _Dist::distance_type __max, const _Cmp &__cmp, const _Acc &__acc, const _Dist &__dist, _Predicate __p)
Definition node.hpp:199