mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-25 14:23:03 +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++: sorting/strand_sort.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');
|
||||
@@ -154,10 +154,10 @@ Functions</h2></td></tr>
|
||||
|
||||
<p>Main function. </p>
|
||||
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
|
||||
<div class="fragment"><div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> {</div>
|
||||
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> <a class="code hl_function" href="../../dc/dd9/strand__sort_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>();</div>
|
||||
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span>}</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 84</span> {</div>
|
||||
<div class="line"><span class="lineno"> 85</span> <a class="code hl_function" href="../../dc/dd9/strand__sort_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>();</div>
|
||||
<div class="line"><span class="lineno"> 86</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><span class="lineno"> 87</span>}</div>
|
||||
<div class="ttc" id="astrand__sort_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../dc/dd9/strand__sort_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Function for testing.</div><div class="ttdef"><b>Definition:</b> strand_sort.cpp:64</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
@@ -200,27 +200,27 @@ template<typename T > </div>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>Sorted list<T> instance </dd></dl>
|
||||
<div class="fragment"><div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> {</div>
|
||||
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> <span class="keywordflow">if</span> (lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/size.html">size</a>() < 2) { <span class="comment">// Returns list if empty or contains only one element</span></div>
|
||||
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> <span class="keywordflow">return</span> lst; <span class="comment">// Returns list</span></div>
|
||||
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> }</div>
|
||||
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list.html">std::list<T></a> <a class="code hl_function" href="../../de/dc3/fibonacci__sum_8cpp.html#aadb40ac4c74a7efc0680b83eeee138aa">result</a>; <span class="comment">// Define new "result" named list instance.</span></div>
|
||||
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list.html">std::list<T></a> sorted; <span class="comment">// Define new "sorted" named list instance.</span></div>
|
||||
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> <span class="keywordflow">while</span>(!lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/empty.html">empty</a>()) <span class="comment">/* if lst is not empty */</span> {</div>
|
||||
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> sorted.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/push_back.html">push_back</a>(lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/front.html">front</a>()); <span class="comment">// Adds the first element of "lst" list to the bottom of the "sorted" list.</span></div>
|
||||
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/pop_front.html">pop_front</a>(); <span class="comment">// Remove first element of "lst" list.</span></div>
|
||||
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> <span class="keywordflow">for</span> (<span class="keyword">auto</span> it = lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/begin.html">begin</a>(); it != lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/end.html">end</a>(); ) { <span class="comment">// Return the loop as long as the current iterator is not equal to the last literator of the "lst" list.</span></div>
|
||||
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> <span class="keywordflow">if</span> (sorted.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/back.html">back</a>() <= *it) { <span class="comment">// If the last reference of the "sorted" list is less than or equal to the current iterator reference.</span></div>
|
||||
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> sorted.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/push_back.html">push_back</a>(*it); <span class="comment">// Adds the iterator retrieved in the loop under the "sorted" list.</span></div>
|
||||
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> it = lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/erase.html">erase</a>(it); <span class="comment">// Deletes the element with the current iterator and assigns the deleted element to the iterator.</span></div>
|
||||
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> } <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> it++; <span class="comment">// Next iterator.</span></div>
|
||||
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> }</div>
|
||||
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> }</div>
|
||||
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> <a class="code hl_function" href="../../de/dc3/fibonacci__sum_8cpp.html#aadb40ac4c74a7efc0680b83eeee138aa">result</a>.merge(sorted); <span class="comment">// Merge "result" list with "sorted" list.</span></div>
|
||||
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> }</div>
|
||||
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <span class="keywordflow">return</span> <a class="code hl_function" href="../../de/dc3/fibonacci__sum_8cpp.html#aadb40ac4c74a7efc0680b83eeee138aa">result</a>; <span class="comment">// Returns sorted list</span></div>
|
||||
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> }</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 36</span> {</div>
|
||||
<div class="line"><span class="lineno"> 37</span> <span class="keywordflow">if</span> (lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/size.html">size</a>() < 2) { <span class="comment">// Returns list if empty or contains only one element</span></div>
|
||||
<div class="line"><span class="lineno"> 38</span> <span class="keywordflow">return</span> lst; <span class="comment">// Returns list</span></div>
|
||||
<div class="line"><span class="lineno"> 39</span> }</div>
|
||||
<div class="line"><span class="lineno"> 40</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list.html">std::list<T></a> <a class="code hl_function" href="../../de/dc3/fibonacci__sum_8cpp.html#aadb40ac4c74a7efc0680b83eeee138aa">result</a>; <span class="comment">// Define new "result" named list instance.</span></div>
|
||||
<div class="line"><span class="lineno"> 41</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list.html">std::list<T></a> sorted; <span class="comment">// Define new "sorted" named list instance.</span></div>
|
||||
<div class="line"><span class="lineno"> 42</span> <span class="keywordflow">while</span>(!lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/empty.html">empty</a>()) <span class="comment">/* if lst is not empty */</span> {</div>
|
||||
<div class="line"><span class="lineno"> 43</span> sorted.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/push_back.html">push_back</a>(lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/front.html">front</a>()); <span class="comment">// Adds the first element of "lst" list to the bottom of the "sorted" list.</span></div>
|
||||
<div class="line"><span class="lineno"> 44</span> lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/pop_front.html">pop_front</a>(); <span class="comment">// Remove first element of "lst" list.</span></div>
|
||||
<div class="line"><span class="lineno"> 45</span> <span class="keywordflow">for</span> (<span class="keyword">auto</span> it = lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/begin.html">begin</a>(); it != lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/end.html">end</a>(); ) { <span class="comment">// Return the loop as long as the current iterator is not equal to the last literator of the "lst" list.</span></div>
|
||||
<div class="line"><span class="lineno"> 46</span> <span class="keywordflow">if</span> (sorted.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/back.html">back</a>() <= *it) { <span class="comment">// If the last reference of the "sorted" list is less than or equal to the current iterator reference.</span></div>
|
||||
<div class="line"><span class="lineno"> 47</span> sorted.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/push_back.html">push_back</a>(*it); <span class="comment">// Adds the iterator retrieved in the loop under the "sorted" list.</span></div>
|
||||
<div class="line"><span class="lineno"> 48</span> it = lst.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/erase.html">erase</a>(it); <span class="comment">// Deletes the element with the current iterator and assigns the deleted element to the iterator.</span></div>
|
||||
<div class="line"><span class="lineno"> 49</span> } <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><span class="lineno"> 50</span> it++; <span class="comment">// Next iterator.</span></div>
|
||||
<div class="line"><span class="lineno"> 51</span> }</div>
|
||||
<div class="line"><span class="lineno"> 52</span> }</div>
|
||||
<div class="line"><span class="lineno"> 53</span> <a class="code hl_function" href="../../de/dc3/fibonacci__sum_8cpp.html#aadb40ac4c74a7efc0680b83eeee138aa">result</a>.merge(sorted); <span class="comment">// Merge "result" list with "sorted" list.</span></div>
|
||||
<div class="line"><span class="lineno"> 54</span> }</div>
|
||||
<div class="line"><span class="lineno"> 55</span> <span class="keywordflow">return</span> <a class="code hl_function" href="../../de/dc3/fibonacci__sum_8cpp.html#aadb40ac4c74a7efc0680b83eeee138aa">result</a>; <span class="comment">// Returns sorted list</span></div>
|
||||
<div class="line"><span class="lineno"> 56</span> }</div>
|
||||
<div class="ttc" id="aback_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/list/back.html">std::list::back</a></div><div class="ttdeci">T back(T... args)</div></div>
|
||||
<div class="ttc" id="abegin_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/list/begin.html">std::list::begin</a></div><div class="ttdeci">T begin(T... args)</div></div>
|
||||
<div class="ttc" id="aempty_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/list/empty.html">std::list::empty</a></div><div class="ttdeci">T empty(T... args)</div></div>
|
||||
@@ -266,21 +266,21 @@ Here is the call graph for this function:</div>
|
||||
|
||||
<p>Function for testing. </p>
|
||||
<dl class="section return"><dt>Returns</dt><dd>N/A </dd></dl>
|
||||
<div class="fragment"><div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> {</div>
|
||||
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list.html">std::list<int></a> lst = { -333, 525, 1, 0, 94, 52, 33 };</div>
|
||||
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> </div>
|
||||
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</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">"Before: "</span>;</div>
|
||||
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <span class="keywordflow">for</span>(<span class="keyword">auto</span> item: lst) {</div>
|
||||
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << item << <span class="stringliteral">" "</span>;</div>
|
||||
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> }</div>
|
||||
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> </div>
|
||||
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> lst = <a class="code hl_function" href="../../dc/dd9/strand__sort_8cpp.html#a2bea2fe5dd38ed63610fdeaddf5785cd">sorting::strand::strand_sort</a>(lst); <span class="comment">// Sort list.</span></div>
|
||||
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> </div>
|
||||
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</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">"\nAfter: "</span>;</div>
|
||||
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <span class="keywordflow">for</span>(<span class="keyword">auto</span> item: lst) {</div>
|
||||
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << item << <span class="stringliteral">" "</span>;</div>
|
||||
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> }</div>
|
||||
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span>}</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 64</span> {</div>
|
||||
<div class="line"><span class="lineno"> 65</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list.html">std::list<int></a> lst = { -333, 525, 1, 0, 94, 52, 33 };</div>
|
||||
<div class="line"><span class="lineno"> 66</span> </div>
|
||||
<div class="line"><span class="lineno"> 67</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">"Before: "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 68</span> <span class="keywordflow">for</span>(<span class="keyword">auto</span> item: lst) {</div>
|
||||
<div class="line"><span class="lineno"> 69</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << item << <span class="stringliteral">" "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 70</span> }</div>
|
||||
<div class="line"><span class="lineno"> 71</span> </div>
|
||||
<div class="line"><span class="lineno"> 72</span> lst = <a class="code hl_function" href="../../dc/dd9/strand__sort_8cpp.html#a2bea2fe5dd38ed63610fdeaddf5785cd">sorting::strand::strand_sort</a>(lst); <span class="comment">// Sort list.</span></div>
|
||||
<div class="line"><span class="lineno"> 73</span> </div>
|
||||
<div class="line"><span class="lineno"> 74</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">"\nAfter: "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 75</span> <span class="keywordflow">for</span>(<span class="keyword">auto</span> item: lst) {</div>
|
||||
<div class="line"><span class="lineno"> 76</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << item << <span class="stringliteral">" "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 77</span> }</div>
|
||||
<div class="line"><span class="lineno"> 78</span>}</div>
|
||||
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
|
||||
<div class="ttc" id="astrand__sort_8cpp_html_a2bea2fe5dd38ed63610fdeaddf5785cd"><div class="ttname"><a href="../../dc/dd9/strand__sort_8cpp.html#a2bea2fe5dd38ed63610fdeaddf5785cd">sorting::strand::strand_sort</a></div><div class="ttdeci">std::list< T > strand_sort(std::list< T > lst)</div><div class="ttdoc">Apply sorting.</div><div class="ttdef"><b>Definition:</b> strand_sort.cpp:36</div></div>
|
||||
</div><!-- fragment -->
|
||||
@@ -292,7 +292,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_bb1b521853a9c46347182a9d10420771.html">sorting</a></li><li class="navelem"><a class="el" href="../../dc/dd9/strand__sort_8cpp.html">strand_sort.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