mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-24 22:02:20 +08:00
Documentation for 8b1eab204b
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<!-- HTML header for doxygen 1.12.0-->
|
||||
<!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" lang="en-US">
|
||||
<head>
|
||||
@@ -5,10 +6,15 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.12.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: sorting/cycle_sort.cpp File Reference</title>
|
||||
<title>TheAlgorithms/C++: sorting/cycle_sort.cpp File Reference</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
<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>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
@@ -18,14 +24,24 @@
|
||||
<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 type="text/javascript">
|
||||
window.MathJax = {
|
||||
options: {
|
||||
ignoreHtmlClass: 'tex2jax_ignore',
|
||||
processHtmlClass: 'tex2jax_process'
|
||||
},
|
||||
loader: {
|
||||
load: ['[tex]/ams']
|
||||
},
|
||||
tex: {
|
||||
macros: {},
|
||||
packages: ['base','configmacros','ams']
|
||||
}
|
||||
};
|
||||
</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>
|
||||
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
|
||||
<td id="projectalign">
|
||||
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
||||
<div id="projectname">TheAlgorithms/C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
||||
<div id="projectbrief">All the algorithms implemented in C++</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -123,7 +140,9 @@ Include dependency graph for cycle_sort.cpp:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d9/deb/cycle__sort_8cpp__incl.svg" width="434" height="111"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
</div><table class="memberdecls">
|
||||
</div>
|
||||
<p><a href="../../de/d07/cycle__sort_8cpp_source.html">Go to the source code of this file.</a></p>
|
||||
<table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
|
||||
Namespaces</h2></td></tr>
|
||||
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d5/d91/namespacesorting.html">sorting</a></td></tr>
|
||||
@@ -136,7 +155,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:ae79a9d247691fce0d655fce75f1c04fa" id="r_ae79a9d247691fce0d655fce75f1c04fa"><td class="memTemplParams" colspan="2">template<typename T > </td></tr>
|
||||
<tr class="memitem:ae79a9d247691fce0d655fce75f1c04fa"><td class="memTemplItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< T > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< T > &in_arr)</td></tr>
|
||||
<tr class="memitem:ae79a9d247691fce0d655fce75f1c04fa"><td class="memTemplItemLeft" align="right" valign="top">std::vector< T > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a> (const std::vector< T > &in_arr)</td></tr>
|
||||
<tr class="memdesc:ae79a9d247691fce0d655fce75f1c04fa"><td class="mdescLeft"> </td><td class="mdescRight">The main function implements cycleSort. <br /></td></tr>
|
||||
<tr class="separator:ae79a9d247691fce0d655fce75f1c04fa"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:aa8dca7b867074164d5f45b0f3851269d" id="r_aa8dca7b867074164d5f45b0f3851269d"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="#aa8dca7b867074164d5f45b0f3851269d">test</a> ()</td></tr>
|
||||
@@ -149,6 +168,8 @@ Functions</h2></td></tr>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p>Implementation of <a href="https://en.wikipedia.org/wiki/Cycle_sort" target="_blank">Cycle sort</a> algorithm. </p>
|
||||
<p>Cycle Sort is a sorting algorithm that works in \(O(n^2)\) time in the best case and works in \(O(n^2)\) in worst case. If a element is already at its correct position, do nothing. If a element is not at its correct position, we then need to move it to its correct position by computing the correct positions.Therefore, we should make sure the duplicate elements. </p><dl class="section author"><dt>Author</dt><dd><a href="https://github.com/dalaoqi" target="_blank">TsungHan Ho</a> </dd></dl>
|
||||
|
||||
<p class="definition">Definition in file <a class="el" href="../../de/d07/cycle__sort_8cpp_source.html">cycle_sort.cpp</a>.</p>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
<a id="ae79a9d247691fce0d655fce75f1c04fa" name="ae79a9d247691fce0d655fce75f1c04fa"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ae79a9d247691fce0d655fce75f1c04fa">◆ </a></span>cycleSort()</h2>
|
||||
@@ -159,9 +180,9 @@ Functions</h2></td></tr>
|
||||
template<typename T > </div>
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< T > sorting::cycle_sort::cycleSort </td>
|
||||
<td class="memname">std::vector< T > sorting::cycle_sort::cycleSort </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>< T > &</td> <td class="paramname"><span class="paramname"><em>in_arr</em></span></td><td>)</td>
|
||||
<td class="paramtype">const std::vector< T > &</td> <td class="paramname"><span class="paramname"><em>in_arr</em></span></td><td>)</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -181,8 +202,10 @@ template<typename T > </div>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../de/d07/cycle__sort_8cpp_source.html#l00038">38</a> of file <a class="el" href="../../de/d07/cycle__sort_8cpp_source.html">cycle_sort.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 38</span> {</div>
|
||||
<div class="line"><span class="lineno"> 39</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<T></a> arr(in_arr);</div>
|
||||
<div class="line"><span class="lineno"> 39</span> std::vector<T> arr(in_arr);</div>
|
||||
<div class="line"><span class="lineno"> 40</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> cycle_start = 0; cycle_start <= arr.size() - 1; cycle_start++) {</div>
|
||||
<div class="line"><span class="lineno"> 41</span> <span class="comment">// initialize item</span></div>
|
||||
<div class="line"><span class="lineno"> 42</span> T item = arr[cycle_start];</div>
|
||||
@@ -206,7 +229,7 @@ template<typename T > </div>
|
||||
<div class="line"><span class="lineno"> 60</span> <span class="keywordflow">if</span> (pos == cycle_start) {</div>
|
||||
<div class="line"><span class="lineno"> 61</span> <span class="keywordflow">continue</span>;</div>
|
||||
<div class="line"><span class="lineno"> 62</span> } <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><span class="lineno"> 63</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a>(item, arr[pos]);</div>
|
||||
<div class="line"><span class="lineno"> 63</span> std::swap(item, arr[pos]);</div>
|
||||
<div class="line"><span class="lineno"> 64</span> }</div>
|
||||
<div class="line"><span class="lineno"> 65</span> <span class="comment">// Rest of the elements</span></div>
|
||||
<div class="line"><span class="lineno"> 66</span> <span class="keywordflow">while</span> (pos != cycle_start) {</div>
|
||||
@@ -222,20 +245,13 @@ template<typename T > </div>
|
||||
<div class="line"><span class="lineno"> 76</span> <span class="keywordflow">if</span> (item == arr[pos]) {</div>
|
||||
<div class="line"><span class="lineno"> 77</span> <span class="keywordflow">continue</span>;</div>
|
||||
<div class="line"><span class="lineno"> 78</span> } <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><span class="lineno"> 79</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a>(item, arr[pos]);</div>
|
||||
<div class="line"><span class="lineno"> 79</span> std::swap(item, arr[pos]);</div>
|
||||
<div class="line"><span class="lineno"> 80</span> }</div>
|
||||
<div class="line"><span class="lineno"> 81</span> }</div>
|
||||
<div class="line"><span class="lineno"> 82</span> }</div>
|
||||
<div class="line"><span class="lineno"> 83</span> <span class="keywordflow">return</span> arr;</div>
|
||||
<div class="line"><span class="lineno"> 84</span>}</div>
|
||||
<div class="ttc" id="aswap_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a></div><div class="ttdeci">T swap(T... args)</div></div>
|
||||
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></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="../../de/d07/cycle__sort_8cpp_ae79a9d247691fce0d655fce75f1c04fa_cgraph.svg" width="303" height="92"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
|
||||
@@ -255,17 +271,14 @@ Here is the call graph for this function:</div>
|
||||
|
||||
<p>Main function. </p>
|
||||
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../de/d07/cycle__sort_8cpp_source.html#l00128">128</a> of file <a class="el" href="../../de/d07/cycle__sort_8cpp_source.html">cycle_sort.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 128</span> {</div>
|
||||
<div class="line"><span class="lineno"> 129</span> <a class="code hl_function" href="#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// execute the test</span></div>
|
||||
<div class="line"><span class="lineno"> 130</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><span class="lineno"> 131</span>}</div>
|
||||
<div class="ttc" id="acycle__sort_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Test implementations.</div><div class="ttdef"><b>Definition</b> cycle_sort.cpp:92</div></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="../../de/d07/cycle__sort_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="300" height="184"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="acycle__sort_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Test implementations.</div><div class="ttdef"><b>Definition</b> <a href="../../de/d07/cycle__sort_8cpp_source.html#l00092">cycle_sort.cpp:92</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="aa8dca7b867074164d5f45b0f3851269d" name="aa8dca7b867074164d5f45b0f3851269d"></a>
|
||||
@@ -293,49 +306,41 @@ Here is the call graph for this function:</div>
|
||||
|
||||
<p>Test implementations. </p>
|
||||
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../de/d07/cycle__sort_8cpp_source.html#l00092">92</a> of file <a class="el" href="../../de/d07/cycle__sort_8cpp_source.html">cycle_sort.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 92</span> {</div>
|
||||
<div class="line"><span class="lineno"> 93</span> <span class="comment">// Test 1</span></div>
|
||||
<div class="line"><span class="lineno"> 94</span> <span class="comment">// [4, 3, 2, 1] return [1, 2, 3, 4]</span></div>
|
||||
<div class="line"><span class="lineno"> 95</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<uint32_t></a> array1 = {4, 3, 2, 1};</div>
|
||||
<div class="line"><span class="lineno"> 96</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">"Test 1... "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 97</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<uint32_t></a> arr1 = <a class="code hl_function" href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a>(array1);</div>
|
||||
<div class="line"><span class="lineno"> 98</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr1), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr1)));</div>
|
||||
<div class="line"><span class="lineno"> 99</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">"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"> 95</span> std::vector<uint32_t> array1 = {4, 3, 2, 1};</div>
|
||||
<div class="line"><span class="lineno"> 96</span> std::cout << <span class="stringliteral">"Test 1... "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 97</span> std::vector<uint32_t> arr1 = <a class="code hl_function" href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a>(array1);</div>
|
||||
<div class="line"><span class="lineno"> 98</span> assert(std::is_sorted(std::begin(arr1), std::end(arr1)));</div>
|
||||
<div class="line"><span class="lineno"> 99</span> std::cout << <span class="stringliteral">"passed"</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 100</span> </div>
|
||||
<div class="line"><span class="lineno"> 101</span> <span class="comment">// [4.3, -6.5, -7.4, 0, 2.7, 1.8] return [-7.4, -6.5, 0, 1.8, 2.7, 4.3]</span></div>
|
||||
<div class="line"><span class="lineno"> 102</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<double></a> array2 = {4.3, -6.5, -7.4, 0, 2.7, 1.8};</div>
|
||||
<div class="line"><span class="lineno"> 103</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">"Test 2... "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 104</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<double></a> arr2 = <a class="code hl_function" href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a>(array2);</div>
|
||||
<div class="line"><span class="lineno"> 105</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr2), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr2)));</div>
|
||||
<div class="line"><span class="lineno"> 106</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">"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"> 102</span> std::vector<double> array2 = {4.3, -6.5, -7.4, 0, 2.7, 1.8};</div>
|
||||
<div class="line"><span class="lineno"> 103</span> std::cout << <span class="stringliteral">"Test 2... "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 104</span> std::vector<double> arr2 = <a class="code hl_function" href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a>(array2);</div>
|
||||
<div class="line"><span class="lineno"> 105</span> assert(std::is_sorted(std::begin(arr2), std::end(arr2)));</div>
|
||||
<div class="line"><span class="lineno"> 106</span> std::cout << <span class="stringliteral">"passed"</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 107</span> </div>
|
||||
<div class="line"><span class="lineno"> 108</span> <span class="comment">// Test 3</span></div>
|
||||
<div class="line"><span class="lineno"> 109</span> <span class="comment">// [3, 3, 3, 3] return [3, 3, 3, 3]</span></div>
|
||||
<div class="line"><span class="lineno"> 110</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<uint32_t></a> array3 = {3, 3, 3, 3};</div>
|
||||
<div class="line"><span class="lineno"> 111</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">"Test 3... "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 112</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<uint32_t></a> arr3 = <a class="code hl_function" href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a>(array3);</div>
|
||||
<div class="line"><span class="lineno"> 113</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr3), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr3)));</div>
|
||||
<div class="line"><span class="lineno"> 114</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">"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"> 110</span> std::vector<uint32_t> array3 = {3, 3, 3, 3};</div>
|
||||
<div class="line"><span class="lineno"> 111</span> std::cout << <span class="stringliteral">"Test 3... "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 112</span> std::vector<uint32_t> arr3 = <a class="code hl_function" href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a>(array3);</div>
|
||||
<div class="line"><span class="lineno"> 113</span> assert(std::is_sorted(std::begin(arr3), std::end(arr3)));</div>
|
||||
<div class="line"><span class="lineno"> 114</span> std::cout << <span class="stringliteral">"passed"</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 115</span> </div>
|
||||
<div class="line"><span class="lineno"> 116</span> <span class="comment">// [9, 4, 6, 8, 14, 3] return [9, 4, 6, 8, 14, 3]</span></div>
|
||||
<div class="line"><span class="lineno"> 117</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<uint32_t></a> array4 = {3, 4, 6, 8, 9, 14};</div>
|
||||
<div class="line"><span class="lineno"> 118</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">"Test 4... "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 119</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<uint32_t></a> arr4 = <a class="code hl_function" href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a>(array4);</div>
|
||||
<div class="line"><span class="lineno"> 120</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr4), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr4)));</div>
|
||||
<div class="line"><span class="lineno"> 121</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">"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"> 117</span> std::vector<uint32_t> array4 = {3, 4, 6, 8, 9, 14};</div>
|
||||
<div class="line"><span class="lineno"> 118</span> std::cout << <span class="stringliteral">"Test 4... "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 119</span> std::vector<uint32_t> arr4 = <a class="code hl_function" href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a>(array4);</div>
|
||||
<div class="line"><span class="lineno"> 120</span> assert(std::is_sorted(std::begin(arr4), std::end(arr4)));</div>
|
||||
<div class="line"><span class="lineno"> 121</span> std::cout << <span class="stringliteral">"passed"</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 122</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="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>
|
||||
<div class="ttc" id="acycle__sort_8cpp_html_ae79a9d247691fce0d655fce75f1c04fa"><div class="ttname"><a href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a></div><div class="ttdeci">std::vector< T > cycleSort(const std::vector< T > &in_arr)</div><div class="ttdoc">The main function implements cycleSort.</div><div class="ttdef"><b>Definition</b> cycle_sort.cpp:38</div></div>
|
||||
<div class="ttc" id="aend_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a></div><div class="ttdeci">T end(T... args)</div></div>
|
||||
<div class="ttc" id="aendl_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a></div><div class="ttdeci">T endl(T... args)</div></div>
|
||||
<div class="ttc" id="ais_sorted_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a></div><div class="ttdeci">T is_sorted(T... args)</div></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="../../de/d07/cycle__sort_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg" width="203" height="184"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="acycle__sort_8cpp_html_ae79a9d247691fce0d655fce75f1c04fa"><div class="ttname"><a href="#ae79a9d247691fce0d655fce75f1c04fa">sorting::cycle_sort::cycleSort</a></div><div class="ttdeci">std::vector< T > cycleSort(const std::vector< T > &in_arr)</div><div class="ttdoc">The main function implements cycleSort.</div><div class="ttdef"><b>Definition</b> <a href="../../de/d07/cycle__sort_8cpp_source.html#l00038">cycle_sort.cpp:38</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- contents -->
|
||||
|
||||
Reference in New Issue
Block a user