generated from karl/cpp-template
Fix clang-format
That earlier change introduced an error because YAML sucks
This commit is contained in:
parent
e7f18acc7d
commit
ece164a660
@ -9,4 +9,5 @@ AllowShortLoopsOnASingleLine: 'false'
|
||||
AlwaysBreakBeforeMultilineStrings: 'true'
|
||||
IndentWidth: '4'
|
||||
ColumnLimit: 100
|
||||
|
||||
...
|
11
kdtree.h
11
kdtree.h
@ -37,12 +37,12 @@ struct Point {
|
||||
};
|
||||
|
||||
class KDTree {
|
||||
public:
|
||||
public:
|
||||
KDTree(std::vector<Point *> points) { root = build(points, 0); }
|
||||
|
||||
~KDTree() = default;
|
||||
|
||||
private:
|
||||
private:
|
||||
Node *root;
|
||||
|
||||
int MAX_DEPTH = 500;
|
||||
@ -57,9 +57,7 @@ private:
|
||||
|
||||
Node *build(std::vector<Point *> points, int depth) {
|
||||
// Exit conditions
|
||||
if (points.empty() || depth > MAX_DEPTH) {
|
||||
return nullptr;
|
||||
}
|
||||
if (points.empty() || depth > MAX_DEPTH) { return nullptr; }
|
||||
|
||||
// Select axis by choosing the one with maximal extent
|
||||
float max_extent = 0;
|
||||
@ -93,8 +91,7 @@ private:
|
||||
float pivot;
|
||||
|
||||
// TODO: This copies. Can we split the vector into two without copying?
|
||||
std::vector<Point *> left_of_median(points.begin(),
|
||||
points.begin() + middle);
|
||||
std::vector<Point *> left_of_median(points.begin(), points.begin() + middle);
|
||||
std::vector<Point *> right_of_median(points.begin() + middle, points.end());
|
||||
|
||||
// Create node, recursively call to construct subtree
|
||||
|
Loading…
x
Reference in New Issue
Block a user