-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubsumtree.hpp
More file actions
executable file
·47 lines (33 loc) · 945 Bytes
/
Copy pathsubsumtree.hpp
File metadata and controls
executable file
·47 lines (33 loc) · 945 Bytes
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
/*
* subsumtree.hpp
*
* Created on: 2013-11-10
* Author: Rong Xiao
*/
#ifndef SUBSUMTREE_HPP_
#define SUBSUMTREE_HPP_
#include <vector>
using std::vector;
typedef vector<int>::size_type size_t; // size_t compatibility
struct BackTreeNode {
BackTreeNode *parent;
size_t lstart;
size_t rend;
int val;
BackTreeNode(BackTreeNode *left, BackTreeNode *right) : lstart(left->lstart), rend(right->rend), val(left->val+right->val), parent(0) {
left->parent = this;
right->parent=this;
}
BackTreeNode(int v, size_t i) : lstart(i), rend(i), val(v), parent(0) {
}
};
class SubsumTree {
vector<BackTreeNode*> treeNodes;
void buildSubsumTree(const vector<int>& vec);
void deleteSubsumTree();
public:
SubsumTree(const vector<int>& vec);
~SubsumTree();
int query(size_t i, size_t j);
};
#endif /* SUBSUMTREE_HPP_ */