-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlock_quadtree.h
More file actions
48 lines (39 loc) · 1.13 KB
/
lock_quadtree.h
File metadata and controls
48 lines (39 loc) · 1.13 KB
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
#ifndef lockquadtreeH
#define lockquadtreeH
#include <vector>
#include <mutex>
//#include <memory>
#include "quadtree.h"
namespace quadtree
{
class LockQuadtree : public Quadtree
{
public:
// @todo create destructor, that deletes all the newed children
LockQuadtree(BoundingBox boundary, size_t capacity);
virtual ~LockQuadtree() {}
virtual bool Insert(const Point& p);
virtual std::vector<Point> Query(const BoundingBox&);
virtual BoundingBox Boundary() {return boundary;}
bool ThreadCanComplete(); ///< @todo not sure I like this. Make gc() call until success on each func?
BoundingBox boundary; ///< @todo change to shared_ptr ?
// @todo rename these and vars, swap case
// this are here so the gui can get their boundaries.
LockQuadtree* nw() {return Nw;}
LockQuadtree* ne() {return Ne;}
LockQuadtree* sw() {return Sw;}
LockQuadtree* se() {return Se;}
private:
LockQuadtree();
std::mutex pointsMutex;
std::vector<Point> points;
size_t capacity;
LockQuadtree* Nw;
LockQuadtree* Ne;
LockQuadtree* Sw;
LockQuadtree* Se;
void subdivide();
void disperse();
};
}
#endif // quadtreeH