-
Notifications
You must be signed in to change notification settings - Fork 0
/
VPTree.h
52 lines (42 loc) · 1.06 KB
/
VPTree.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
45
46
47
48
49
50
51
52
#ifndef VPTREE_H
#define VPTREE_H
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <utility>
#include <deque>
#include <string.h>
#include <memory>
#include <boost/optional.hpp>
#include <vector>
#include <deque>
#include "Distance.h"
using std::vector;
using std::deque;
using std::pair;
class VPTree
{
private:
VPTree *left;
VPTree *right;
double left_min,right_min,left_max,right_max;
Point vp;
//Distance function
Distance *distance;
bool _isLeaf();
double _findMedian(std::deque<double>distances);
Point _selectVantagePoint(deque<Point> points);
public:
VPTree(){};
friend bool operator!= (Point &lhs,Point &rhs);
void initializeVPTreePoints(std::deque<Point> points);
std::vector<std::pair<double,Point>> getAllInRange(Point query ,double maxDistance);
std::vector<std::vector<std::pair<double,Point>>> getAllInRange (std::vector<Point> queryPoints,double maxDistance);
template<typename T>
inline void initializeDistance(T&& distFunc)
{
distance = distFunc;
}
};
#endif /* VPTREE_H */