|
|
|
|
@@ -0,0 +1,790 @@
|
|
|
|
|
<!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">
|
|
|
|
|
<head>
|
|
|
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
|
|
|
<meta name="generator" content="Doxygen 1.8.18"/>
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
|
|
|
<title>Algorithms_in_C++: range_queries::heavy_light_decomposition::Tree< X > Class Template 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 style="height: 56px;">
|
|
|
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
|
|
|
<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.8.18 -->
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
|
|
|
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
|
|
|
|
|
/* @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:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
|
|
|
$(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:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
|
|
|
$(document).ready(function(){initNavTree('d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.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">
|
|
|
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
|
|
|
name="MSearchResults" id="MSearchResults">
|
|
|
|
|
</iframe>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="header">
|
|
|
|
|
<div class="summary">
|
|
|
|
|
<a href="#pub-methods">Public Member Functions</a> |
|
|
|
|
|
<a href="#pri-methods">Private Member Functions</a> |
|
|
|
|
|
<a href="#pri-attribs">Private Attributes</a> |
|
|
|
|
|
<a href="#friends">Friends</a> |
|
|
|
|
|
<a href="../../d9/d4e/classrange__queries_1_1heavy__light__decomposition_1_1_tree-members.html">List of all members</a> </div>
|
|
|
|
|
<div class="headertitle">
|
|
|
|
|
<div class="title">range_queries::heavy_light_decomposition::Tree< X > Class Template Reference</div> </div>
|
|
|
|
|
</div><!--header-->
|
|
|
|
|
<div class="contents">
|
|
|
|
|
|
|
|
|
|
<p>A Basic <a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html" title="A Basic Tree, which supports binary lifting.">Tree</a>, which supports binary lifting.
|
|
|
|
|
<a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#details">More...</a></p>
|
|
|
|
|
<div class="dynheader">
|
|
|
|
|
Inheritance diagram for range_queries::heavy_light_decomposition::Tree< X >:</div>
|
|
|
|
|
<div class="dyncontent">
|
|
|
|
|
<div class="center"><iframe scrolling="no" frameborder="0" src="../../da/dcc/classrange__queries_1_1heavy__light__decomposition_1_1_tree__inherit__graph.svg" width="158" height="171"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
|
|
|
</div>
|
|
|
|
|
<center><span class="legend">[<a target="top" href="../../graph_legend.html">legend</a>]</span></center></div>
|
|
|
|
|
<div class="dynheader">
|
|
|
|
|
Collaboration diagram for range_queries::heavy_light_decomposition::Tree< X >:</div>
|
|
|
|
|
<div class="dyncontent">
|
|
|
|
|
<div class="center"><iframe scrolling="no" frameborder="0" src="../../de/d4c/classrange__queries_1_1heavy__light__decomposition_1_1_tree__coll__graph.svg" width="626" height="231"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
|
|
|
</div>
|
|
|
|
|
<center><span class="legend">[<a target="top" href="../../graph_legend.html">legend</a>]</span></center></div>
|
|
|
|
|
<table class="memberdecls">
|
|
|
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
|
|
|
|
|
Public Member Functions</h2></td></tr>
|
|
|
|
|
<tr class="memitem:a835fb2bbb27307b8cacad9b287968bc1"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a835fb2bbb27307b8cacad9b287968bc1">Tree</a> (int nodes)</td></tr>
|
|
|
|
|
<tr class="memdesc:a835fb2bbb27307b8cacad9b287968bc1"><td class="mdescLeft"> </td><td class="mdescRight">Class parameterized constructor, resizes the and initializes the data members. <a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a835fb2bbb27307b8cacad9b287968bc1">More...</a><br /></td></tr>
|
|
|
|
|
<tr class="separator:a835fb2bbb27307b8cacad9b287968bc1"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:a79ab4601c4a95c0902ac04e779e5f54d"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a79ab4601c4a95c0902ac04e779e5f54d">add_edge</a> (const int u, const int v)</td></tr>
|
|
|
|
|
<tr class="memdesc:a79ab4601c4a95c0902ac04e779e5f54d"><td class="mdescLeft"> </td><td class="mdescRight">Adds an undirected edge from node u to node v in the tree. <a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a79ab4601c4a95c0902ac04e779e5f54d">More...</a><br /></td></tr>
|
|
|
|
|
<tr class="separator:a79ab4601c4a95c0902ac04e779e5f54d"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:ab916d554afa8ca5230b4310c2c69fae0"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab916d554afa8ca5230b4310c2c69fae0">change_root</a> (int new_root)</td></tr>
|
|
|
|
|
<tr class="memdesc:ab916d554afa8ca5230b4310c2c69fae0"><td class="mdescLeft"> </td><td class="mdescRight">Set the root for the tree. <a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab916d554afa8ca5230b4310c2c69fae0">More...</a><br /></td></tr>
|
|
|
|
|
<tr class="separator:ab916d554afa8ca5230b4310c2c69fae0"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:a04cd96efaba147b19d3afc769b90ff70"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a04cd96efaba147b19d3afc769b90ff70">set_node_val</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< X > &node_val)</td></tr>
|
|
|
|
|
<tr class="memdesc:a04cd96efaba147b19d3afc769b90ff70"><td class="mdescLeft"> </td><td class="mdescRight">Set the values for all the nodes. <a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a04cd96efaba147b19d3afc769b90ff70">More...</a><br /></td></tr>
|
|
|
|
|
<tr class="separator:a04cd96efaba147b19d3afc769b90ff70"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:ad22d760a5a33545a70e7ea5e1786c8dc"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ad22d760a5a33545a70e7ea5e1786c8dc">init</a> ()</td></tr>
|
|
|
|
|
<tr class="memdesc:ad22d760a5a33545a70e7ea5e1786c8dc"><td class="mdescLeft"> </td><td class="mdescRight">This function must be called after the tree adjacency list and node values are populated The function initializes the required parameters, and populates the segment tree. <a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ad22d760a5a33545a70e7ea5e1786c8dc">More...</a><br /></td></tr>
|
|
|
|
|
<tr class="separator:ad22d760a5a33545a70e7ea5e1786c8dc"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:ac7761255f2ba06b398b9aae5e4dce5f3"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ac7761255f2ba06b398b9aae5e4dce5f3">lift</a> (int *const p, int dist)</td></tr>
|
|
|
|
|
<tr class="memdesc:ac7761255f2ba06b398b9aae5e4dce5f3"><td class="mdescLeft"> </td><td class="mdescRight">The function lifts a node, k units up the tree. The lifting is done in place, and the result is stored in the address pointed by p. <a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ac7761255f2ba06b398b9aae5e4dce5f3">More...</a><br /></td></tr>
|
|
|
|
|
<tr class="separator:ac7761255f2ba06b398b9aae5e4dce5f3"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:a8f7bca1746d40f21ad832fcea59aa6c6"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a8f7bca1746d40f21ad832fcea59aa6c6">kth_ancestor</a> (int p, const int &dist)</td></tr>
|
|
|
|
|
<tr class="memdesc:a8f7bca1746d40f21ad832fcea59aa6c6"><td class="mdescLeft"> </td><td class="mdescRight">The function returns the kth ancestor of a node. <a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a8f7bca1746d40f21ad832fcea59aa6c6">More...</a><br /></td></tr>
|
|
|
|
|
<tr class="separator:a8f7bca1746d40f21ad832fcea59aa6c6"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:ae2b407e64aaf9878fbee7ee6efe9c7d4"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae2b407e64aaf9878fbee7ee6efe9c7d4">lca</a> (int a, int b)</td></tr>
|
|
|
|
|
<tr class="memdesc:ae2b407e64aaf9878fbee7ee6efe9c7d4"><td class="mdescLeft"> </td><td class="mdescRight">The function returns the least common ancestor of two nodes. <a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae2b407e64aaf9878fbee7ee6efe9c7d4">More...</a><br /></td></tr>
|
|
|
|
|
<tr class="separator:ae2b407e64aaf9878fbee7ee6efe9c7d4"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
</table><table class="memberdecls">
|
|
|
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-methods"></a>
|
|
|
|
|
Private Member Functions</h2></td></tr>
|
|
|
|
|
<tr class="memitem:aa339c31ec74cd86a4842a8b09653d460"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#aa339c31ec74cd86a4842a8b09653d460">dfs_size</a> (int u, int p=-1)</td></tr>
|
|
|
|
|
<tr class="memdesc:aa339c31ec74cd86a4842a8b09653d460"><td class="mdescLeft"> </td><td class="mdescRight">Utility function to compute sub-tree sizes. <a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#aa339c31ec74cd86a4842a8b09653d460">More...</a><br /></td></tr>
|
|
|
|
|
<tr class="separator:aa339c31ec74cd86a4842a8b09653d460"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:ae8de7aefcb6635d3dacdd174cd4890c4"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae8de7aefcb6635d3dacdd174cd4890c4">dfs_lca</a> (int u, int p=-1)</td></tr>
|
|
|
|
|
<tr class="memdesc:ae8de7aefcb6635d3dacdd174cd4890c4"><td class="mdescLeft"> </td><td class="mdescRight">Utility function to populate the t_par vector. <a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae8de7aefcb6635d3dacdd174cd4890c4">More...</a><br /></td></tr>
|
|
|
|
|
<tr class="separator:ae8de7aefcb6635d3dacdd174cd4890c4"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
</table><table class="memberdecls">
|
|
|
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-attribs"></a>
|
|
|
|
|
Private Attributes</h2></td></tr>
|
|
|
|
|
<tr class="memitem:ab1aeaefa1bd97b867c652ba916fbdb43"><td class="memItemLeft" align="right" valign="top"><a id="ab1aeaefa1bd97b867c652ba916fbdb43"></a>
|
|
|
|
|
<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list.html">std::list</a>< int > > </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab1aeaefa1bd97b867c652ba916fbdb43">t_adj</a></td></tr>
|
|
|
|
|
<tr class="memdesc:ab1aeaefa1bd97b867c652ba916fbdb43"><td class="mdescLeft"> </td><td class="mdescRight">an adjacency list to stores the tree edges <br /></td></tr>
|
|
|
|
|
<tr class="separator:ab1aeaefa1bd97b867c652ba916fbdb43"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:ae4630fa70a80a1dc65a875488a67178a"><td class="memItemLeft" align="right" valign="top"><a id="ae4630fa70a80a1dc65a875488a67178a"></a>
|
|
|
|
|
const int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">t_nodes</a></td></tr>
|
|
|
|
|
<tr class="memdesc:ae4630fa70a80a1dc65a875488a67178a"><td class="mdescLeft"> </td><td class="mdescRight">number of nodes <br /></td></tr>
|
|
|
|
|
<tr class="separator:ae4630fa70a80a1dc65a875488a67178a"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:ab2ab020f798d00be2613ecf63074b7c1"><td class="memItemLeft" align="right" valign="top"><a id="ab2ab020f798d00be2613ecf63074b7c1"></a>
|
|
|
|
|
const int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab2ab020f798d00be2613ecf63074b7c1">t_maxlift</a></td></tr>
|
|
|
|
|
<tr class="memdesc:ab2ab020f798d00be2613ecf63074b7c1"><td class="mdescLeft"> </td><td class="mdescRight">maximum possible height of the tree <br /></td></tr>
|
|
|
|
|
<tr class="separator:ab2ab020f798d00be2613ecf63074b7c1"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:a350157a5fb79f76fceae33fc84171203"><td class="memItemLeft" align="right" valign="top"><a id="a350157a5fb79f76fceae33fc84171203"></a>
|
|
|
|
|
<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< int > > </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a></td></tr>
|
|
|
|
|
<tr class="memdesc:a350157a5fb79f76fceae33fc84171203"><td class="mdescLeft"> </td><td class="mdescRight">a matrix to store every node's 2^kth parent <br /></td></tr>
|
|
|
|
|
<tr class="separator:a350157a5fb79f76fceae33fc84171203"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:a0efd0b9c564092f443ca97030d866ef1"><td class="memItemLeft" align="right" valign="top"><a id="a0efd0b9c564092f443ca97030d866ef1"></a>
|
|
|
|
|
<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< int > </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a></td></tr>
|
|
|
|
|
<tr class="memdesc:a0efd0b9c564092f443ca97030d866ef1"><td class="mdescLeft"> </td><td class="mdescRight">a vector to store the depth of a node, <br /></td></tr>
|
|
|
|
|
<tr class="separator:a0efd0b9c564092f443ca97030d866ef1"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:ada1494fccbc7f1f07b2f9be9f7e07ad5"><td class="memItemLeft" align="right" valign="top"><a id="ada1494fccbc7f1f07b2f9be9f7e07ad5"></a>
|
|
|
|
|
<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< int > </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ada1494fccbc7f1f07b2f9be9f7e07ad5">t_size</a></td></tr>
|
|
|
|
|
<tr class="memdesc:ada1494fccbc7f1f07b2f9be9f7e07ad5"><td class="mdescLeft"> </td><td class="mdescRight">a vector to store the subtree size rooted at node <br /></td></tr>
|
|
|
|
|
<tr class="separator:ada1494fccbc7f1f07b2f9be9f7e07ad5"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:aa6c37e840355b9fb2105181c578694e8"><td class="memItemLeft" align="right" valign="top"><a id="aa6c37e840355b9fb2105181c578694e8"></a>
|
|
|
|
|
int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#aa6c37e840355b9fb2105181c578694e8">t_root</a></td></tr>
|
|
|
|
|
<tr class="memdesc:aa6c37e840355b9fb2105181c578694e8"><td class="mdescLeft"> </td><td class="mdescRight">the root of the tree <br /></td></tr>
|
|
|
|
|
<tr class="separator:aa6c37e840355b9fb2105181c578694e8"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
<tr class="memitem:a135b7952593c9b1aae38fcaf1cc1abf7"><td class="memItemLeft" align="right" valign="top"><a id="a135b7952593c9b1aae38fcaf1cc1abf7"></a>
|
|
|
|
|
<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< X > </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a135b7952593c9b1aae38fcaf1cc1abf7">t_val</a></td></tr>
|
|
|
|
|
<tr class="memdesc:a135b7952593c9b1aae38fcaf1cc1abf7"><td class="mdescLeft"> </td><td class="mdescRight">values of nodes <br /></td></tr>
|
|
|
|
|
<tr class="separator:a135b7952593c9b1aae38fcaf1cc1abf7"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
</table><table class="memberdecls">
|
|
|
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="friends"></a>
|
|
|
|
|
Friends</h2></td></tr>
|
|
|
|
|
<tr class="memitem:afcdadbdea1e2391cebbb17d2c1ae2f0b"><td class="memTemplParams" colspan="2"><a id="afcdadbdea1e2391cebbb17d2c1ae2f0b"></a>
|
|
|
|
|
template<typename T > </td></tr>
|
|
|
|
|
<tr class="memitem:afcdadbdea1e2391cebbb17d2c1ae2f0b"><td class="memTemplItemLeft" align="right" valign="top">class </td><td class="memTemplItemRight" valign="bottom"><b>HLD</b></td></tr>
|
|
|
|
|
<tr class="separator:afcdadbdea1e2391cebbb17d2c1ae2f0b"><td class="memSeparator" colspan="2"> </td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
|
|
|
<div class="textblock"><h3>template<typename X><br />
|
|
|
|
|
class range_queries::heavy_light_decomposition::Tree< X ></h3>
|
|
|
|
|
|
|
|
|
|
<p>A Basic <a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html" title="A Basic Tree, which supports binary lifting.">Tree</a>, which supports binary lifting. </p>
|
|
|
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
|
|
|
<table class="tparams">
|
|
|
|
|
<tr><td class="paramname">the</td><td>data type of the values stored in the tree nodes</td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<p>Deleting the default constructor An instance can only be created with the number of nodes Defaults: t_node indexing are zero based t_root is 0 depth of root_node is 0 Supports: lift :- lift a node k units up the tree kth_ancestor :- returns the kth ancestor lca :- returns the least common ancestor </p>
|
|
|
|
|
</div><h2 class="groupheader">Constructor & Destructor Documentation</h2>
|
|
|
|
|
<a id="a835fb2bbb27307b8cacad9b287968bc1"></a>
|
|
|
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a835fb2bbb27307b8cacad9b287968bc1">◆ </a></span>Tree()</h2>
|
|
|
|
|
|
|
|
|
|
<div class="memitem">
|
|
|
|
|
<div class="memproto">
|
|
|
|
|
<div class="memtemplate">
|
|
|
|
|
template<typename X > </div>
|
|
|
|
|
<table class="mlabels">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="mlabels-left">
|
|
|
|
|
<table class="memname">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="memname"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">range_queries::heavy_light_decomposition::Tree</a>< X >::<a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">Tree</a> </td>
|
|
|
|
|
<td>(</td>
|
|
|
|
|
<td class="paramtype">int </td>
|
|
|
|
|
<td class="paramname"><em>nodes</em></td><td>)</td>
|
|
|
|
|
<td></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="mlabels-right">
|
|
|
|
|
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">explicit</span></span> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</div><div class="memdoc">
|
|
|
|
|
|
|
|
|
|
<p>Class parameterized constructor, resizes the and initializes the data members. </p>
|
|
|
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
|
|
|
<table class="params">
|
|
|
|
|
<tr><td class="paramname">nodes</td><td>the total number of nodes in the tree </td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  : <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">t_nodes</a>(nodes), <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab2ab020f798d00be2613ecf63074b7c1">t_maxlift</a>(<span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/floor.html">floor</a>(log2(nodes))) + 1) {</div>
|
|
|
|
|
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  <span class="comment">/* Initialize and resize all the vectors */</span></div>
|
|
|
|
|
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#aa6c37e840355b9fb2105181c578694e8">t_root</a> = 0; <span class="comment">/* Default */</span></div>
|
|
|
|
|
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab1aeaefa1bd97b867c652ba916fbdb43">t_adj</a>.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/resize.html">resize</a>(<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">t_nodes</a>);</div>
|
|
|
|
|
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/assign.html">assign</a>(<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">t_nodes</a>, <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<int></a>(<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab2ab020f798d00be2613ecf63074b7c1">t_maxlift</a>, -1));</div>
|
|
|
|
|
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a>.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/assign.html">assign</a>(<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">t_nodes</a>, 0);</div>
|
|
|
|
|
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ada1494fccbc7f1f07b2f9be9f7e07ad5">t_size</a>.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/assign.html">assign</a>(<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">t_nodes</a>, 1);</div>
|
|
|
|
|
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a135b7952593c9b1aae38fcaf1cc1abf7">t_val</a>.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/resize.html">resize</a>(<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">t_nodes</a>);</div>
|
|
|
|
|
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  }</div>
|
|
|
|
|
</div><!-- fragment --><div class="dynheader">
|
|
|
|
|
Here is the call graph for this function:</div>
|
|
|
|
|
<div class="dyncontent">
|
|
|
|
|
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree_a835fb2bbb27307b8cacad9b287968bc1_cgraph.svg" width="336" height="88"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<h2 class="groupheader">Member Function Documentation</h2>
|
|
|
|
|
<a id="a79ab4601c4a95c0902ac04e779e5f54d"></a>
|
|
|
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a79ab4601c4a95c0902ac04e779e5f54d">◆ </a></span>add_edge()</h2>
|
|
|
|
|
|
|
|
|
|
<div class="memitem">
|
|
|
|
|
<div class="memproto">
|
|
|
|
|
<div class="memtemplate">
|
|
|
|
|
template<typename X > </div>
|
|
|
|
|
<table class="mlabels">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="mlabels-left">
|
|
|
|
|
<table class="memname">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="memname">void <a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">range_queries::heavy_light_decomposition::Tree</a>< X >::add_edge </td>
|
|
|
|
|
<td>(</td>
|
|
|
|
|
<td class="paramtype">const int </td>
|
|
|
|
|
<td class="paramname"><em>u</em>, </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="paramkey"></td>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td class="paramtype">const int </td>
|
|
|
|
|
<td class="paramname"><em>v</em> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td>)</td>
|
|
|
|
|
<td></td><td></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="mlabels-right">
|
|
|
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</div><div class="memdoc">
|
|
|
|
|
|
|
|
|
|
<p>Adds an undirected edge from node u to node v in the tree. </p>
|
|
|
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
|
|
|
<table class="params">
|
|
|
|
|
<tr><td class="paramname">u</td><td>the node where the edge is from </td></tr>
|
|
|
|
|
<tr><td class="paramname">v</td><td>the node where the edge is to </td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00157"></a><span class="lineno"> 157</span>  {</div>
|
|
|
|
|
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab1aeaefa1bd97b867c652ba916fbdb43">t_adj</a>[u].<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">push_back</a>(v);</div>
|
|
|
|
|
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab1aeaefa1bd97b867c652ba916fbdb43">t_adj</a>[v].<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">push_back</a>(u);</div>
|
|
|
|
|
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  }</div>
|
|
|
|
|
</div><!-- fragment --><div class="dynheader">
|
|
|
|
|
Here is the call graph for this function:</div>
|
|
|
|
|
<div class="dyncontent">
|
|
|
|
|
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree_a79ab4601c4a95c0902ac04e779e5f54d_cgraph.svg" width="360" height="67"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<a id="ab916d554afa8ca5230b4310c2c69fae0"></a>
|
|
|
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ab916d554afa8ca5230b4310c2c69fae0">◆ </a></span>change_root()</h2>
|
|
|
|
|
|
|
|
|
|
<div class="memitem">
|
|
|
|
|
<div class="memproto">
|
|
|
|
|
<div class="memtemplate">
|
|
|
|
|
template<typename X > </div>
|
|
|
|
|
<table class="mlabels">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="mlabels-left">
|
|
|
|
|
<table class="memname">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="memname">void <a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">range_queries::heavy_light_decomposition::Tree</a>< X >::change_root </td>
|
|
|
|
|
<td>(</td>
|
|
|
|
|
<td class="paramtype">int </td>
|
|
|
|
|
<td class="paramname"><em>new_root</em></td><td>)</td>
|
|
|
|
|
<td></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="mlabels-right">
|
|
|
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</div><div class="memdoc">
|
|
|
|
|
|
|
|
|
|
<p>Set the root for the tree. </p>
|
|
|
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
|
|
|
<table class="params">
|
|
|
|
|
<tr><td class="paramname">new_root</td><td>the new root </td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00167"></a><span class="lineno"> 167</span> { <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#aa6c37e840355b9fb2105181c578694e8">t_root</a> = new_root; }</div>
|
|
|
|
|
</div><!-- fragment -->
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<a id="ae8de7aefcb6635d3dacdd174cd4890c4"></a>
|
|
|
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ae8de7aefcb6635d3dacdd174cd4890c4">◆ </a></span>dfs_lca()</h2>
|
|
|
|
|
|
|
|
|
|
<div class="memitem">
|
|
|
|
|
<div class="memproto">
|
|
|
|
|
<div class="memtemplate">
|
|
|
|
|
template<typename X > </div>
|
|
|
|
|
<table class="mlabels">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="mlabels-left">
|
|
|
|
|
<table class="memname">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="memname">void <a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">range_queries::heavy_light_decomposition::Tree</a>< X >::dfs_lca </td>
|
|
|
|
|
<td>(</td>
|
|
|
|
|
<td class="paramtype">int </td>
|
|
|
|
|
<td class="paramname"><em>u</em>, </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="paramkey"></td>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td class="paramtype">int </td>
|
|
|
|
|
<td class="paramname"><em>p</em> = <code>-1</code> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td>)</td>
|
|
|
|
|
<td></td><td></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="mlabels-right">
|
|
|
|
|
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">private</span></span> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</div><div class="memdoc">
|
|
|
|
|
|
|
|
|
|
<p>Utility function to populate the t_par vector. </p>
|
|
|
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
|
|
|
<table class="params">
|
|
|
|
|
<tr><td class="paramname">u</td><td>current dfs node </td></tr>
|
|
|
|
|
<tr><td class="paramname">p</td><td>the parent of node u </td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  {</div>
|
|
|
|
|
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>[u][0] = p;</div>
|
|
|
|
|
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  <span class="keywordflow">if</span> (p != -1) {</div>
|
|
|
|
|
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a>[u] = 1 + <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a>[p];</div>
|
|
|
|
|
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k = 1; k < <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab2ab020f798d00be2613ecf63074b7c1">t_maxlift</a>; k++) {</div>
|
|
|
|
|
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  <span class="keywordflow">if</span> (<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>[u][k - 1] != -1) {</div>
|
|
|
|
|
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>[u][k] = <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>[<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>[u][k - 1]][k - 1];</div>
|
|
|
|
|
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  </div>
|
|
|
|
|
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keywordtype">int</span> &v : <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab1aeaefa1bd97b867c652ba916fbdb43">t_adj</a>[u]) {</div>
|
|
|
|
|
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  <span class="keywordflow">if</span> (v ^ p) {</div>
|
|
|
|
|
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae8de7aefcb6635d3dacdd174cd4890c4">dfs_lca</a>(v, u);</div>
|
|
|
|
|
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  }</div>
|
|
|
|
|
</div><!-- fragment -->
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<a id="aa339c31ec74cd86a4842a8b09653d460"></a>
|
|
|
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aa339c31ec74cd86a4842a8b09653d460">◆ </a></span>dfs_size()</h2>
|
|
|
|
|
|
|
|
|
|
<div class="memitem">
|
|
|
|
|
<div class="memproto">
|
|
|
|
|
<div class="memtemplate">
|
|
|
|
|
template<typename X > </div>
|
|
|
|
|
<table class="mlabels">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="mlabels-left">
|
|
|
|
|
<table class="memname">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="memname">void <a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">range_queries::heavy_light_decomposition::Tree</a>< X >::dfs_size </td>
|
|
|
|
|
<td>(</td>
|
|
|
|
|
<td class="paramtype">int </td>
|
|
|
|
|
<td class="paramname"><em>u</em>, </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="paramkey"></td>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td class="paramtype">int </td>
|
|
|
|
|
<td class="paramname"><em>p</em> = <code>-1</code> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td>)</td>
|
|
|
|
|
<td></td><td></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="mlabels-right">
|
|
|
|
|
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">private</span></span> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</div><div class="memdoc">
|
|
|
|
|
|
|
|
|
|
<p>Utility function to compute sub-tree sizes. </p>
|
|
|
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
|
|
|
<table class="params">
|
|
|
|
|
<tr><td class="paramname">u</td><td>current dfs node </td></tr>
|
|
|
|
|
<tr><td class="paramname">p</td><td>the parent of node</td></tr>
|
|
|
|
|
<tr><td class="paramname">u</td><td></td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  {</div>
|
|
|
|
|
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keywordtype">int</span> &v : <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab1aeaefa1bd97b867c652ba916fbdb43">t_adj</a>[u]) {</div>
|
|
|
|
|
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  <span class="keywordflow">if</span> (v ^ p) {</div>
|
|
|
|
|
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#aa339c31ec74cd86a4842a8b09653d460">dfs_size</a>(v, u);</div>
|
|
|
|
|
<div class="line"><a name="l00105"></a><span class="lineno"> 105</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ada1494fccbc7f1f07b2f9be9f7e07ad5">t_size</a>[u] += <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ada1494fccbc7f1f07b2f9be9f7e07ad5">t_size</a>[v];</div>
|
|
|
|
|
<div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  }</div>
|
|
|
|
|
</div><!-- fragment -->
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<a id="ad22d760a5a33545a70e7ea5e1786c8dc"></a>
|
|
|
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ad22d760a5a33545a70e7ea5e1786c8dc">◆ </a></span>init()</h2>
|
|
|
|
|
|
|
|
|
|
<div class="memitem">
|
|
|
|
|
<div class="memproto">
|
|
|
|
|
<div class="memtemplate">
|
|
|
|
|
template<typename X > </div>
|
|
|
|
|
<table class="mlabels">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="mlabels-left">
|
|
|
|
|
<table class="memname">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="memname">void <a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">range_queries::heavy_light_decomposition::Tree</a>< X >::init </td>
|
|
|
|
|
<td>(</td>
|
|
|
|
|
<td class="paramname"></td><td>)</td>
|
|
|
|
|
<td></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="mlabels-right">
|
|
|
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</div><div class="memdoc">
|
|
|
|
|
|
|
|
|
|
<p>This function must be called after the tree adjacency list and node values are populated The function initializes the required parameters, and populates the segment tree. </p>
|
|
|
|
|
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  {</div>
|
|
|
|
|
<div class="line"><a name="l00187"></a><span class="lineno"> 187</span>  assert(<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">t_nodes</a> > 0);</div>
|
|
|
|
|
<div class="line"><a name="l00188"></a><span class="lineno"> 188</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#aa339c31ec74cd86a4842a8b09653d460">dfs_size</a>(<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#aa6c37e840355b9fb2105181c578694e8">t_root</a>);</div>
|
|
|
|
|
<div class="line"><a name="l00189"></a><span class="lineno"> 189</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae8de7aefcb6635d3dacdd174cd4890c4">dfs_lca</a>(<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#aa6c37e840355b9fb2105181c578694e8">t_root</a>);</div>
|
|
|
|
|
<div class="line"><a name="l00190"></a><span class="lineno"> 190</span>  }</div>
|
|
|
|
|
</div><!-- fragment --><div class="dynheader">
|
|
|
|
|
Here is the call graph for this function:</div>
|
|
|
|
|
<div class="dyncontent">
|
|
|
|
|
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree_ad22d760a5a33545a70e7ea5e1786c8dc_cgraph.svg" width="352" height="147"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<a id="a8f7bca1746d40f21ad832fcea59aa6c6"></a>
|
|
|
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a8f7bca1746d40f21ad832fcea59aa6c6">◆ </a></span>kth_ancestor()</h2>
|
|
|
|
|
|
|
|
|
|
<div class="memitem">
|
|
|
|
|
<div class="memproto">
|
|
|
|
|
<div class="memtemplate">
|
|
|
|
|
template<typename X > </div>
|
|
|
|
|
<table class="mlabels">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="mlabels-left">
|
|
|
|
|
<table class="memname">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="memname">int <a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">range_queries::heavy_light_decomposition::Tree</a>< X >::kth_ancestor </td>
|
|
|
|
|
<td>(</td>
|
|
|
|
|
<td class="paramtype">int </td>
|
|
|
|
|
<td class="paramname"><em>p</em>, </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="paramkey"></td>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td class="paramtype">const int & </td>
|
|
|
|
|
<td class="paramname"><em>dist</em> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td>)</td>
|
|
|
|
|
<td></td><td></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="mlabels-right">
|
|
|
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</div><div class="memdoc">
|
|
|
|
|
|
|
|
|
|
<p>The function returns the kth ancestor of a node. </p>
|
|
|
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
|
|
|
<table class="params">
|
|
|
|
|
<tr><td class="paramname">p</td><td>the node id whose kth ancestor is to be found </td></tr>
|
|
|
|
|
<tr><td class="paramname">dist</td><td>the distance to move up the tree </td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<dl class="section return"><dt>Returns</dt><dd>the kth ancestor of node </dd></dl>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00218"></a><span class="lineno"> 218</span>  {</div>
|
|
|
|
|
<div class="line"><a name="l00219"></a><span class="lineno"> 219</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ac7761255f2ba06b398b9aae5e4dce5f3">lift</a>(&p, dist);</div>
|
|
|
|
|
<div class="line"><a name="l00220"></a><span class="lineno"> 220</span>  <span class="keywordflow">return</span> p;</div>
|
|
|
|
|
<div class="line"><a name="l00221"></a><span class="lineno"> 221</span>  }</div>
|
|
|
|
|
</div><!-- fragment --><div class="dynheader">
|
|
|
|
|
Here is the call graph for this function:</div>
|
|
|
|
|
<div class="dyncontent">
|
|
|
|
|
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree_a8f7bca1746d40f21ad832fcea59aa6c6_cgraph.svg" width="352" height="67"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<a id="ae2b407e64aaf9878fbee7ee6efe9c7d4"></a>
|
|
|
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ae2b407e64aaf9878fbee7ee6efe9c7d4">◆ </a></span>lca()</h2>
|
|
|
|
|
|
|
|
|
|
<div class="memitem">
|
|
|
|
|
<div class="memproto">
|
|
|
|
|
<div class="memtemplate">
|
|
|
|
|
template<typename X > </div>
|
|
|
|
|
<table class="mlabels">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="mlabels-left">
|
|
|
|
|
<table class="memname">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="memname">int <a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">range_queries::heavy_light_decomposition::Tree</a>< X >::lca </td>
|
|
|
|
|
<td>(</td>
|
|
|
|
|
<td class="paramtype">int </td>
|
|
|
|
|
<td class="paramname"><em>a</em>, </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="paramkey"></td>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td class="paramtype">int </td>
|
|
|
|
|
<td class="paramname"><em>b</em> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td>)</td>
|
|
|
|
|
<td></td><td></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="mlabels-right">
|
|
|
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</div><div class="memdoc">
|
|
|
|
|
|
|
|
|
|
<p>The function returns the least common ancestor of two nodes. </p>
|
|
|
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
|
|
|
<table class="params">
|
|
|
|
|
<tr><td class="paramname">a</td><td>node id_1 </td></tr>
|
|
|
|
|
<tr><td class="paramname">b</td><td>node id_2 </td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<dl class="section return"><dt>Returns</dt><dd>the least common ancestor of node a, and node b </dd></dl>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00229"></a><span class="lineno"> 229</span>  {</div>
|
|
|
|
|
<div class="line"><a name="l00230"></a><span class="lineno"> 230</span>  assert(a >= 0 and b >= 0 and a < <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">t_nodes</a> and b < <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">t_nodes</a>);</div>
|
|
|
|
|
<div class="line"><a name="l00231"></a><span class="lineno"> 231</span>  <span class="keywordflow">if</span> (<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a>[a] > <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a>[b]) {</div>
|
|
|
|
|
<div class="line"><a name="l00232"></a><span class="lineno"> 232</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ac7761255f2ba06b398b9aae5e4dce5f3">lift</a>(&a, <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a>[a] - <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a>[b]);</div>
|
|
|
|
|
<div class="line"><a name="l00233"></a><span class="lineno"> 233</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span>  <span class="keywordflow">if</span> (<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a>[b] > <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a>[a]) {</div>
|
|
|
|
|
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ac7761255f2ba06b398b9aae5e4dce5f3">lift</a>(&b, <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a>[b] - <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">t_depth</a>[a]);</div>
|
|
|
|
|
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00237"></a><span class="lineno"> 237</span>  <span class="keywordflow">if</span> (a == b) {</div>
|
|
|
|
|
<div class="line"><a name="l00238"></a><span class="lineno"> 238</span>  <span class="keywordflow">return</span> a;</div>
|
|
|
|
|
<div class="line"><a name="l00239"></a><span class="lineno"> 239</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00240"></a><span class="lineno"> 240</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k = <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab2ab020f798d00be2613ecf63074b7c1">t_maxlift</a> - 1; k >= 0; k--) {</div>
|
|
|
|
|
<div class="line"><a name="l00241"></a><span class="lineno"> 241</span>  <span class="keywordflow">if</span> (<a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>[a][k] != <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>[b][k]) {</div>
|
|
|
|
|
<div class="line"><a name="l00242"></a><span class="lineno"> 242</span>  a = <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>[a][k];</div>
|
|
|
|
|
<div class="line"><a name="l00243"></a><span class="lineno"> 243</span>  b = <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>[b][k];</div>
|
|
|
|
|
<div class="line"><a name="l00244"></a><span class="lineno"> 244</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00245"></a><span class="lineno"> 245</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00246"></a><span class="lineno"> 246</span>  <span class="keywordflow">return</span> <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>[a][0];</div>
|
|
|
|
|
<div class="line"><a name="l00247"></a><span class="lineno"> 247</span>  }</div>
|
|
|
|
|
</div><!-- fragment --><div class="dynheader">
|
|
|
|
|
Here is the call graph for this function:</div>
|
|
|
|
|
<div class="dyncontent">
|
|
|
|
|
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree_ae2b407e64aaf9878fbee7ee6efe9c7d4_cgraph.svg" width="352" height="67"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<a id="ac7761255f2ba06b398b9aae5e4dce5f3"></a>
|
|
|
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ac7761255f2ba06b398b9aae5e4dce5f3">◆ </a></span>lift()</h2>
|
|
|
|
|
|
|
|
|
|
<div class="memitem">
|
|
|
|
|
<div class="memproto">
|
|
|
|
|
<div class="memtemplate">
|
|
|
|
|
template<typename X > </div>
|
|
|
|
|
<table class="mlabels">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="mlabels-left">
|
|
|
|
|
<table class="memname">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="memname">void <a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">range_queries::heavy_light_decomposition::Tree</a>< X >::lift </td>
|
|
|
|
|
<td>(</td>
|
|
|
|
|
<td class="paramtype">int *const </td>
|
|
|
|
|
<td class="paramname"><em>p</em>, </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="paramkey"></td>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td class="paramtype">int </td>
|
|
|
|
|
<td class="paramname"><em>dist</em> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td>)</td>
|
|
|
|
|
<td></td><td></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="mlabels-right">
|
|
|
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</div><div class="memdoc">
|
|
|
|
|
|
|
|
|
|
<p>The function lifts a node, k units up the tree. The lifting is done in place, and the result is stored in the address pointed by p. </p>
|
|
|
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
|
|
|
<table class="params">
|
|
|
|
|
<tr><td class="paramname">p</td><td>a pointer to the variable that stores the node id </td></tr>
|
|
|
|
|
<tr><td class="paramname">dist</td><td>the distance to move up the tree </td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00200"></a><span class="lineno"> 200</span>  {</div>
|
|
|
|
|
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k = 0; k < <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab2ab020f798d00be2613ecf63074b7c1">t_maxlift</a>; k++) {</div>
|
|
|
|
|
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span>  <span class="keywordflow">if</span> (*p == -1) {</div>
|
|
|
|
|
<div class="line"><a name="l00203"></a><span class="lineno"> 203</span>  <span class="keywordflow">return</span>;</div>
|
|
|
|
|
<div class="line"><a name="l00204"></a><span class="lineno"> 204</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00205"></a><span class="lineno"> 205</span>  <span class="keywordflow">if</span> (dist & 1) {</div>
|
|
|
|
|
<div class="line"><a name="l00206"></a><span class="lineno"> 206</span>  *p = <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">t_par</a>[*p][k];</div>
|
|
|
|
|
<div class="line"><a name="l00207"></a><span class="lineno"> 207</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00208"></a><span class="lineno"> 208</span>  dist >>= 1;</div>
|
|
|
|
|
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span>  }</div>
|
|
|
|
|
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span>  }</div>
|
|
|
|
|
</div><!-- fragment -->
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<a id="a04cd96efaba147b19d3afc769b90ff70"></a>
|
|
|
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a04cd96efaba147b19d3afc769b90ff70">◆ </a></span>set_node_val()</h2>
|
|
|
|
|
|
|
|
|
|
<div class="memitem">
|
|
|
|
|
<div class="memproto">
|
|
|
|
|
<div class="memtemplate">
|
|
|
|
|
template<typename X > </div>
|
|
|
|
|
<table class="mlabels">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="mlabels-left">
|
|
|
|
|
<table class="memname">
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="memname">void <a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">range_queries::heavy_light_decomposition::Tree</a>< X >::set_node_val </td>
|
|
|
|
|
<td>(</td>
|
|
|
|
|
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< X > & </td>
|
|
|
|
|
<td class="paramname"><em>node_val</em></td><td>)</td>
|
|
|
|
|
<td></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="mlabels-right">
|
|
|
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</div><div class="memdoc">
|
|
|
|
|
|
|
|
|
|
<p>Set the values for all the nodes. </p>
|
|
|
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
|
|
|
<table class="params">
|
|
|
|
|
<tr><td class="paramname">node_val</td><td>a vector of size n, with all the node values where, n is the number of nodes </td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  {</div>
|
|
|
|
|
<div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  assert(<span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(node_val.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>()) == <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">t_nodes</a>);</div>
|
|
|
|
|
<div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  <a class="code" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a135b7952593c9b1aae38fcaf1cc1abf7">t_val</a> = node_val;</div>
|
|
|
|
|
<div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  }</div>
|
|
|
|
|
</div><!-- fragment --><div class="dynheader">
|
|
|
|
|
Here is the call graph for this function:</div>
|
|
|
|
|
<div class="dyncontent">
|
|
|
|
|
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree_a04cd96efaba147b19d3afc769b90ff70_cgraph.svg" width="322" height="67"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<hr/>The documentation for this class was generated from the following file:<ul>
|
|
|
|
|
<li>range_queries/<a class="el" href="../../d2/de9/heavy__light__decomposition_8cpp.html">heavy_light_decomposition.cpp</a></li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div><!-- contents -->
|
|
|
|
|
</div><!-- doc-content -->
|
|
|
|
|
<div class="ttc" id="aresize_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/resize.html">std::vector::resize</a></div><div class="ttdeci">T resize(T... args)</div></div>
|
|
|
|
|
<div class="ttc" id="afloor_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/floor.html">std::floor</a></div><div class="ttdeci">T floor(T... args)</div></div>
|
|
|
|
|
<div class="ttc" id="aclassrange__queries_1_1heavy__light__decomposition_1_1_tree_html_ada1494fccbc7f1f07b2f9be9f7e07ad5"><div class="ttname"><a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ada1494fccbc7f1f07b2f9be9f7e07ad5">range_queries::heavy_light_decomposition::Tree::t_size</a></div><div class="ttdeci">std::vector< int > t_size</div><div class="ttdoc">a vector to store the subtree size rooted at node</div><div class="ttdef"><b>Definition:</b> heavy_light_decomposition.cpp:89</div></div>
|
|
|
|
|
<div class="ttc" id="aclassrange__queries_1_1heavy__light__decomposition_1_1_tree_html_ae8de7aefcb6635d3dacdd174cd4890c4"><div class="ttname"><a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae8de7aefcb6635d3dacdd174cd4890c4">range_queries::heavy_light_decomposition::Tree::dfs_lca</a></div><div class="ttdeci">void dfs_lca(int u, int p=-1)</div><div class="ttdoc">Utility function to populate the t_par vector.</div><div class="ttdef"><b>Definition:</b> heavy_light_decomposition.cpp:116</div></div>
|
|
|
|
|
<div class="ttc" id="aclassrange__queries_1_1heavy__light__decomposition_1_1_tree_html_aa6c37e840355b9fb2105181c578694e8"><div class="ttname"><a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#aa6c37e840355b9fb2105181c578694e8">range_queries::heavy_light_decomposition::Tree::t_root</a></div><div class="ttdeci">int t_root</div><div class="ttdoc">the root of the tree</div><div class="ttdef"><b>Definition:</b> heavy_light_decomposition.cpp:91</div></div>
|
|
|
|
|
<div class="ttc" id="aclassrange__queries_1_1heavy__light__decomposition_1_1_tree_html_ab2ab020f798d00be2613ecf63074b7c1"><div class="ttname"><a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab2ab020f798d00be2613ecf63074b7c1">range_queries::heavy_light_decomposition::Tree::t_maxlift</a></div><div class="ttdeci">const int t_maxlift</div><div class="ttdoc">maximum possible height of the tree</div><div class="ttdef"><b>Definition:</b> heavy_light_decomposition.cpp:85</div></div>
|
|
|
|
|
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector< int ></a></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="aclassrange__queries_1_1heavy__light__decomposition_1_1_tree_html_ac7761255f2ba06b398b9aae5e4dce5f3"><div class="ttname"><a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ac7761255f2ba06b398b9aae5e4dce5f3">range_queries::heavy_light_decomposition::Tree::lift</a></div><div class="ttdeci">void lift(int *const p, int dist)</div><div class="ttdoc">The function lifts a node, k units up the tree. The lifting is done in place, and the result is store...</div><div class="ttdef"><b>Definition:</b> heavy_light_decomposition.cpp:200</div></div>
|
|
|
|
|
<div class="ttc" id="apush_back_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">std::vector::push_back</a></div><div class="ttdeci">T push_back(T... args)</div></div>
|
|
|
|
|
<div class="ttc" id="aclassrange__queries_1_1heavy__light__decomposition_1_1_tree_html_ab1aeaefa1bd97b867c652ba916fbdb43"><div class="ttname"><a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ab1aeaefa1bd97b867c652ba916fbdb43">range_queries::heavy_light_decomposition::Tree::t_adj</a></div><div class="ttdeci">std::vector< std::list< int > > t_adj</div><div class="ttdoc">an adjacency list to stores the tree edges</div><div class="ttdef"><b>Definition:</b> heavy_light_decomposition.cpp:83</div></div>
|
|
|
|
|
<div class="ttc" id="aclassrange__queries_1_1heavy__light__decomposition_1_1_tree_html_ae4630fa70a80a1dc65a875488a67178a"><div class="ttname"><a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#ae4630fa70a80a1dc65a875488a67178a">range_queries::heavy_light_decomposition::Tree::t_nodes</a></div><div class="ttdeci">const int t_nodes</div><div class="ttdoc">number of nodes</div><div class="ttdef"><b>Definition:</b> heavy_light_decomposition.cpp:84</div></div>
|
|
|
|
|
<div class="ttc" id="aclassrange__queries_1_1heavy__light__decomposition_1_1_tree_html_a350157a5fb79f76fceae33fc84171203"><div class="ttname"><a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a350157a5fb79f76fceae33fc84171203">range_queries::heavy_light_decomposition::Tree::t_par</a></div><div class="ttdeci">std::vector< std::vector< int > > t_par</div><div class="ttdoc">a matrix to store every node's 2^kth parent</div><div class="ttdef"><b>Definition:</b> heavy_light_decomposition.cpp:87</div></div>
|
|
|
|
|
<div class="ttc" id="aclassrange__queries_1_1heavy__light__decomposition_1_1_tree_html_a135b7952593c9b1aae38fcaf1cc1abf7"><div class="ttname"><a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a135b7952593c9b1aae38fcaf1cc1abf7">range_queries::heavy_light_decomposition::Tree::t_val</a></div><div class="ttdeci">std::vector< X > t_val</div><div class="ttdoc">values of nodes</div><div class="ttdef"><b>Definition:</b> heavy_light_decomposition.cpp:92</div></div>
|
|
|
|
|
<div class="ttc" id="aassign_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/assign.html">std::vector::assign</a></div><div class="ttdeci">T assign(T... args)</div></div>
|
|
|
|
|
<div class="ttc" id="aclassrange__queries_1_1heavy__light__decomposition_1_1_tree_html_aa339c31ec74cd86a4842a8b09653d460"><div class="ttname"><a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#aa339c31ec74cd86a4842a8b09653d460">range_queries::heavy_light_decomposition::Tree::dfs_size</a></div><div class="ttdeci">void dfs_size(int u, int p=-1)</div><div class="ttdoc">Utility function to compute sub-tree sizes.</div><div class="ttdef"><b>Definition:</b> heavy_light_decomposition.cpp:101</div></div>
|
|
|
|
|
<div class="ttc" id="aclassrange__queries_1_1heavy__light__decomposition_1_1_tree_html_a0efd0b9c564092f443ca97030d866ef1"><div class="ttname"><a href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html#a0efd0b9c564092f443ca97030d866ef1">range_queries::heavy_light_decomposition::Tree::t_depth</a></div><div class="ttdeci">std::vector< int > t_depth</div><div class="ttdoc">a vector to store the depth of a node,</div><div class="ttdef"><b>Definition:</b> heavy_light_decomposition.cpp:88</div></div>
|
|
|
|
|
<!-- start footer part -->
|
|
|
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
|
|
|
<ul>
|
|
|
|
|
<li class="navelem"><a class="el" href="../../dd/d69/namespacerange__queries.html">range_queries</a></li><li class="navelem"><b>heavy_light_decomposition</b></li><li class="navelem"><a class="el" href="../../d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html">Tree</a></li>
|
|
|
|
|
<li class="footer">Generated by
|
|
|
|
|
<a href="http://www.doxygen.org/index.html">
|
|
|
|
|
<img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.8.18 </li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|