-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkdTree.h
44 lines (43 loc) · 1.11 KB
/
kdTree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef KD_TREE
#define KD_TREE
#include "data.h"
#include <vector>
namespace project{
class kdTreeNode{
public:
// variables
double l, r, u, d;
bool isLeaf;
data value;
int size;
kdTreeNode *left, *right;
// constructors
kdTreeNode();
kdTreeNode(double l, double r, double u, double d, const data& v);
~kdTreeNode();
kdTreeNode(const kdTreeNode& n);
// functions
std::vector<double> getRegion();
};
class kdTree
{
public:
// variables
kdTreeNode *root;
std::vector<data> p;
std::vector<data> sortedPC, sortedSC;
std::vector<bool> vis;
int dimensions;
int primaryCoordinate, secondaryCoordinate;
// constructors
kdTree();
kdTree(std::vector<data> a, int pc);
~kdTree();
// functions
void build(std::vector<data>& a, std::vector<data>& b, int depth, kdTreeNode* &root, std::vector<double> bd);
std::vector<data> query(kdTreeNode* root, std::pair<double, double> pcRange, std::pair<double, double> scRange);
std::vector<data> reportSubtree(kdTreeNode* root);
int queryCnt(kdTreeNode* root, std::pair<double, double> pcRange, std::pair<double, double> scRange);
};
}
#endif