AlgoPlus v0.1.0
Loading...
Searching...
No Matches
fenwick_tree< T > Struct Template Reference

fenwick tree class More...

#include <fenwick_tree.h>

Public Member Functions

 fenwick_tree (const std::vector< T > &v) noexcept
 default constructor of fenwick tree class
 
sum (int k)
 sum query function
 
sum (int a, int b)
 sum query function(from index a to b)
 
void update (int k, int x)
 update query function
 

Public Attributes

std::vector< T > tree
 
int n
 

Detailed Description

template<typename T>
struct fenwick_tree< T >

fenwick tree class

Constructor & Destructor Documentation

◆ fenwick_tree()

template<typename T>
fenwick_tree< T >::fenwick_tree ( const std::vector< T > & v)
inlineexplicitnoexcept

default constructor of fenwick tree class

Parameters
vthe input vector

Member Function Documentation

◆ sum() [1/2]

template<typename T>
T fenwick_tree< T >::sum ( int a,
int b )
inline

sum query function(from index a to b)

Parameters
astarting index
bending index
Returns
T: the sum of range [a, b]

◆ sum() [2/2]

template<typename T>
T fenwick_tree< T >::sum ( int k)
inline

sum query function

Parameters
kthe ending index of the query
Returns
T: the sum of range [0, k]

◆ update()

template<typename T>
void fenwick_tree< T >::update ( int k,
int x )
inline

update query function

Parameters
kthe index
xthe value that will be added to data[k]

The documentation for this struct was generated from the following file: