MCPcopy Create free account
hub / github.com/acm-clan/algorithm-stone / query

Method query

templates/segment-tree.cpp:68–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66 }
67
68 int query(TreeNode * n, int l, int r){
69 if(!n)return 0;
70
71 if(n->l == l && n->r == r){
72 return n->v;
73 }
74
75 int m = (n->l + n->r)/2;
76
77 // 左右
78 if(r <= m){
79 return query(n->left, l, r);
80 }else if(l > m){
81 return query(n->right, l, r);
82 }
83
84 // 跨区间
85 return query(n->left, l, m) + query(n->right, m+1, r);
86 }
87
88 void dump(TreeNode * n){
89 // dumpInternal(n, 1);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected