segment tree class Usefull for fast query sums and updates
More...
#include <segment_tree.h>
|
| | segment_tree (const std::vector< int > &v) noexcept |
| | default constructor for segment tree
|
| void | update (int idx, int key) |
| int | sum (int query_start, int query_end) |
| | sum function
|
segment tree class Usefull for fast query sums and updates
◆ segment_tree()
| segment_tree::segment_tree |
( |
const std::vector< int > & | v | ) |
|
|
inlineexplicitnoexcept |
default constructor for segment tree
- Parameters
-
◆ sum()
| int segment_tree::sum |
( |
int | query_start, |
|
|
int | query_end ) |
|
inline |
sum function
- Parameters
-
| query_start | the starting index |
| query_end | the ending index |
- Returns
- int: the sum of the window [query_start, query_end]
◆ update()
| void segment_tree::update |
( |
int | idx, |
|
|
int | key ) |
|
inline |
@update function
- Parameters
-
| idx | the index we want to update |
| key | the new key(i.e. v[idx] = key) |
The documentation for this class was generated from the following file: