mirror of
https://github.com/TheAlgorithms/C
synced 2024-12-04 19:21:54 +03:00
382 lines
28 KiB
HTML
382 lines
28 KiB
HTML
<!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>
|
|
<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.5"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>Algorithms_in_C: misc/cantor_set.c File Reference</title>
|
|
<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>
|
|
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="../../resize.js"></script>
|
|
<script type="text/javascript" src="../../navtreedata.js"></script>
|
|
<script type="text/javascript" src="../../navtree.js"></script>
|
|
<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>
|
|
<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>
|
|
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<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>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.9.5 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="../../menudata.js"></script>
|
|
<script type="text/javascript" src="../../menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(function() {
|
|
initMenu('../../',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(document).ready(function(){initNavTree('dc/d80/cantor__set_8c.html','../../'); initResizable(); });
|
|
/* @license-end */
|
|
</script>
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<div id="MSearchResults">
|
|
<div class="SRPage">
|
|
<div id="SRIndex">
|
|
<div id="SRResults"></div>
|
|
<div class="SRStatus" id="Loading">Loading...</div>
|
|
<div class="SRStatus" id="Searching">Searching...</div>
|
|
<div class="SRStatus" id="NoMatches">No Matches</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#nested-classes">Data Structures</a> |
|
|
<a href="#typedef-members">Typedefs</a> |
|
|
<a href="#func-members">Functions</a> </div>
|
|
<div class="headertitle"><div class="title">cantor_set.c File Reference</div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>Program to generate <a href="https://en.wikipedia.org/wiki/Cantor_set" target="_blank">Cantor ternary set</a>
|
|
<a href="#details">More...</a></p>
|
|
<div class="textblock"><code>#include <stdio.h></code><br />
|
|
<code>#include <stdlib.h></code><br />
|
|
<code>#include <string.h></code><br />
|
|
</div><div class="textblock"><div class="dynheader">
|
|
Include dependency graph for cantor_set.c:</div>
|
|
<div class="dyncontent">
|
|
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/ddc/cantor__set_8c__incl.svg" width="251" height="110"><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">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
|
|
Data Structures</h2></td></tr>
|
|
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d9/dd7/struct__cantor__set.html">_cantor_set</a></td></tr>
|
|
<tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">structure to define Cantor set <a href="../../d9/dd7/struct__cantor__set.html#details">More...</a><br /></td></tr>
|
|
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
|
|
Typedefs</h2></td></tr>
|
|
<tr class="memitem:a2b95c356aff8a282eaad255008fa5a94"><td class="memItemLeft" align="right" valign="top"><a id="a2b95c356aff8a282eaad255008fa5a94" name="a2b95c356aff8a282eaad255008fa5a94"></a>
|
|
typedef struct <a class="el" href="../../d9/dd7/struct__cantor__set.html">_cantor_set</a> </td><td class="memItemRight" valign="bottom"><b>CantorSet</b></td></tr>
|
|
<tr class="memdesc:a2b95c356aff8a282eaad255008fa5a94"><td class="mdescLeft"> </td><td class="mdescRight">structure to define Cantor set <br /></td></tr>
|
|
<tr class="separator:a2b95c356aff8a282eaad255008fa5a94"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
|
Functions</h2></td></tr>
|
|
<tr class="memitem:a1f156d2b53b80305bd2fa3ff5fdf3c97"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../dc/d80/cantor__set_8c.html#a1f156d2b53b80305bd2fa3ff5fdf3c97">propagate</a> (<a class="el" href="../../dc/d80/cantor__set_8c.html#a2b95c356aff8a282eaad255008fa5a94">CantorSet</a> *head)</td></tr>
|
|
<tr class="memdesc:a1f156d2b53b80305bd2fa3ff5fdf3c97"><td class="mdescLeft"> </td><td class="mdescRight">Iterative constructor of all sets in the current level. <a href="../../dc/d80/cantor__set_8c.html#a1f156d2b53b80305bd2fa3ff5fdf3c97">More...</a><br /></td></tr>
|
|
<tr class="separator:a1f156d2b53b80305bd2fa3ff5fdf3c97"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a75ee530cd7148a63249784ad3dda8fab"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../dc/d80/cantor__set_8c.html#a75ee530cd7148a63249784ad3dda8fab">print</a> (<a class="el" href="../../dc/d80/cantor__set_8c.html#a2b95c356aff8a282eaad255008fa5a94">CantorSet</a> *head)</td></tr>
|
|
<tr class="memdesc:a75ee530cd7148a63249784ad3dda8fab"><td class="mdescLeft"> </td><td class="mdescRight">Print sets in the current range to <code>stdout</code> <a href="../../dc/d80/cantor__set_8c.html#a75ee530cd7148a63249784ad3dda8fab">More...</a><br /></td></tr>
|
|
<tr class="separator:a75ee530cd7148a63249784ad3dda8fab"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a85df3c64a683100ac6246e1e034df43d"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../dc/d80/cantor__set_8c.html#a85df3c64a683100ac6246e1e034df43d">free_memory</a> (<a class="el" href="../../dc/d80/cantor__set_8c.html#a2b95c356aff8a282eaad255008fa5a94">CantorSet</a> *head)</td></tr>
|
|
<tr class="memdesc:a85df3c64a683100ac6246e1e034df43d"><td class="mdescLeft"> </td><td class="mdescRight">Clear memory allocated by <a class="el" href="../../dc/d80/cantor__set_8c.html#a1f156d2b53b80305bd2fa3ff5fdf3c97" title="Iterative constructor of all sets in the current level.">propagate</a> function. <a href="../../dc/d80/cantor__set_8c.html#a85df3c64a683100ac6246e1e034df43d">More...</a><br /></td></tr>
|
|
<tr class="separator:a85df3c64a683100ac6246e1e034df43d"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:abf9e6b7e6f15df4b525a2e7705ba3089"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../dc/d80/cantor__set_8c.html#abf9e6b7e6f15df4b525a2e7705ba3089">main</a> (int argc, char const *argv[])</td></tr>
|
|
<tr class="memdesc:abf9e6b7e6f15df4b525a2e7705ba3089"><td class="mdescLeft"> </td><td class="mdescRight">Main function. <a href="../../dc/d80/cantor__set_8c.html#abf9e6b7e6f15df4b525a2e7705ba3089">More...</a><br /></td></tr>
|
|
<tr class="separator:abf9e6b7e6f15df4b525a2e7705ba3089"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><p >Program to generate <a href="https://en.wikipedia.org/wiki/Cantor_set" target="_blank">Cantor ternary set</a> </p>
|
|
</div><h2 class="groupheader">Function Documentation</h2>
|
|
<a id="a85df3c64a683100ac6246e1e034df43d" name="a85df3c64a683100ac6246e1e034df43d"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a85df3c64a683100ac6246e1e034df43d">◆ </a></span>free_memory()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void free_memory </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../dc/d80/cantor__set_8c.html#a2b95c356aff8a282eaad255008fa5a94">CantorSet</a> * </td>
|
|
<td class="paramname"><em>head</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Clear memory allocated by <a class="el" href="../../dc/d80/cantor__set_8c.html#a1f156d2b53b80305bd2fa3ff5fdf3c97" title="Iterative constructor of all sets in the current level.">propagate</a> function. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">head</td><td>pointer to first allocated instance. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 73</span>{</div>
|
|
<div class="line"><span class="lineno"> 74</span> <span class="keywordflow">if</span> (!head)</div>
|
|
<div class="line"><span class="lineno"> 75</span> <span class="keywordflow">return</span>;</div>
|
|
<div class="line"><span class="lineno"> 76</span> </div>
|
|
<div class="line"><span class="lineno"> 77</span> <span class="keywordflow">if</span> (head-><a class="code hl_variable" href="../../d5/da1/structnode.html#a111a569ab2765add9b91c9f94cf9f063">next</a>)</div>
|
|
<div class="line"><span class="lineno"> 78</span> <a class="code hl_function" href="../../dc/d80/cantor__set_8c.html#a85df3c64a683100ac6246e1e034df43d">free_memory</a>(head-><a class="code hl_variable" href="../../d5/da1/structnode.html#a111a569ab2765add9b91c9f94cf9f063">next</a>);</div>
|
|
<div class="line"><span class="lineno"> 79</span> </div>
|
|
<div class="line"><span class="lineno"> 80</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(head);</div>
|
|
<div class="line"><span class="lineno"> 81</span>}</div>
|
|
<div class="ttc" id="acantor__set_8c_html_a85df3c64a683100ac6246e1e034df43d"><div class="ttname"><a href="../../dc/d80/cantor__set_8c.html#a85df3c64a683100ac6246e1e034df43d">free_memory</a></div><div class="ttdeci">void free_memory(CantorSet *head)</div><div class="ttdoc">Clear memory allocated by propagate function.</div><div class="ttdef"><b>Definition:</b> cantor_set.c:72</div></div>
|
|
<div class="ttc" id="amalloc__dbg_8h_html_a9cc854374299a1dd933bf62029761768"><div class="ttname"><a href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a></div><div class="ttdeci">#define free(ptr)</div><div class="ttdoc">This macro replace the standard free function with free_dbg.</div><div class="ttdef"><b>Definition:</b> malloc_dbg.h:26</div></div>
|
|
<div class="ttc" id="astructnode_html_a111a569ab2765add9b91c9f94cf9f063"><div class="ttname"><a href="../../d5/da1/structnode.html#a111a569ab2765add9b91c9f94cf9f063">node::next</a></div><div class="ttdeci">struct node * next</div><div class="ttdoc">pointer to the node</div><div class="ttdef"><b>Definition:</b> bfs.c:24</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="../../dc/d80/cantor__set_8c_a85df3c64a683100ac6246e1e034df43d_cgraph.svg" width="110" height="60"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="abf9e6b7e6f15df4b525a2e7705ba3089" name="abf9e6b7e6f15df4b525a2e7705ba3089"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#abf9e6b7e6f15df4b525a2e7705ba3089">◆ </a></span>main()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">int main </td>
|
|
<td>(</td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>argc</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">char const * </td>
|
|
<td class="paramname"><em>argv</em>[] </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Main function. </p>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 85</span>{</div>
|
|
<div class="line"><span class="lineno"> 86</span> <span class="keywordtype">int</span> start_num, end_num, levels;</div>
|
|
<div class="line"><span class="lineno"> 87</span> </div>
|
|
<div class="line"><span class="lineno"> 88</span> <span class="keywordflow">if</span> (argc < 2)</div>
|
|
<div class="line"><span class="lineno"> 89</span> {</div>
|
|
<div class="line"><span class="lineno"> 90</span> printf(<span class="stringliteral">"Enter 3 arguments: start_num \t end_num \t levels\n"</span>);</div>
|
|
<div class="line"><span class="lineno"> 91</span> scanf(<span class="stringliteral">"%d %d %d"</span>, &start_num, &end_num, &levels);</div>
|
|
<div class="line"><span class="lineno"> 92</span> }</div>
|
|
<div class="line"><span class="lineno"> 93</span> <span class="keywordflow">else</span></div>
|
|
<div class="line"><span class="lineno"> 94</span> {</div>
|
|
<div class="line"><span class="lineno"> 95</span> start_num = atoi(argv[1]);</div>
|
|
<div class="line"><span class="lineno"> 96</span> end_num = atoi(argv[2]);</div>
|
|
<div class="line"><span class="lineno"> 97</span> levels = atoi(argv[3]);</div>
|
|
<div class="line"><span class="lineno"> 98</span> }</div>
|
|
<div class="line"><span class="lineno"> 99</span> </div>
|
|
<div class="line"><span class="lineno"> 100</span> <span class="keywordflow">if</span> (start_num < 0 || end_num < 0 || levels < 0)</div>
|
|
<div class="line"><span class="lineno"> 101</span> {</div>
|
|
<div class="line"><span class="lineno"> 102</span> fprintf(stderr, <span class="stringliteral">"All numbers must be positive\n"</span>);</div>
|
|
<div class="line"><span class="lineno"> 103</span> <span class="keywordflow">return</span> -1;</div>
|
|
<div class="line"><span class="lineno"> 104</span> }</div>
|
|
<div class="line"><span class="lineno"> 105</span> </div>
|
|
<div class="line"><span class="lineno"> 106</span> <a class="code hl_struct" href="../../d9/dd7/struct__cantor__set.html">CantorSet</a> head = {.start = start_num, .end = end_num, .<a class="code hl_variable" href="../../d5/da1/structnode.html#a111a569ab2765add9b91c9f94cf9f063">next</a> = NULL};</div>
|
|
<div class="line"><span class="lineno"> 107</span> </div>
|
|
<div class="line"><span class="lineno"> 108</span> <span class="comment">// loop to propagate each level from top to bottom</span></div>
|
|
<div class="line"><span class="lineno"> 109</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < levels; i++)</div>
|
|
<div class="line"><span class="lineno"> 110</span> {</div>
|
|
<div class="line"><span class="lineno"> 111</span> printf(<span class="stringliteral">"Level %d\t"</span>, i);</div>
|
|
<div class="line"><span class="lineno"> 112</span> <a class="code hl_function" href="../../dc/d80/cantor__set_8c.html#a75ee530cd7148a63249784ad3dda8fab">print</a>(&head);</div>
|
|
<div class="line"><span class="lineno"> 113</span> <a class="code hl_function" href="../../dc/d80/cantor__set_8c.html#a1f156d2b53b80305bd2fa3ff5fdf3c97">propagate</a>(&head);</div>
|
|
<div class="line"><span class="lineno"> 114</span> printf(<span class="stringliteral">"\n"</span>);</div>
|
|
<div class="line"><span class="lineno"> 115</span> }</div>
|
|
<div class="line"><span class="lineno"> 116</span> printf(<span class="stringliteral">"Level %d\t"</span>, levels);</div>
|
|
<div class="line"><span class="lineno"> 117</span> <a class="code hl_function" href="../../dc/d80/cantor__set_8c.html#a75ee530cd7148a63249784ad3dda8fab">print</a>(&head);</div>
|
|
<div class="line"><span class="lineno"> 118</span> </div>
|
|
<div class="line"><span class="lineno"> 119</span> <span class="comment">// delete all memory allocated</span></div>
|
|
<div class="line"><span class="lineno"> 120</span> <a class="code hl_function" href="../../dc/d80/cantor__set_8c.html#a85df3c64a683100ac6246e1e034df43d">free_memory</a>(head.<a class="code hl_variable" href="../../d5/da1/structnode.html#a111a569ab2765add9b91c9f94cf9f063">next</a>);</div>
|
|
<div class="line"><span class="lineno"> 121</span> </div>
|
|
<div class="line"><span class="lineno"> 122</span> <span class="keywordflow">return</span> 0;</div>
|
|
<div class="line"><span class="lineno"> 123</span>}</div>
|
|
<div class="ttc" id="acantor__set_8c_html_a1f156d2b53b80305bd2fa3ff5fdf3c97"><div class="ttname"><a href="../../dc/d80/cantor__set_8c.html#a1f156d2b53b80305bd2fa3ff5fdf3c97">propagate</a></div><div class="ttdeci">void propagate(CantorSet *head)</div><div class="ttdoc">Iterative constructor of all sets in the current level.</div><div class="ttdef"><b>Definition:</b> cantor_set.c:23</div></div>
|
|
<div class="ttc" id="acantor__set_8c_html_a75ee530cd7148a63249784ad3dda8fab"><div class="ttname"><a href="../../dc/d80/cantor__set_8c.html#a75ee530cd7148a63249784ad3dda8fab">print</a></div><div class="ttdeci">void print(CantorSet *head)</div><div class="ttdoc">Print sets in the current range to stdout</div><div class="ttdef"><b>Definition:</b> cantor_set.c:55</div></div>
|
|
<div class="ttc" id="astruct__cantor__set_html"><div class="ttname"><a href="../../d9/dd7/struct__cantor__set.html">_cantor_set</a></div><div class="ttdoc">structure to define Cantor set</div><div class="ttdef"><b>Definition:</b> cantor_set.c:12</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="../../dc/d80/cantor__set_8c_abf9e6b7e6f15df4b525a2e7705ba3089_cgraph.svg" width="208" height="183"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a75ee530cd7148a63249784ad3dda8fab" name="a75ee530cd7148a63249784ad3dda8fab"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a75ee530cd7148a63249784ad3dda8fab">◆ </a></span>print()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void print </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../dc/d80/cantor__set_8c.html#a2b95c356aff8a282eaad255008fa5a94">CantorSet</a> * </td>
|
|
<td class="paramname"><em>head</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Print sets in the current range to <code>stdout</code> </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">head</td><td>pointer to first set in the current level </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 56</span>{</div>
|
|
<div class="line"><span class="lineno"> 57</span> <a class="code hl_struct" href="../../d9/dd7/struct__cantor__set.html">CantorSet</a> *temp = head;</div>
|
|
<div class="line"><span class="lineno"> 58</span> <span class="keywordflow">while</span> (temp != NULL) <span class="comment">// print while a valid set is found</span></div>
|
|
<div class="line"><span class="lineno"> 59</span> {</div>
|
|
<div class="line"><span class="lineno"> 60</span> printf(<span class="stringliteral">"\t"</span>);</div>
|
|
<div class="line"><span class="lineno"> 61</span> printf(<span class="stringliteral">"[%lf] -- "</span>, temp->start);</div>
|
|
<div class="line"><span class="lineno"> 62</span> printf(<span class="stringliteral">"[%lf]"</span>, temp->end);</div>
|
|
<div class="line"><span class="lineno"> 63</span> temp = temp-><a class="code hl_variable" href="../../d5/da1/structnode.html#a111a569ab2765add9b91c9f94cf9f063">next</a>;</div>
|
|
<div class="line"><span class="lineno"> 64</span> }</div>
|
|
<div class="line"><span class="lineno"> 65</span> </div>
|
|
<div class="line"><span class="lineno"> 66</span> printf(<span class="stringliteral">"\n"</span>);</div>
|
|
<div class="line"><span class="lineno"> 67</span>}</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a1f156d2b53b80305bd2fa3ff5fdf3c97" name="a1f156d2b53b80305bd2fa3ff5fdf3c97"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a1f156d2b53b80305bd2fa3ff5fdf3c97">◆ </a></span>propagate()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void propagate </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../dc/d80/cantor__set_8c.html#a2b95c356aff8a282eaad255008fa5a94">CantorSet</a> * </td>
|
|
<td class="paramname"><em>head</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Iterative constructor of all sets in the current level. </p>
|
|
<p >This function dynamically allocates memory when creating new sets. These are freed by the function <a class="el" href="../../dc/d80/cantor__set_8c.html#a85df3c64a683100ac6246e1e034df43d" title="Clear memory allocated by propagate function.">free_memory</a>. </p><dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">head</td><td>pointer to interval set instance to update </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 24</span>{</div>
|
|
<div class="line"><span class="lineno"> 25</span> <span class="comment">// if input is NULL, ignore the process</span></div>
|
|
<div class="line"><span class="lineno"> 26</span> <span class="keywordflow">if</span> (head == NULL)</div>
|
|
<div class="line"><span class="lineno"> 27</span> <span class="keywordflow">return</span>;</div>
|
|
<div class="line"><span class="lineno"> 28</span> </div>
|
|
<div class="line"><span class="lineno"> 29</span> <a class="code hl_struct" href="../../d9/dd7/struct__cantor__set.html">CantorSet</a> *temp = head; <span class="comment">// local pointer to track propagation</span></div>
|
|
<div class="line"><span class="lineno"> 30</span> </div>
|
|
<div class="line"><span class="lineno"> 31</span> <span class="comment">// create new node for the new set</span></div>
|
|
<div class="line"><span class="lineno"> 32</span> <a class="code hl_struct" href="../../d9/dd7/struct__cantor__set.html">CantorSet</a> *newNode = (<a class="code hl_struct" href="../../d9/dd7/struct__cantor__set.html">CantorSet</a> *)<a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<a class="code hl_struct" href="../../d9/dd7/struct__cantor__set.html">CantorSet</a>));</div>
|
|
<div class="line"><span class="lineno"> 33</span> </div>
|
|
<div class="line"><span class="lineno"> 34</span> <span class="comment">// get 1/3rd of interval</span></div>
|
|
<div class="line"><span class="lineno"> 35</span> <span class="keywordtype">double</span> diff = (((temp->end) - (temp->start)) / 3);</div>
|
|
<div class="line"><span class="lineno"> 36</span> </div>
|
|
<div class="line"><span class="lineno"> 37</span> <span class="comment">// update interval ranges</span></div>
|
|
<div class="line"><span class="lineno"> 38</span> newNode->end = temp->end;</div>
|
|
<div class="line"><span class="lineno"> 39</span> temp->end = ((temp->start) + diff);</div>
|
|
<div class="line"><span class="lineno"> 40</span> newNode->start = (newNode->end) - diff;</div>
|
|
<div class="line"><span class="lineno"> 41</span> </div>
|
|
<div class="line"><span class="lineno"> 42</span> <span class="comment">// update pointer to next set in this level</span></div>
|
|
<div class="line"><span class="lineno"> 43</span> newNode->next = temp-><a class="code hl_variable" href="../../d5/da1/structnode.html#a111a569ab2765add9b91c9f94cf9f063">next</a>;</div>
|
|
<div class="line"><span class="lineno"> 44</span> </div>
|
|
<div class="line"><span class="lineno"> 45</span> <span class="comment">// point to next set</span></div>
|
|
<div class="line"><span class="lineno"> 46</span> temp-><a class="code hl_variable" href="../../d5/da1/structnode.html#a111a569ab2765add9b91c9f94cf9f063">next</a> = newNode;</div>
|
|
<div class="line"><span class="lineno"> 47</span> </div>
|
|
<div class="line"><span class="lineno"> 48</span> <span class="comment">// create next set</span></div>
|
|
<div class="line"><span class="lineno"> 49</span> <a class="code hl_function" href="../../dc/d80/cantor__set_8c.html#a1f156d2b53b80305bd2fa3ff5fdf3c97">propagate</a>(temp-><a class="code hl_variable" href="../../d5/da1/structnode.html#a111a569ab2765add9b91c9f94cf9f063">next</a>-><a class="code hl_variable" href="../../d5/da1/structnode.html#a111a569ab2765add9b91c9f94cf9f063">next</a>);</div>
|
|
<div class="line"><span class="lineno"> 50</span>}</div>
|
|
<div class="ttc" id="amalloc__dbg_8h_html_a725f50ecaf1959d96de79b36b4788fee"><div class="ttname"><a href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a></div><div class="ttdeci">#define malloc(bytes)</div><div class="ttdoc">This macro replace the standard malloc function with malloc_dbg.</div><div class="ttdef"><b>Definition:</b> malloc_dbg.h:18</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="../../dc/d80/cantor__set_8c_a1f156d2b53b80305bd2fa3ff5fdf3c97_cgraph.svg" width="90" height="60"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="../../dir_a52f4d3d586a58b02f3a4ddf0a992157.html">misc</a></li><li class="navelem"><a class="el" href="../../dc/d80/cantor__set_8c.html">cantor_set.c</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.5 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|