AlgoPlus v0.1.0
Loading...
Searching...
No Matches
segment_tree Class Reference

segment tree class Usefull for fast query sums and updates More...

#include <segment_tree.h>

Public Member Functions

 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
 

Detailed Description

segment tree class Usefull for fast query sums and updates

Constructor & Destructor Documentation

◆ segment_tree()

segment_tree::segment_tree ( const std::vector< int > & v)
inlineexplicitnoexcept

default constructor for segment tree

Parameters
vinput vector

Member Function Documentation

◆ sum()

int segment_tree::sum ( int query_start,
int query_end )
inline

sum function

Parameters
query_startthe starting index
query_endthe 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
idxthe index we want to update
keythe new key(i.e. v[idx] = key)

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