Documentation for c26eea874d

This commit is contained in:
realstealthninja
2025-05-19 11:38:33 +00:00
parent c7a9a42397
commit 14583a2f33
2829 changed files with 30266 additions and 21669 deletions

View File

@@ -4,7 +4,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.12.0"/>
<meta name="generator" content="Doxygen 1.13.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TheAlgorithms/C++: strings/rabin_karp.cpp Source File</title>
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
@@ -60,7 +60,7 @@ window.MathJax = {
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<!-- Generated by Doxygen 1.13.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
@@ -124,7 +124,7 @@ $(function(){initNavTree('d6/dce/rabin__karp_8cpp_source.html','../../'); initRe
<div class="headertitle"><div class="title">rabin_karp.cpp</div></div>
</div><!--header-->
<div class="contents">
<a href="../../d6/dce/rabin__karp_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span> </div>
<a href="../../d6/dce/rabin__karp_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span><span class="preprocessor">#include &lt;cassert&gt;</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span><span class="preprocessor">#include &lt;cmath&gt;</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span><span class="preprocessor">#include &lt;iostream&gt;</span></div>
@@ -146,7 +146,7 @@ $(function(){initNavTree('d6/dce/rabin__karp_8cpp_source.html','../../'); initRe
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> <span class="keywordflow">return</span> result;</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span>}</div>
</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> </div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span></div>
<div class="foldopen" id="foldopen00042" data-start="{" data-end="}">
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"><a class="line" href="../../d9/d03/namespacestring__search.html#aed769d565b705a9b3e0eb1ec74088893"> 42</a></span>int64_t <a class="code hl_function" href="../../d9/d03/namespacestring__search.html#aed769d565b705a9b3e0eb1ec74088893">recalculate_hash</a>(<span class="keyword">const</span> std::string&amp; s, <span class="keywordtype">int</span> old_index, <span class="keywordtype">int</span> new_index,</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> int64_t old_hash, <span class="keywordtype">int</span> patLength) {</div>
@@ -156,7 +156,7 @@ $(function(){initNavTree('d6/dce/rabin__karp_8cpp_source.html','../../'); initRe
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> <span class="keywordflow">return</span> new_hash;</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span>}</div>
</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> </div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span></div>
<div class="foldopen" id="foldopen00060" data-start="{" data-end="}">
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"><a class="line" href="../../d9/d03/namespacestring__search.html#aebe07cea289a13142503d98be7df11fd"> 60</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="../../d9/d03/namespacestring__search.html#aebe07cea289a13142503d98be7df11fd">check_if_equal</a>(<span class="keyword">const</span> std::string&amp; str1, <span class="keyword">const</span> std::string&amp; str2,</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> <span class="keywordtype">int</span> start1, <span class="keywordtype">int</span> end1, <span class="keywordtype">int</span> start2, <span class="keywordtype">int</span> end2) {</div>
@@ -173,7 +173,8 @@ $(function(){initNavTree('d6/dce/rabin__karp_8cpp_source.html','../../'); initRe
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span>}</div>
</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> </div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span></div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> </div>
<div class="foldopen" id="foldopen00083" data-start="{" data-end="}">
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"><a class="line" href="../../d9/d03/namespacestring__search.html#a21c673d56cbf67b1d2ee4d869185b7d9"> 83</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../d9/d03/namespacestring__search.html#a21c673d56cbf67b1d2ee4d869185b7d9">rabin_karp</a>(<span class="keyword">const</span> std::string&amp; str, <span class="keyword">const</span> std::string&amp; pat) {</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> int64_t pat_hash = <a class="code hl_function" href="../../d9/d03/namespacestring__search.html#a8fb0bc932ba8b582c9f4c71338d050f8">create_hash</a>(pat, pat.size());</div>
@@ -196,13 +197,13 @@ $(function(){initNavTree('d6/dce/rabin__karp_8cpp_source.html','../../'); initRe
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span>} <span class="comment">// namespace string_search</span></div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> </div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span><span class="keyword">using </span><a class="code hl_function" href="../../d9/d03/namespacestring__search.html#a21c673d56cbf67b1d2ee4d869185b7d9">string_search::rabin_karp</a>;</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> </div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span></div>
<div class="foldopen" id="foldopen00105" data-start="{" data-end="}">
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"><a class="line" href="../../d6/dce/rabin__karp_8cpp.html#a840291bc02cba5474a4cb46a9b9566fe"> 105</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../d6/dce/rabin__karp_8cpp.html#a840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> assert(rabin_karp(<span class="stringliteral">&quot;helloWorld&quot;</span>, <span class="stringliteral">&quot;world&quot;</span>) == -1);</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> assert(rabin_karp(<span class="stringliteral">&quot;helloWorld&quot;</span>, <span class="stringliteral">&quot;World&quot;</span>) == 5);</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> assert(rabin_karp(<span class="stringliteral">&quot;this_is_c++&quot;</span>, <span class="stringliteral">&quot;c++&quot;</span>) == 8);</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> assert(rabin_karp(<span class="stringliteral">&quot;happy_coding&quot;</span>, <span class="stringliteral">&quot;happy&quot;</span>) == 0);</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> assert(<a class="code hl_function" href="../../d6/dce/rabin__karp_8cpp.html#a21c673d56cbf67b1d2ee4d869185b7d9">rabin_karp</a>(<span class="stringliteral">&quot;helloWorld&quot;</span>, <span class="stringliteral">&quot;world&quot;</span>) == -1);</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> assert(<a class="code hl_function" href="../../d6/dce/rabin__karp_8cpp.html#a21c673d56cbf67b1d2ee4d869185b7d9">rabin_karp</a>(<span class="stringliteral">&quot;helloWorld&quot;</span>, <span class="stringliteral">&quot;World&quot;</span>) == 5);</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> assert(<a class="code hl_function" href="../../d6/dce/rabin__karp_8cpp.html#a21c673d56cbf67b1d2ee4d869185b7d9">rabin_karp</a>(<span class="stringliteral">&quot;this_is_c++&quot;</span>, <span class="stringliteral">&quot;c++&quot;</span>) == 8);</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> assert(<a class="code hl_function" href="../../d6/dce/rabin__karp_8cpp.html#a21c673d56cbf67b1d2ee4d869185b7d9">rabin_karp</a>(<span class="stringliteral">&quot;happy_coding&quot;</span>, <span class="stringliteral">&quot;happy&quot;</span>) == 0);</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span>}</div>
</div>
@@ -211,6 +212,7 @@ $(function(){initNavTree('d6/dce/rabin__karp_8cpp_source.html','../../'); initRe
<div class="ttc" id="anamespacestring__search_html_a8fb0bc932ba8b582c9f4c71338d050f8"><div class="ttname"><a href="../../d9/d03/namespacestring__search.html#a8fb0bc932ba8b582c9f4c71338d050f8">string_search::create_hash</a></div><div class="ttdeci">int64_t create_hash(const std::string &amp;s, int n)</div><div class="ttdef"><b>Definition</b> <a href="#l00025">rabin_karp.cpp:25</a></div></div>
<div class="ttc" id="anamespacestring__search_html_aebe07cea289a13142503d98be7df11fd"><div class="ttname"><a href="../../d9/d03/namespacestring__search.html#aebe07cea289a13142503d98be7df11fd">string_search::check_if_equal</a></div><div class="ttdeci">bool check_if_equal(const std::string &amp;str1, const std::string &amp;str2, int start1, int end1, int start2, int end2)</div><div class="ttdef"><b>Definition</b> <a href="#l00060">rabin_karp.cpp:60</a></div></div>
<div class="ttc" id="anamespacestring__search_html_aed769d565b705a9b3e0eb1ec74088893"><div class="ttname"><a href="../../d9/d03/namespacestring__search.html#aed769d565b705a9b3e0eb1ec74088893">string_search::recalculate_hash</a></div><div class="ttdeci">int64_t recalculate_hash(const std::string &amp;s, int old_index, int new_index, int64_t old_hash, int patLength)</div><div class="ttdef"><b>Definition</b> <a href="#l00042">rabin_karp.cpp:42</a></div></div>
<div class="ttc" id="arabin__karp_8cpp_html_a21c673d56cbf67b1d2ee4d869185b7d9"><div class="ttname"><a href="../../d6/dce/rabin__karp_8cpp.html#a21c673d56cbf67b1d2ee4d869185b7d9">rabin_karp</a></div><div class="ttdeci">int rabin_karp(const std::string &amp;str, const std::string &amp;pat)</div><div class="ttdef"><b>Definition</b> <a href="#l00083">rabin_karp.cpp:83</a></div></div>
<div class="ttc" id="arabin__karp_8cpp_html_a840291bc02cba5474a4cb46a9b9566fe"><div class="ttname"><a href="../../d6/dce/rabin__karp_8cpp.html#a840291bc02cba5474a4cb46a9b9566fe">main</a></div><div class="ttdeci">int main(void)</div><div class="ttdef"><b>Definition</b> <a href="#l00105">rabin_karp.cpp:105</a></div></div>
<div class="ttc" id="arabin__karp_8cpp_html_ac4add2a227a10511e0128d63952030e8"><div class="ttname"><a href="../../d6/dce/rabin__karp_8cpp.html#ac4add2a227a10511e0128d63952030e8">PRIME</a></div><div class="ttdeci">#define PRIME</div><div class="ttdoc">Prime modulus for hash functions.</div><div class="ttdef"><b>Definition</b> <a href="#l00016">rabin_karp.cpp:16</a></div></div>
</div><!-- fragment --></div><!-- contents -->
@@ -219,7 +221,7 @@ $(function(){initNavTree('d6/dce/rabin__karp_8cpp_source.html','../../'); initRe
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_73a3cc5065b223eb41b02873c0e19f0e.html">strings</a></li><li class="navelem"><a class="el" href="../../d6/dce/rabin__karp_8cpp.html">rabin_karp.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.12.0 </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.13.2 </li>
</ul>
</div>
</body>