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++: dynamic_programming/word_break.cpp File Reference</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');
@@ -156,7 +156,7 @@ Namespaces</h2></td></tr>
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a1cc9dd6e6190d10a010fdcdfe7a21a81" id="r_a1cc9dd6e6190d10a010fdcdfe7a21a81"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a1cc9dd6e6190d10a010fdcdfe7a21a81">dynamic_programming::word_break::exists</a> (const std::string &amp;str, const std::unordered_set&lt; std::string &gt; &amp;strSet)</td></tr>
<tr class="memdesc:a1cc9dd6e6190d10a010fdcdfe7a21a81"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function that checks if the string passed in param is present in the the unordered_set passed. <br /></td></tr>
<tr class="memdesc:a1cc9dd6e6190d10a010fdcdfe7a21a81"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function that checks if the string passed in param is present in the the <a class="el" href="../../d3/d6d/classunordered__set.html" title="STL class.">unordered_set</a> passed. <br /></td></tr>
<tr class="separator:a1cc9dd6e6190d10a010fdcdfe7a21a81"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a272b0f5cdb4e41fd6dee4538b808c06a" id="r_a272b0f5cdb4e41fd6dee4538b808c06a"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a272b0f5cdb4e41fd6dee4538b808c06a">dynamic_programming::word_break::check</a> (const std::string &amp;s, const std::unordered_set&lt; std::string &gt; &amp;strSet, int pos, std::vector&lt; int &gt; *dp)</td></tr>
<tr class="memdesc:a272b0f5cdb4e41fd6dee4538b808c06a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function that checks if the string passed in param can be segmented from position 'pos', and then correctly go on to segment the rest of the string correctly as well to reach a solution. <br /></td></tr>
@@ -254,18 +254,17 @@ pen apple". Note that you are allowed to reuse a dictionary word.</p>
<div class="line"><span class="lineno"> 105</span> <span class="comment">// if the prefix till current position is present in the dictionary</span></div>
<div class="line"><span class="lineno"> 106</span> <span class="comment">// and the remaining substring can also be segmented legally, then</span></div>
<div class="line"><span class="lineno"> 107</span> <span class="comment">// set solution at position pos in the memo, and return true</span></div>
<div class="line"><span class="lineno"> 108</span> <span class="keywordflow">if</span> (<a class="code hl_function" href="#a1cc9dd6e6190d10a010fdcdfe7a21a81">exists</a>(wordTillNow, strSet) &amp;&amp; check(s, strSet, i + 1, <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>)) {</div>
<div class="line"><span class="lineno"> 108</span> <span class="keywordflow">if</span> (exists(wordTillNow, strSet) &amp;&amp; check(s, strSet, i + 1, <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>)) {</div>
<div class="line"><span class="lineno"> 109</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>-&gt;at(pos) = 1;</div>
<div class="line"><span class="lineno"> 110</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><span class="lineno"> 111</span> }</div>
<div class="line"><span class="lineno"> 112</span> }</div>
<div class="line"><span class="lineno"> 113</span> <span class="comment">// if function has still not returned, then there must be no legal</span></div>
<div class="line"><span class="lineno"> 114</span> <span class="comment">// segmentation possible after segmenting at pos</span></div>
<div class="line"><span class="lineno"> 115</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>-&gt;at(pos) = 0; <span class="comment">// so set solution at pos as false</span></div>
<div class="line"><span class="lineno"> 115</span> dp-&gt;at(pos) = 0; <span class="comment">// so set solution at pos as false</span></div>
<div class="line"><span class="lineno"> 116</span> <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// and return no solution at position pos</span></div>
<div class="line"><span class="lineno"> 117</span>}</div>
<div class="ttc" id="anamespacedp_html"><div class="ttname"><a href="../../df/d88/namespacedp.html">dp</a></div><div class="ttdoc">for std::vector</div><div class="ttdef"><b>Definition</b> <a href="../../de/d8c/partition__problem_8cpp_source.html#l00039">partition_problem.cpp:39</a></div></div>
<div class="ttc" id="aword__break_8cpp_html_a1cc9dd6e6190d10a010fdcdfe7a21a81"><div class="ttname"><a href="#a1cc9dd6e6190d10a010fdcdfe7a21a81">dynamic_programming::word_break::exists</a></div><div class="ttdeci">bool exists(const std::string &amp;str, const std::unordered_set&lt; std::string &gt; &amp;strSet)</div><div class="ttdoc">Function that checks if the string passed in param is present in the the unordered_set passed.</div><div class="ttdef"><b>Definition</b> <a href="../../d3/d84/word__break_8cpp_source.html#l00060">word_break.cpp:60</a></div></div>
</div><!-- fragment -->
</div>
</div>
@@ -288,7 +287,7 @@ pen apple". Note that you are allowed to reuse a dictionary word.</p>
</table>
</div><div class="memdoc">
<p>Function that checks if the string passed in param is present in the the unordered_set passed. </p>
<p>Function that checks if the string passed in param is present in the the <a class="el" href="../../d3/d6d/classunordered__set.html" title="STL class.">unordered_set</a> passed. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">str</td><td>the string to be searched </td></tr>
@@ -362,7 +361,7 @@ pen apple". Note that you are allowed to reuse a dictionary word.</p>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
<span class="mlabels"><span class="mlabel static">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
@@ -377,7 +376,7 @@ pen apple". Note that you are allowed to reuse a dictionary word.</p>
<div class="line"><span class="lineno"> 159</span> <span class="comment">// the dictionary to be used</span></div>
<div class="line"><span class="lineno"> 160</span> <span class="keyword">const</span> std::vector&lt;std::string&gt; wordDict = {<span class="stringliteral">&quot;apple&quot;</span>, <span class="stringliteral">&quot;pen&quot;</span>};</div>
<div class="line"><span class="lineno"> 161</span> </div>
<div class="line"><span class="lineno"> 162</span> assert(dynamic_programming::word_break::wordBreak(s, wordDict));</div>
<div class="line"><span class="lineno"> 162</span> assert(<a class="code hl_function" href="#afe4dcd6fd5282e535685361cba645d7c">dynamic_programming::word_break::wordBreak</a>(s, wordDict));</div>
<div class="line"><span class="lineno"> 163</span> </div>
<div class="line"><span class="lineno"> 164</span> <span class="comment">// should return true, as applepenapple can be segmented as apple + pen +</span></div>
<div class="line"><span class="lineno"> 165</span> <span class="comment">// apple</span></div>
@@ -446,7 +445,7 @@ pen apple". Note that you are allowed to reuse a dictionary word.</p>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_8a20dd5bfd5341a725342bf72b6b686f.html">dynamic_programming</a></li><li class="navelem"><a class="el" href="../../d3/d84/word__break_8cpp.html">word_break.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>