mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-22 04:42:10 +08:00
275 lines
26 KiB
HTML
275 lines
26 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
|
<meta name="generator" content="Doxygen 1.9.7"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>Algorithms_in_C++: range_queries/persistent_seg_tree_lazy_prop.cpp File Reference</title>
|
|
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="../../jquery.js"></script>
|
|
<script type="text/javascript" src="../../dynsections.js"></script>
|
|
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="../../resize.js"></script>
|
|
<script type="text/javascript" src="../../navtreedata.js"></script>
|
|
<script type="text/javascript" src="../../navtree.js"></script>
|
|
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
|
<script type="text/javascript" src="../../search/search.js"></script>
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({
|
|
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
|
|
jax: ["input/TeX","output/HTML-CSS"],
|
|
});
|
|
</script>
|
|
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
|
|
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr id="projectrow">
|
|
<td id="projectalign">
|
|
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
|
</div>
|
|
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.9.7 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="../../menudata.js"></script>
|
|
<script type="text/javascript" src="../../menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(function() {
|
|
initMenu('../../',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(document).ready(function(){initNavTree('d5/d58/persistent__seg__tree__lazy__prop_8cpp.html','../../'); initResizable(); });
|
|
/* @license-end */
|
|
</script>
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<div id="MSearchResults">
|
|
<div class="SRPage">
|
|
<div id="SRIndex">
|
|
<div id="SRResults"></div>
|
|
<div class="SRStatus" id="Loading">Loading...</div>
|
|
<div class="SRStatus" id="Searching">Searching...</div>
|
|
<div class="SRStatus" id="NoMatches">No Matches</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#nested-classes">Classes</a> |
|
|
<a href="#namespaces">Namespaces</a> |
|
|
<a href="#func-members">Functions</a> </div>
|
|
<div class="headertitle"><div class="title">persistent_seg_tree_lazy_prop.cpp File Reference</div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p><a href="https://en.wikipedia.org/wiki/Persistent_data_structure" target="_blank">Persistent segment tree with range updates (lazy propagation)</a>
|
|
<a href="#details">More...</a></p>
|
|
<div class="textblock"><code>#include <iostream></code><br />
|
|
<code>#include <memory></code><br />
|
|
<code>#include <vector></code><br />
|
|
</div><div class="textblock"><div class="dynheader">
|
|
Include dependency graph for persistent_seg_tree_lazy_prop.cpp:</div>
|
|
<div class="dyncontent">
|
|
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d2/d86/persistent__seg__tree__lazy__prop_8cpp__incl.svg" width="255" height="126"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
|
</div>
|
|
</div><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
|
|
Classes</h2></td></tr>
|
|
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d28/classrange__queries_1_1per_seg_tree.html">range_queries::perSegTree</a></td></tr>
|
|
<tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">Range query here is range sum, but the code can be modified to make different queries like range max or min. <a href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#details">More...</a><br /></td></tr>
|
|
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d5/d66/classrange__queries_1_1per_seg_tree_1_1_node.html">range_queries::perSegTree::Node</a></td></tr>
|
|
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
|
|
Namespaces</h2></td></tr>
|
|
<tr class="memitem:dd/d69/namespacerange__queries"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d69/namespacerange__queries.html">range_queries</a></td></tr>
|
|
<tr class="memdesc:dd/d69/namespacerange__queries"><td class="mdescLeft"> </td><td class="mdescRight">Algorithms and Data Structures that support range queries and updates. <br /></td></tr>
|
|
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
|
Functions</h2></td></tr>
|
|
<tr class="memitem:aa8dca7b867074164d5f45b0f3851269d"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d5/d58/persistent__seg__tree__lazy__prop_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a> ()</td></tr>
|
|
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft"> </td><td class="mdescRight">Test implementations. <br /></td></tr>
|
|
<tr class="separator:aa8dca7b867074164d5f45b0f3851269d"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d5/d58/persistent__seg__tree__lazy__prop_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
|
|
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft"> </td><td class="mdescRight">Main function. <br /></td></tr>
|
|
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><p><a href="https://en.wikipedia.org/wiki/Persistent_data_structure" target="_blank">Persistent segment tree with range updates (lazy propagation)</a> </p>
|
|
<p>A normal segment tree facilitates making point updates and range queries in logarithmic time. Lazy propagation preserves the logarithmic time with range updates. So, a segment tree with lazy propagation enables doing range updates and range queries in logarithmic time, but it doesn't save any information about itself before the last update. A persistent data structure always preserves the previous version of itself when it is modified. That is, a new version of the segment tree is generated after every update. It saves all previous versions of itself (before every update) to facilitate doing range queries in any version. More memory is used ,but the logarithmic time is preserved because the new version points to the same nodes, that the previous version points to, that are not affected by the update. That is, only the nodes that are affected by the update and their ancestors are copied. The rest is copied using lazy propagation in the next queries. Thus preserving the logarithmic time because the number of nodes copied after any update is logarithmic.</p>
|
|
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/MSedra" target="_blank">Magdy Sedra</a> </dd></dl>
|
|
</div><h2 class="groupheader">Function Documentation</h2>
|
|
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">◆ </a></span>main()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">int main </td>
|
|
<td>(</td>
|
|
<td class="paramtype">void </td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Main function. </p>
|
|
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 318</span> {</div>
|
|
<div class="line"><span class="lineno"> 319</span> <a class="code hl_function" href="../../d5/d58/persistent__seg__tree__lazy__prop_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
|
|
<div class="line"><span class="lineno"> 320</span> <span class="keywordflow">return</span> 0;</div>
|
|
<div class="line"><span class="lineno"> 321</span>}</div>
|
|
<div class="ttc" id="apersistent__seg__tree__lazy__prop_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../d5/d58/persistent__seg__tree__lazy__prop_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Test implementations.</div><div class="ttdef"><b>Definition</b> persistent_seg_tree_lazy_prop.cpp:268</div></div>
|
|
</div><!-- fragment --><div class="dynheader">
|
|
Here is the call graph for this function:</div>
|
|
<div class="dyncontent">
|
|
<div class="center"><div class="zoom"><iframe scrolling="no" frameborder="0" src="../../d5/d58/persistent__seg__tree__lazy__prop_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="100%" height="559"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div></div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="aa8dca7b867074164d5f45b0f3851269d" name="aa8dca7b867074164d5f45b0f3851269d"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aa8dca7b867074164d5f45b0f3851269d">◆ </a></span>test()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">static void test </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Test implementations. </p>
|
|
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 268</span> {</div>
|
|
<div class="line"><span class="lineno"> 269</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<int64_t></a> arr = {-5, 2, 3, 11, -2, 7, 0, 1};</div>
|
|
<div class="line"><span class="lineno"> 270</span> <a class="code hl_class" href="../../d8/d28/classrange__queries_1_1per_seg_tree.html">range_queries::perSegTree</a> tree;</div>
|
|
<div class="line"><span class="lineno"> 271</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Elements before any updates are {"</span>;</div>
|
|
<div class="line"><span class="lineno"> 272</span> <span class="keywordflow">for</span> (uint32_t i = 0; i < arr.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>(); ++i) {</div>
|
|
<div class="line"><span class="lineno"> 273</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << arr[i];</div>
|
|
<div class="line"><span class="lineno"> 274</span> <span class="keywordflow">if</span> (i != arr.size() - 1) {</div>
|
|
<div class="line"><span class="lineno"> 275</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">","</span>;</div>
|
|
<div class="line"><span class="lineno"> 276</span> }</div>
|
|
<div class="line"><span class="lineno"> 277</span> }</div>
|
|
<div class="line"><span class="lineno"> 278</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"}\n"</span>;</div>
|
|
<div class="line"><span class="lineno"> 279</span> tree.<a class="code hl_function" href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#a6d3f2465a7c5803a1ff16c5378bcc5e4">construct</a>(</div>
|
|
<div class="line"><span class="lineno"> 280</span> arr); <span class="comment">// constructing the original segment tree (version = 0)</span></div>
|
|
<div class="line"><span class="lineno"> 281</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Querying range sum on version 0 from index 2 to 4 = 3+11-2 = "</span></div>
|
|
<div class="line"><span class="lineno"> 282</span> << tree.<a class="code hl_function" href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#ae8ae4b1835e5e8aec32f68c5059ed4d4">query</a>(2, 4, 0) << <span class="charliteral">'\n'</span>;</div>
|
|
<div class="line"><span class="lineno"> 283</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div>
|
|
<div class="line"><span class="lineno"> 284</span> << <span class="stringliteral">"Subtract 7 from all elements from index 1 to index 5 inclusive\n"</span>;</div>
|
|
<div class="line"><span class="lineno"> 285</span> tree.<a class="code hl_function" href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#a24487eda25123bc4d112e8430821a6c6">update</a>(1, 5, -7); <span class="comment">// subtracting 7 from index 1 to index 5</span></div>
|
|
<div class="line"><span class="lineno"> 286</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Elements of the segment tree whose version = 1 (after 1 "</span></div>
|
|
<div class="line"><span class="lineno"> 287</span> <span class="stringliteral">"update) are {"</span>;</div>
|
|
<div class="line"><span class="lineno"> 288</span> <span class="keywordflow">for</span> (uint32_t i = 0; i < arr.size(); ++i) {</div>
|
|
<div class="line"><span class="lineno"> 289</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << tree.<a class="code hl_function" href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#ae8ae4b1835e5e8aec32f68c5059ed4d4">query</a>(i, i, 1);</div>
|
|
<div class="line"><span class="lineno"> 290</span> <span class="keywordflow">if</span> (i != arr.size() - 1) {</div>
|
|
<div class="line"><span class="lineno"> 291</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">","</span>;</div>
|
|
<div class="line"><span class="lineno"> 292</span> }</div>
|
|
<div class="line"><span class="lineno"> 293</span> }</div>
|
|
<div class="line"><span class="lineno"> 294</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"}\n"</span>;</div>
|
|
<div class="line"><span class="lineno"> 295</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Add 10 to all elements from index 0 to index 7 inclusive\n"</span>;</div>
|
|
<div class="line"><span class="lineno"> 296</span> tree.<a class="code hl_function" href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#a24487eda25123bc4d112e8430821a6c6">update</a>(0, 7, 10); <span class="comment">// adding 10 to all elements</span></div>
|
|
<div class="line"><span class="lineno"> 297</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Elements of the segment tree whose version = 2 (after 2 "</span></div>
|
|
<div class="line"><span class="lineno"> 298</span> <span class="stringliteral">"updates) are {"</span>;</div>
|
|
<div class="line"><span class="lineno"> 299</span> <span class="keywordflow">for</span> (uint32_t i = 0; i < arr.size(); ++i) {</div>
|
|
<div class="line"><span class="lineno"> 300</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << tree.<a class="code hl_function" href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#ae8ae4b1835e5e8aec32f68c5059ed4d4">query</a>(i, i, 2);</div>
|
|
<div class="line"><span class="lineno"> 301</span> <span class="keywordflow">if</span> (i != arr.size() - 1) {</div>
|
|
<div class="line"><span class="lineno"> 302</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">","</span>;</div>
|
|
<div class="line"><span class="lineno"> 303</span> }</div>
|
|
<div class="line"><span class="lineno"> 304</span> }</div>
|
|
<div class="line"><span class="lineno"> 305</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"}\n"</span>;</div>
|
|
<div class="line"><span class="lineno"> 306</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Number of segment trees (versions) now = "</span> << tree.<a class="code hl_function" href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#a0fe4e431f3e09c274ecd7d2d58dcb865">size</a>()</div>
|
|
<div class="line"><span class="lineno"> 307</span> << <span class="charliteral">'\n'</span>;</div>
|
|
<div class="line"><span class="lineno"> 308</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Querying range sum on version 0 from index 3 to 5 = 11-2+7 = "</span></div>
|
|
<div class="line"><span class="lineno"> 309</span> << tree.<a class="code hl_function" href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#ae8ae4b1835e5e8aec32f68c5059ed4d4">query</a>(3, 5, 0) << <span class="charliteral">'\n'</span>;</div>
|
|
<div class="line"><span class="lineno"> 310</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Querying range sum on version 1 from index 3 to 5 = 4-9+0 = "</span></div>
|
|
<div class="line"><span class="lineno"> 311</span> << tree.<a class="code hl_function" href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#ae8ae4b1835e5e8aec32f68c5059ed4d4">query</a>(3, 5, 1) << <span class="charliteral">'\n'</span>;</div>
|
|
<div class="line"><span class="lineno"> 312</span>}</div>
|
|
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
|
|
<div class="ttc" id="aclassrange__queries_1_1per_seg_tree_html"><div class="ttname"><a href="../../d8/d28/classrange__queries_1_1per_seg_tree.html">range_queries::perSegTree</a></div><div class="ttdoc">Range query here is range sum, but the code can be modified to make different queries like range max ...</div><div class="ttdef"><b>Definition</b> persistent_seg_tree_lazy_prop.cpp:39</div></div>
|
|
<div class="ttc" id="aclassrange__queries_1_1per_seg_tree_html_a0fe4e431f3e09c274ecd7d2d58dcb865"><div class="ttname"><a href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#a0fe4e431f3e09c274ecd7d2d58dcb865">range_queries::perSegTree::size</a></div><div class="ttdeci">uint32_t size()</div><div class="ttdoc">Getting the number of versions after updates so far which is equal to the size of the pointers vector...</div><div class="ttdef"><b>Definition</b> persistent_seg_tree_lazy_prop.cpp:255</div></div>
|
|
<div class="ttc" id="aclassrange__queries_1_1per_seg_tree_html_a24487eda25123bc4d112e8430821a6c6"><div class="ttname"><a href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#a24487eda25123bc4d112e8430821a6c6">range_queries::perSegTree::update</a></div><div class="ttdeci">std::shared_ptr< Node > update(const uint32_t &i, const uint32_t &j, const uint32_t &l, const uint32_t &r, const int64_t &value, std::shared_ptr< Node > const &curr)</div><div class="ttdoc">Doing range update, checking at every node if it has some value to be propagated. All nodes affected ...</div><div class="ttdef"><b>Definition</b> persistent_seg_tree_lazy_prop.cpp:135</div></div>
|
|
<div class="ttc" id="aclassrange__queries_1_1per_seg_tree_html_a6d3f2465a7c5803a1ff16c5378bcc5e4"><div class="ttname"><a href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#a6d3f2465a7c5803a1ff16c5378bcc5e4">range_queries::perSegTree::construct</a></div><div class="ttdeci">std::shared_ptr< Node > construct(const uint32_t &i, const uint32_t &j)</div><div class="ttdoc">Constructing the segment tree with the early passed vector. Every call creates a node to hold the sum...</div><div class="ttdef"><b>Definition</b> persistent_seg_tree_lazy_prop.cpp:106</div></div>
|
|
<div class="ttc" id="aclassrange__queries_1_1per_seg_tree_html_ae8ae4b1835e5e8aec32f68c5059ed4d4"><div class="ttname"><a href="../../d8/d28/classrange__queries_1_1per_seg_tree.html#ae8ae4b1835e5e8aec32f68c5059ed4d4">range_queries::perSegTree::query</a></div><div class="ttdeci">int64_t query(const uint32_t &i, const uint32_t &j, const uint32_t &l, const uint32_t &r, std::shared_ptr< Node > const &curr)</div><div class="ttdoc">Querying the range from index l to index r, checking at every node if it has some value to be propaga...</div><div class="ttdef"><b>Definition</b> persistent_seg_tree_lazy_prop.cpp:171</div></div>
|
|
<div class="ttc" id="asize_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/size.html">std::vector::size</a></div><div class="ttdeci">T size(T... args)</div></div>
|
|
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
|
|
</div><!-- fragment --><div class="dynheader">
|
|
Here is the call graph for this function:</div>
|
|
<div class="dyncontent">
|
|
<div class="center"><div class="zoom"><iframe scrolling="no" frameborder="0" src="../../d5/d58/persistent__seg__tree__lazy__prop_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg" width="100%" height="559"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div></div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="../../dir_074119ce3a874b57120c49a0cc4bb5ad.html">range_queries</a></li><li class="navelem"><a class="el" href="../../d5/d58/persistent__seg__tree__lazy__prop_8cpp.html">persistent_seg_tree_lazy_prop.cpp</a></li>
|
|
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.7 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|