1 | #ifndef __TREE_HPP__ |
---|
2 | #define __TREE_HPP__ |
---|
3 | //#include <list> |
---|
4 | #include <deque> |
---|
5 | #include <vector> |
---|
6 | #include "elt.hpp" |
---|
7 | #include "node.hpp" |
---|
8 | |
---|
9 | namespace sphereRemap { |
---|
10 | |
---|
11 | using namespace std; |
---|
12 | |
---|
13 | class CBasicTree |
---|
14 | { |
---|
15 | public: |
---|
16 | |
---|
17 | NodePtr root; /* The main tree is stored as Nodes which can be reached through traversal starting here */ |
---|
18 | NodePtr ref; // FIXME this reference, set by a node is odd, try to remove |
---|
19 | int ri; /** this is set to one by a node in case of reinsertion */ |
---|
20 | vector<int> levelSize; /** e.g. levelSize[0] == leafs.size() */ |
---|
21 | vector<Node> leafs; /** leafs are stored in vector for easy access and rest of the tree nodes as separate allocations, only reachable through tree traversal */ |
---|
22 | |
---|
23 | CBasicTree(); |
---|
24 | ~CBasicTree(); |
---|
25 | void build(vector<Node>& nodes); |
---|
26 | void slim(int nbIts = 1); |
---|
27 | virtual void insertNodes(vector<Node>& node) = 0; |
---|
28 | |
---|
29 | void routeNodes(vector<int>& route, vector<Node>& nodes, int assignLevel); |
---|
30 | void routeIntersections(vector<vector<int> >& route, vector<Node>& nodes); |
---|
31 | |
---|
32 | void push_back(NodePtr node); |
---|
33 | void push_front(NodePtr node); |
---|
34 | void increaseLevelSize(int level); |
---|
35 | void decreaseLevelSize(int level); |
---|
36 | void newRoot(int level); |
---|
37 | void insertNode(NodePtr node); |
---|
38 | void output(ostream& flux, int level) ; |
---|
39 | |
---|
40 | private: |
---|
41 | deque<NodePtr > pool; |
---|
42 | void emptyPool(); |
---|
43 | |
---|
44 | }; |
---|
45 | |
---|
46 | class CTree : public CBasicTree |
---|
47 | { |
---|
48 | public: |
---|
49 | void insertNodes(vector<Node>& nodes); |
---|
50 | }; |
---|
51 | |
---|
52 | class CSampleTree : public CBasicTree |
---|
53 | { |
---|
54 | int keepNodes; |
---|
55 | int assignLevel; |
---|
56 | public: |
---|
57 | CSampleTree(int keepNodes, int assignLevel) : keepNodes(keepNodes), assignLevel(assignLevel) {} |
---|
58 | |
---|
59 | void insertNodes(vector<Node>& nodes); |
---|
60 | }; |
---|
61 | |
---|
62 | } |
---|
63 | #endif |
---|