Update kd.hpp

Remove spurious dependencies
This commit is contained in:
Carl Pearson
2021-05-25 17:20:52 -06:00
committed by GitHub
parent 7ab5672ec6
commit 7ade9ac719

16
kd.hpp
View File

@@ -5,9 +5,12 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
class KD {
class KD {
public:
struct Point { struct Point {
Point() = default;
Point(int _i, int _j) : i(_i), j(_j) {}
int i; int i;
int j; int j;
static bool by_ij(const Point &a, const Point &b) { static bool by_ij(const Point &a, const Point &b) {
@@ -32,6 +35,7 @@ class KD {
}; };
private:
struct Node { struct Node {
Point location; Point location;
Node *left; Node *left;
@@ -110,14 +114,8 @@ class KD {
} }
public: public:
KD(std::vector<Entry> pointlist) { KD(const std::vector<Point> &pointlist) {
std::vector<Point> ps; std::vector<Point> ps = pointlist; // ctor uses this as scratch space
for (size_t i = 0; i < pointlist.size(); ++i) {
Point p;
p.i = pointlist[i].i;
p.j = pointlist[i].j;
ps.push_back(p);
}
root_ = helper(&ps[0], &ps[ps.size()], 0); root_ = helper(&ps[0], &ps[ps.size()], 0);
} }
~KD() { ~KD() {