7 #ifndef INCLUDE_KDTREE_REGION_HPP 8 #define INCLUDE_KDTREE_REGION_HPP 17 template <
size_t const __K,
typename _Val,
typename _SubVal,
18 typename _Acc,
typename _Cmp>
21 typedef _Val value_type;
22 typedef _SubVal subvalue_type;
27 typedef std::pair<_Region,_SubVal> _CenterPt;
29 _Region(_Acc
const& __acc=_Acc(),
const _Cmp& __cmp=_Cmp())
30 : _M_cmp(__acc), _M_acc(__cmp) {}
32 template <
typename Val>
34 _Acc
const& __acc=_Acc(),
const _Cmp& __cmp=_Cmp())
35 : _M_acc(__acc), _M_cmp(__cmp)
37 for (
size_t __i = 0; __i != __K; ++__i)
39 _M_low_bounds[__i] = _M_high_bounds[__i] = _M_acc(__V,__i);
43 template <
typename Val>
44 _Region(Val
const& __V, subvalue_type
const& __R,
45 _Acc
const& __acc=_Acc(),
const _Cmp& __cmp=_Cmp())
46 : _M_acc(__acc), _M_cmp(__cmp)
48 for (
size_t __i = 0; __i != __K; ++__i)
50 _M_low_bounds[__i] = _M_acc(__V,__i) - __R;
51 _M_high_bounds[__i] = _M_acc(__V,__i) + __R;
56 intersects_with(_CenterPt
const& __THAT)
const 58 for (
size_t __i = 0; __i != __K; ++__i)
66 if (_M_cmp(__THAT.first._M_low_bounds[__i], _M_low_bounds[__i] - __THAT.second)
67 || _M_cmp(_M_high_bounds[__i] + __THAT.second, __THAT.first._M_low_bounds[__i]))
74 intersects_with(
_Region const& __THAT)
const 76 for (
size_t __i = 0; __i != __K; ++__i)
78 if (_M_cmp(__THAT._M_high_bounds[__i], _M_low_bounds[__i])
79 || _M_cmp(_M_high_bounds[__i], __THAT._M_low_bounds[__i]))
86 encloses(value_type
const& __V)
const 88 for (
size_t __i = 0; __i != __K; ++__i)
90 if (_M_cmp(_M_acc(__V, __i), _M_low_bounds[__i])
91 || _M_cmp(_M_high_bounds[__i], _M_acc(__V, __i)))
98 set_high_bound(value_type
const& __V,
size_t const __L)
100 _M_high_bounds[__L % __K] = _M_acc(__V, __L % __K);
105 set_low_bound(value_type
const& __V,
size_t const __L)
107 _M_low_bounds[__L % __K] = _M_acc(__V, __L % __K);
111 subvalue_type _M_low_bounds[__K], _M_high_bounds[__K];
118 #endif // include guard Definition: region.hpp:19
Defines interfaces for nodes as used by the KDTree class.
Definition: allocator.hpp:14