#pragma once #include #include "build.hpp" #include "nns.hpp" namespace kd { template class KdTree { public: KdTree() {} template KdTree(It first, It last); const U& lookup(const Point& pk) const; protected: std::unique_ptr> root; }; template const U& KdTree::lookup(const Point& pk) const { // do a nearest neighbour search on the tree return kd::nns(pk, root.get())->data; } template template KdTree::KdTree(It first, It last) { root.reset(kd::build(first, last)); } }