47 static_assert(P::dim > 0,
"Cannot have points in 0 dimensions");
65 void Apply(std::function<
bool(
const P&)> f)
const;
72 void Apply(std::function<
bool(
const P&)> f,
const AABBox<P>& box)
const;
98 std::vector<P>
Query(
const AABBox<P>& box)
const;
101 std::size_t
Size()
const;
104 template <std::
size_t D>
105 static std::unique_ptr<kd::Node<P, D>>
Construct(
const std::vector<P>& points);
bool Empty() const
Is the tree empty.
static std::unique_ptr< kd::Node< P, D > > Construct(const std::vector< P > &points)
std::size_t Size() const
Get the size of the tree.
std::size_t m_size
The number of points in the tree.
void Insert(P point)
Insert a new point into the tree, using this often may result in an unbalanced tree.
std::size_t GetHeight() const
Get the height of the tree (mostly for testing purposes).
KdTree()
Constructor: builds an empty tree.
Namespace for the geographic and demograhic classes.
std::unique_ptr< kd::Node< P, 0 > > m_root
The root node of the tree.
std::vector< P > Query(const AABBox< P > &box) const
Get all points in the tree that lie within box.
static KdTree Build(const std::vector< P > &points)
Build a balanced tree from the given set of points efficiently.
bool Contains(const P &point) const
Test wether a point is contained in the tree.
void Apply(std::function< bool(const P &)> f) const
Calls a function with each of the points in the tree.