57 template <
typename P, std::
size_t D>
61 explicit Node(P pt) : m_point(pt), m_left(nullptr), m_right(nullptr) {}
69 auto refval = m_point.template Get<D>();
70 auto testval = point.template Get<D>();
71 if (testval <= refval) {
80 auto refval = m_point.template Get<D>();
81 auto testval = point.template Get<D>();
82 if (testval <= refval) {
83 m_left = std::make_unique<Child>(point);
85 m_right = std::make_unique<Child>(point);
89 P
GetPoint()
const override {
return m_point; }
void AddChild(P point) override
Add a new child in the right place, according to split.
P GetPoint() const override
Gets the point for this node.
BaseNode< P > * BorrowSplitChild(const P &point) const override
Get a non-owning pointer to the child corresponding to the correct split for point.
A k-d tree: a k-dimensional generalization of binary search trees This data structure allows for effi...
virtual BaseNode< P > * BorrowRight() const =0
Get a non-owning pointer to the right child (nullptr if no such child).
virtual BaseNode< P > * BorrowSplitChild(const P &point) const =0
Get a non-owning pointer to the child corresponding to the correct split for point.
A node in the KdTree (parameter P: the type of point, parameter D: dimension this node splits on)...
virtual ~BaseNode()=default
std::unique_ptr< Child > m_right
Namespace for the geographic and demograhic classes.
virtual P GetPoint() const =0
Gets the point for this node.
virtual void AddChild(P point)=0
Add a new child in the right place, according to split.
virtual BaseNode< P > * BorrowLeft() const =0
Get a non-owning pointer to the left child (nullptr if no such child).
BaseNode< P > * BorrowLeft() const override
Get a non-owning pointer to the left child (nullptr if no such child).
BaseNode< P > * BorrowRight() const override
Get a non-owning pointer to the right child (nullptr if no such child).
A base class for all instantiations of a Node with D.