mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-21 20:31:43 +08:00
Documentation for 53a6c16730
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<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.2"/>
|
||||
<meta name="generator" content="Doxygen 1.9.3"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: data_structures/sparse_table.cpp File Reference</title>
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
@@ -30,8 +30,8 @@ MathJax.Hub.Config({
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<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>
|
||||
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.2 -->
|
||||
<!-- Generated by Doxygen 1.9.3 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
|
||||
@@ -187,10 +187,10 @@ constexpr uint8_t </td><td class="memItemRight" valign="bottom"><b>data_str
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
|
||||
<div class="fragment"><div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> {</div>
|
||||
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> <a class="code hl_function" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
|
||||
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span>}</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 161</span> {</div>
|
||||
<div class="line"><span class="lineno"> 162</span> <a class="code hl_function" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
|
||||
<div class="line"><span class="lineno"> 163</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><span class="lineno"> 164</span>}</div>
|
||||
<div class="ttc" id="adata__structures_2sparse__table_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../d6/d42/data__structures_2sparse__table_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition:</b> sparse_table.cpp:128</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
@@ -235,32 +235,32 @@ Here is the call graph for this function:</div>
|
||||
<p >< as 1 is smallest from 1..9</p>
|
||||
<p >< as 2 is smallest from 2..6</p>
|
||||
<p >< as 3 is smallest from 3..8</p>
|
||||
<div class="fragment"><div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> {</div>
|
||||
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> <span class="comment">/* We take an array as an input on which we need to perform the ranged</span></div>
|
||||
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span><span class="comment"> * minimum queries[RMQ](https://en.wikipedia.org/wiki/Range_minimum_query).</span></div>
|
||||
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span><span class="comment"> */</span></div>
|
||||
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<int64_t, 10></a> testcase = {</div>
|
||||
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> 1, 2, 3, 4, 5,</div>
|
||||
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> 6, 7, 8, 9, 10}; <span class="comment">///< array on which RMQ will be performed.</span></div>
|
||||
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span> <span class="keywordtype">size_t</span> testcase_size =</div>
|
||||
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> <span class="keyword">sizeof</span>(testcase) / <span class="keyword">sizeof</span>(testcase[0]); <span class="comment">///< size of self test's array</span></div>
|
||||
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> </div>
|
||||
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> <a class="code hl_struct" href="../../da/d37/structdata__structures_1_1sparse__table_1_1_sparse__table.html">data_structures::sparse_table::Sparse_table</a></div>
|
||||
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span> st{}; <span class="comment">///< declaring sparse tree</span></div>
|
||||
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> </div>
|
||||
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/copy.html">std::copy</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(testcase), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(testcase),</div>
|
||||
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(st.A)); <span class="comment">///< copying array to the struct</span></div>
|
||||
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> st.n = testcase_size; <span class="comment">///< passing the array's size to the struct</span></div>
|
||||
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> </div>
|
||||
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> st.buildST(); <span class="comment">///< precomputing sparse tree</span></div>
|
||||
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> </div>
|
||||
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> <span class="comment">// pass queries of the form: [l,r]</span></div>
|
||||
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> assert(st.query(1, 9) == 1); <span class="comment">///< as 1 is smallest from 1..9</span></div>
|
||||
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> assert(st.query(2, 6) == 2); <span class="comment">///< as 2 is smallest from 2..6</span></div>
|
||||
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> assert(st.query(3, 8) == 3); <span class="comment">///< as 3 is smallest from 3..8</span></div>
|
||||
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> </div>
|
||||
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</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">"Self-test implementations passed!"</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span>}</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 128</span> {</div>
|
||||
<div class="line"><span class="lineno"> 129</span> <span class="comment">/* We take an array as an input on which we need to perform the ranged</span></div>
|
||||
<div class="line"><span class="lineno"> 130</span><span class="comment"> * minimum queries[RMQ](https://en.wikipedia.org/wiki/Range_minimum_query).</span></div>
|
||||
<div class="line"><span class="lineno"> 131</span><span class="comment"> */</span></div>
|
||||
<div class="line"><span class="lineno"> 132</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<int64_t, 10></a> testcase = {</div>
|
||||
<div class="line"><span class="lineno"> 133</span> 1, 2, 3, 4, 5,</div>
|
||||
<div class="line"><span class="lineno"> 134</span> 6, 7, 8, 9, 10}; <span class="comment">///< array on which RMQ will be performed.</span></div>
|
||||
<div class="line"><span class="lineno"> 135</span> <span class="keywordtype">size_t</span> testcase_size =</div>
|
||||
<div class="line"><span class="lineno"> 136</span> <span class="keyword">sizeof</span>(testcase) / <span class="keyword">sizeof</span>(testcase[0]); <span class="comment">///< size of self test's array</span></div>
|
||||
<div class="line"><span class="lineno"> 137</span> </div>
|
||||
<div class="line"><span class="lineno"> 138</span> <a class="code hl_struct" href="../../da/d37/structdata__structures_1_1sparse__table_1_1_sparse__table.html">data_structures::sparse_table::Sparse_table</a></div>
|
||||
<div class="line"><span class="lineno"> 139</span> st{}; <span class="comment">///< declaring sparse tree</span></div>
|
||||
<div class="line"><span class="lineno"> 140</span> </div>
|
||||
<div class="line"><span class="lineno"> 141</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/copy.html">std::copy</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(testcase), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(testcase),</div>
|
||||
<div class="line"><span class="lineno"> 142</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(st.A)); <span class="comment">///< copying array to the struct</span></div>
|
||||
<div class="line"><span class="lineno"> 143</span> st.n = testcase_size; <span class="comment">///< passing the array's size to the struct</span></div>
|
||||
<div class="line"><span class="lineno"> 144</span> </div>
|
||||
<div class="line"><span class="lineno"> 145</span> st.buildST(); <span class="comment">///< precomputing sparse tree</span></div>
|
||||
<div class="line"><span class="lineno"> 146</span> </div>
|
||||
<div class="line"><span class="lineno"> 147</span> <span class="comment">// pass queries of the form: [l,r]</span></div>
|
||||
<div class="line"><span class="lineno"> 148</span> assert(st.query(1, 9) == 1); <span class="comment">///< as 1 is smallest from 1..9</span></div>
|
||||
<div class="line"><span class="lineno"> 149</span> assert(st.query(2, 6) == 2); <span class="comment">///< as 2 is smallest from 2..6</span></div>
|
||||
<div class="line"><span class="lineno"> 150</span> assert(st.query(3, 8) == 3); <span class="comment">///< as 3 is smallest from 3..8</span></div>
|
||||
<div class="line"><span class="lineno"> 151</span> </div>
|
||||
<div class="line"><span class="lineno"> 152</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">"Self-test implementations passed!"</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 153</span>}</div>
|
||||
<div class="ttc" id="aarray_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a></div></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="abegin_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a></div><div class="ttdeci">T begin(T... args)</div></div>
|
||||
@@ -309,7 +309,7 @@ Here is the call graph for this function:</div>
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_2e746e9d06bf2d8ff842208bcc6ebcfc.html">data_structures</a></li><li class="navelem"><a class="el" href="../../d6/d42/data__structures_2sparse__table_8cpp.html">sparse_table.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.2 </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.3 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user