mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
600 lines
46 KiB
HTML
600 lines
46 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: data_structures/vector.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('df/dfa/vector_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="#func-members">Functions</a> </div>
|
|
<div class="headertitle"><div class="title">vector.c File Reference</div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>This is a vector implemenation in C.
|
|
<a href="#details">More...</a></p>
|
|
<div class="textblock"><code>#include <stdio.h></code><br />
|
|
<code>#include <stdlib.h></code><br />
|
|
<code>#include <assert.h></code><br />
|
|
</div><div class="textblock"><div class="dynheader">
|
|
Include dependency graph for vector.c:</div>
|
|
<div class="dyncontent">
|
|
<div class="center"><iframe scrolling="no" frameborder="0" src="../../da/ded/vector_8c__incl.svg" width="254" 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="../../d4/d06/struct_vector.html">Vector</a></td></tr>
|
|
<tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">for IO operations <a href="../../d4/d06/struct_vector.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="func-members" name="func-members"></a>
|
|
Functions</h2></td></tr>
|
|
<tr class="memitem:a27a32c68950e464846b6730512968e4b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#a27a32c68950e464846b6730512968e4b">init</a> (<a class="el" href="../../d4/d06/struct_vector.html">Vector</a> *vec, int val)</td></tr>
|
|
<tr class="memdesc:a27a32c68950e464846b6730512968e4b"><td class="mdescLeft"> </td><td class="mdescRight">This function initilaizes the vector and gives it a size of 1 and initializes the first index to 0. <a href="../../df/dfa/vector_8c.html#a27a32c68950e464846b6730512968e4b">More...</a><br /></td></tr>
|
|
<tr class="separator:a27a32c68950e464846b6730512968e4b"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a2191fb0b42377eb385e1daf04bdfb939"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#a2191fb0b42377eb385e1daf04bdfb939">delete</a> (<a class="el" href="../../d4/d06/struct_vector.html">Vector</a> *vec)</td></tr>
|
|
<tr class="memdesc:a2191fb0b42377eb385e1daf04bdfb939"><td class="mdescLeft"> </td><td class="mdescRight">This function clears the heap memory allocated by the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. <a href="../../df/dfa/vector_8c.html#a2191fb0b42377eb385e1daf04bdfb939">More...</a><br /></td></tr>
|
|
<tr class="separator:a2191fb0b42377eb385e1daf04bdfb939"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ab9dfc1249180f1e924b7333a4e5d133a"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#ab9dfc1249180f1e924b7333a4e5d133a">clear</a> (<a class="el" href="../../d4/d06/struct_vector.html">Vector</a> *vec)</td></tr>
|
|
<tr class="memdesc:ab9dfc1249180f1e924b7333a4e5d133a"><td class="mdescLeft"> </td><td class="mdescRight">This function clears the contents of the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. <a href="../../df/dfa/vector_8c.html#ab9dfc1249180f1e924b7333a4e5d133a">More...</a><br /></td></tr>
|
|
<tr class="separator:ab9dfc1249180f1e924b7333a4e5d133a"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a6f8a49f17bf315bdc30749a57bc7bc93"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#a6f8a49f17bf315bdc30749a57bc7bc93">len</a> (<a class="el" href="../../d4/d06/struct_vector.html">Vector</a> *vec)</td></tr>
|
|
<tr class="memdesc:a6f8a49f17bf315bdc30749a57bc7bc93"><td class="mdescLeft"> </td><td class="mdescRight">This function returns the length the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. <a href="../../df/dfa/vector_8c.html#a6f8a49f17bf315bdc30749a57bc7bc93">More...</a><br /></td></tr>
|
|
<tr class="separator:a6f8a49f17bf315bdc30749a57bc7bc93"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a878dddf838dbd6d5a9a1da77a362ce56"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#a878dddf838dbd6d5a9a1da77a362ce56">push</a> (<a class="el" href="../../d4/d06/struct_vector.html">Vector</a> *vec, int val)</td></tr>
|
|
<tr class="memdesc:a878dddf838dbd6d5a9a1da77a362ce56"><td class="mdescLeft"> </td><td class="mdescRight">This function pushes a value to the end of the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. <a href="../../df/dfa/vector_8c.html#a878dddf838dbd6d5a9a1da77a362ce56">More...</a><br /></td></tr>
|
|
<tr class="separator:a878dddf838dbd6d5a9a1da77a362ce56"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a15f534ebe962fda31cc191852befc250"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#a15f534ebe962fda31cc191852befc250">get</a> (<a class="el" href="../../d4/d06/struct_vector.html">Vector</a> *vec, int index)</td></tr>
|
|
<tr class="memdesc:a15f534ebe962fda31cc191852befc250"><td class="mdescLeft"> </td><td class="mdescRight">This function get the item at the specified index of the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. <a href="../../df/dfa/vector_8c.html#a15f534ebe962fda31cc191852befc250">More...</a><br /></td></tr>
|
|
<tr class="separator:a15f534ebe962fda31cc191852befc250"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a6facac5424445995bd2f8bb03ffcb548"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#a6facac5424445995bd2f8bb03ffcb548">set</a> (<a class="el" href="../../d4/d06/struct_vector.html">Vector</a> *vec, int index, int val)</td></tr>
|
|
<tr class="memdesc:a6facac5424445995bd2f8bb03ffcb548"><td class="mdescLeft"> </td><td class="mdescRight">This function sets an item at the specified index of the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. <a href="../../df/dfa/vector_8c.html#a6facac5424445995bd2f8bb03ffcb548">More...</a><br /></td></tr>
|
|
<tr class="separator:a6facac5424445995bd2f8bb03ffcb548"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:af2f92e8cc55e764980bc0573ab5cd06f"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#af2f92e8cc55e764980bc0573ab5cd06f">next</a> (<a class="el" href="../../d4/d06/struct_vector.html">Vector</a> *vec)</td></tr>
|
|
<tr class="memdesc:af2f92e8cc55e764980bc0573ab5cd06f"><td class="mdescLeft"> </td><td class="mdescRight">This function gets the next item from the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> each time it's called. <a href="../../df/dfa/vector_8c.html#af2f92e8cc55e764980bc0573ab5cd06f">More...</a><br /></td></tr>
|
|
<tr class="separator:af2f92e8cc55e764980bc0573ab5cd06f"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a1afee8aaf33d741df31a73048cff4473"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#a1afee8aaf33d741df31a73048cff4473">begin</a> (<a class="el" href="../../d4/d06/struct_vector.html">Vector</a> *vec)</td></tr>
|
|
<tr class="memdesc:a1afee8aaf33d741df31a73048cff4473"><td class="mdescLeft"> </td><td class="mdescRight">This function returns the pointer to the begining of the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. <a href="../../df/dfa/vector_8c.html#a1afee8aaf33d741df31a73048cff4473">More...</a><br /></td></tr>
|
|
<tr class="separator:a1afee8aaf33d741df31a73048cff4473"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:abdb067a98f90bcd9b0aa4ceb364d607f"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#abdb067a98f90bcd9b0aa4ceb364d607f">print</a> (<a class="el" href="../../d4/d06/struct_vector.html">Vector</a> *vec)</td></tr>
|
|
<tr class="memdesc:abdb067a98f90bcd9b0aa4ceb364d607f"><td class="mdescLeft"> </td><td class="mdescRight">This function prints the entire <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> as a list. <a href="../../df/dfa/vector_8c.html#abdb067a98f90bcd9b0aa4ceb364d607f">More...</a><br /></td></tr>
|
|
<tr class="separator:abdb067a98f90bcd9b0aa4ceb364d607f"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:aa8dca7b867074164d5f45b0f3851269d"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#aa8dca7b867074164d5f45b0f3851269d">test</a> ()</td></tr>
|
|
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft"> </td><td class="mdescRight">This function tests the functions used to work with Vectors. <a href="../../df/dfa/vector_8c.html#aa8dca7b867074164d5f45b0f3851269d">More...</a><br /></td></tr>
|
|
<tr class="separator:aa8dca7b867074164d5f45b0f3851269d"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dfa/vector_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
|
|
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft"> </td><td class="mdescRight">Main function. <a href="../../df/dfa/vector_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">More...</a><br /></td></tr>
|
|
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><p >This is a vector implemenation in C. </p>
|
|
<p >A vector is an expandable array.</p>
|
|
<p >This vector implementation in C comes with some wrapper functions that lets the user work with data without having to worrying about memory. </p>
|
|
</div><h2 class="groupheader">Function Documentation</h2>
|
|
<a id="a1afee8aaf33d741df31a73048cff4473" name="a1afee8aaf33d741df31a73048cff4473"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a1afee8aaf33d741df31a73048cff4473">◆ </a></span>begin()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void * begin </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../d4/d06/struct_vector.html">Vector</a> * </td>
|
|
<td class="paramname"><em>vec</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>This function returns the pointer to the begining of the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. </p>
|
|
<p >@params Vector* (a pointer to the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> struct) </p><dl class="section return"><dt>Returns</dt><dd>: void* </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 116</span> {</div>
|
|
<div class="line"><span class="lineno"> 117</span> <span class="keywordflow">return</span> (<span class="keywordtype">void</span>*)vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">contents</a>;</div>
|
|
<div class="line"><span class="lineno"> 118</span>}</div>
|
|
<div class="ttc" id="astruct_vector_html_afd870750f3874ee097833fc8a1dc809e"><div class="ttname"><a href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">Vector::contents</a></div><div class="ttdeci">int * contents</div><div class="ttdoc">the internal array itself</div><div class="ttdef"><b>Definition:</b> vector.c:15</div></div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="ab9dfc1249180f1e924b7333a4e5d133a" name="ab9dfc1249180f1e924b7333a4e5d133a"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ab9dfc1249180f1e924b7333a4e5d133a">◆ </a></span>clear()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void clear </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../d4/d06/struct_vector.html">Vector</a> * </td>
|
|
<td class="paramname"><em>vec</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>This function clears the contents of the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. </p>
|
|
<p >@params Vector* (a pointer to the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> struct) </p><dl class="section return"><dt>Returns</dt><dd>: none </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 46</span> {</div>
|
|
<div class="line"><span class="lineno"> 47</span> <span class="keyword">delete</span>(vec);</div>
|
|
<div class="line"><span class="lineno"> 48</span> <a class="code hl_function" href="../../df/dfa/vector_8c.html#a27a32c68950e464846b6730512968e4b">init</a>(vec, 0);</div>
|
|
<div class="line"><span class="lineno"> 49</span>}</div>
|
|
<div class="ttc" id="avector_8c_html_a27a32c68950e464846b6730512968e4b"><div class="ttname"><a href="../../df/dfa/vector_8c.html#a27a32c68950e464846b6730512968e4b">init</a></div><div class="ttdeci">void init(Vector *vec, int val)</div><div class="ttdoc">This function initilaizes the vector and gives it a size of 1 and initializes the first index to 0.</div><div class="ttdef"><b>Definition:</b> vector.c:25</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="../../df/dfa/vector_8c_ab9dfc1249180f1e924b7333a4e5d133a_cgraph.svg" width="148" height="36"><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="a2191fb0b42377eb385e1daf04bdfb939" name="a2191fb0b42377eb385e1daf04bdfb939"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a2191fb0b42377eb385e1daf04bdfb939">◆ </a></span>delete()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void delete </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../d4/d06/struct_vector.html">Vector</a> * </td>
|
|
<td class="paramname"><em>vec</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>This function clears the heap memory allocated by the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. </p>
|
|
<p >@params Vector* (a pointer to the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> struct) </p><dl class="section return"><dt>Returns</dt><dd>: none </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 37</span> {</div>
|
|
<div class="line"><span class="lineno"> 38</span> <a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a>(vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">contents</a>); </div>
|
|
<div class="line"><span class="lineno"> 39</span>}</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><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a15f534ebe962fda31cc191852befc250" name="a15f534ebe962fda31cc191852befc250"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a15f534ebe962fda31cc191852befc250">◆ </a></span>get()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">int get </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../d4/d06/struct_vector.html">Vector</a> * </td>
|
|
<td class="paramname"><em>vec</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>index</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>This function get the item at the specified index of the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. </p>
|
|
<p >@params Vector* (a pointer to the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> struct) @params int (the index to get value from) </p><dl class="section return"><dt>Returns</dt><dd>: int </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 78</span> {</div>
|
|
<div class="line"><span class="lineno"> 79</span> <span class="keywordflow">if</span>(index < vec->len) {</div>
|
|
<div class="line"><span class="lineno"> 80</span> <span class="keywordflow">return</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">contents</a>[index];</div>
|
|
<div class="line"><span class="lineno"> 81</span> }</div>
|
|
<div class="line"><span class="lineno"> 82</span> <span class="keywordflow">return</span> -1;</div>
|
|
<div class="line"><span class="lineno"> 83</span>}</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a27a32c68950e464846b6730512968e4b" name="a27a32c68950e464846b6730512968e4b"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a27a32c68950e464846b6730512968e4b">◆ </a></span>init()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void init </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../d4/d06/struct_vector.html">Vector</a> * </td>
|
|
<td class="paramname"><em>vec</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>val</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>This function initilaizes the vector and gives it a size of 1 and initializes the first index to 0. </p>
|
|
<p >@params Vector* (a pointer to the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> struct) @params int (the actual data to be passed to the vector) </p><dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 25</span> {</div>
|
|
<div class="line"><span class="lineno"> 26</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">contents</a> = (<span class="keywordtype">int</span>*)<a class="code hl_define" href="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a>(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>));</div>
|
|
<div class="line"><span class="lineno"> 27</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">contents</a>[0] = val;</div>
|
|
<div class="line"><span class="lineno"> 28</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a8cb577f14bea1a6c1fbf85717b3ee4f9">current</a> = 0;</div>
|
|
<div class="line"><span class="lineno"> 29</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a55870593ddea19c96770c2521b075059">len</a> = 1;</div>
|
|
<div class="line"><span class="lineno"> 30</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 class="ttc" id="astruct_vector_html_a55870593ddea19c96770c2521b075059"><div class="ttname"><a href="../../d4/d06/struct_vector.html#a55870593ddea19c96770c2521b075059">Vector::len</a></div><div class="ttdeci">int len</div><div class="ttdoc">contains the length of the vector</div><div class="ttdef"><b>Definition:</b> vector.c:13</div></div>
|
|
<div class="ttc" id="astruct_vector_html_a8cb577f14bea1a6c1fbf85717b3ee4f9"><div class="ttname"><a href="../../d4/d06/struct_vector.html#a8cb577f14bea1a6c1fbf85717b3ee4f9">Vector::current</a></div><div class="ttdeci">int current</div><div class="ttdoc">holds the current item</div><div class="ttdef"><b>Definition:</b> vector.c:14</div></div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a6f8a49f17bf315bdc30749a57bc7bc93" name="a6f8a49f17bf315bdc30749a57bc7bc93"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a6f8a49f17bf315bdc30749a57bc7bc93">◆ </a></span>len()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">int len </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../d4/d06/struct_vector.html">Vector</a> * </td>
|
|
<td class="paramname"><em>vec</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>This function returns the length the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. </p>
|
|
<p >@params Vector* (a pointer to the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> struct) </p><dl class="section return"><dt>Returns</dt><dd>: int </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 56</span> {</div>
|
|
<div class="line"><span class="lineno"> 57</span> <span class="keywordflow">return</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a55870593ddea19c96770c2521b075059">len</a>; </div>
|
|
<div class="line"><span class="lineno"> 58</span>}</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">◆ </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">void </td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Main function. </p>
|
|
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 156</span> {</div>
|
|
<div class="line"><span class="lineno"> 157</span> <a class="code hl_function" href="../../df/dfa/vector_8c.html#aa8dca7b867074164d5f45b0f3851269d">test</a>();</div>
|
|
<div class="line"><span class="lineno"> 158</span> </div>
|
|
<div class="line"><span class="lineno"> 159</span> <a class="code hl_struct" href="../../d4/d06/struct_vector.html">Vector</a> vec;</div>
|
|
<div class="line"><span class="lineno"> 160</span> <a class="code hl_function" href="../../df/dfa/vector_8c.html#a27a32c68950e464846b6730512968e4b">init</a>(&vec, 10);</div>
|
|
<div class="line"><span class="lineno"> 161</span> <a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#a613462735d30cae1b85b606ecab30554">push</a>(&vec, 20);</div>
|
|
<div class="line"><span class="lineno"> 162</span> <a class="code hl_function" href="../../df/dfa/vector_8c.html#abdb067a98f90bcd9b0aa4ceb364d607f">print</a>(&vec);</div>
|
|
<div class="line"><span class="lineno"> 163</span> <a class="code hl_function" href="../../df/dfa/vector_8c.html#a6facac5424445995bd2f8bb03ffcb548">set</a>(&vec, 0, 11);</div>
|
|
<div class="line"><span class="lineno"> 164</span> <a class="code hl_function" href="../../df/dfa/vector_8c.html#a6facac5424445995bd2f8bb03ffcb548">set</a>(&vec, 1, 22);</div>
|
|
<div class="line"><span class="lineno"> 165</span> <a class="code hl_function" href="../../df/dfa/vector_8c.html#abdb067a98f90bcd9b0aa4ceb364d607f">print</a>(&vec);</div>
|
|
<div class="line"><span class="lineno"> 166</span> printf(<span class="stringliteral">"Length: %d\n"</span>, len(&vec));</div>
|
|
<div class="line"><span class="lineno"> 167</span> <span class="keywordflow">return</span> 0;</div>
|
|
<div class="line"><span class="lineno"> 168</span>}</div>
|
|
<div class="ttc" id="ainfix__to__postfix_8c_html_a613462735d30cae1b85b606ecab30554"><div class="ttname"><a href="../../db/d0c/infix__to__postfix_8c.html#a613462735d30cae1b85b606ecab30554">push</a></div><div class="ttdeci">void push(struct Stack *p, char ch)</div><div class="ttdoc">push function</div><div class="ttdef"><b>Definition:</b> infix_to_postfix.c:55</div></div>
|
|
<div class="ttc" id="astruct_vector_html"><div class="ttname"><a href="../../d4/d06/struct_vector.html">Vector</a></div><div class="ttdoc">for IO operations</div><div class="ttdef"><b>Definition:</b> vector.c:12</div></div>
|
|
<div class="ttc" id="avector_8c_html_a6facac5424445995bd2f8bb03ffcb548"><div class="ttname"><a href="../../df/dfa/vector_8c.html#a6facac5424445995bd2f8bb03ffcb548">set</a></div><div class="ttdeci">void set(Vector *vec, int index, int val)</div><div class="ttdoc">This function sets an item at the specified index of the Vector.</div><div class="ttdef"><b>Definition:</b> vector.c:91</div></div>
|
|
<div class="ttc" id="avector_8c_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../df/dfa/vector_8c.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">This function tests the functions used to work with Vectors.</div><div class="ttdef"><b>Definition:</b> vector.c:138</div></div>
|
|
<div class="ttc" id="avector_8c_html_abdb067a98f90bcd9b0aa4ceb364d607f"><div class="ttname"><a href="../../df/dfa/vector_8c.html#abdb067a98f90bcd9b0aa4ceb364d607f">print</a></div><div class="ttdeci">void print(Vector *vec)</div><div class="ttdoc">This function prints the entire Vector as a list.</div><div class="ttdef"><b>Definition:</b> vector.c:125</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="../../df/dfa/vector_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="255" height="262"><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="af2f92e8cc55e764980bc0573ab5cd06f" name="af2f92e8cc55e764980bc0573ab5cd06f"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#af2f92e8cc55e764980bc0573ab5cd06f">◆ </a></span>next()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">int next </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../d4/d06/struct_vector.html">Vector</a> * </td>
|
|
<td class="paramname"><em>vec</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>This function gets the next item from the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> each time it's called. </p>
|
|
<p >@params Vector* (a pointer to the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> struct) </p><dl class="section return"><dt>Returns</dt><dd>: int </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 102</span> {</div>
|
|
<div class="line"><span class="lineno"> 103</span> <span class="keywordflow">if</span>(vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a8cb577f14bea1a6c1fbf85717b3ee4f9">current</a> == vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a55870593ddea19c96770c2521b075059">len</a>) {</div>
|
|
<div class="line"><span class="lineno"> 104</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a8cb577f14bea1a6c1fbf85717b3ee4f9">current</a> = 0;</div>
|
|
<div class="line"><span class="lineno"> 105</span> }</div>
|
|
<div class="line"><span class="lineno"> 106</span> <span class="keywordtype">int</span> current_val = vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">contents</a>[vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a8cb577f14bea1a6c1fbf85717b3ee4f9">current</a>];</div>
|
|
<div class="line"><span class="lineno"> 107</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a8cb577f14bea1a6c1fbf85717b3ee4f9">current</a>++;</div>
|
|
<div class="line"><span class="lineno"> 108</span> <span class="keywordflow">return</span> current_val;</div>
|
|
<div class="line"><span class="lineno"> 109</span>}</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="abdb067a98f90bcd9b0aa4ceb364d607f" name="abdb067a98f90bcd9b0aa4ceb364d607f"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#abdb067a98f90bcd9b0aa4ceb364d607f">◆ </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="../../d4/d06/struct_vector.html">Vector</a> * </td>
|
|
<td class="paramname"><em>vec</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>This function prints the entire <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> as a list. </p>
|
|
<p >@params Vector* (a pointer to the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> struct) </p><dl class="section return"><dt>Returns</dt><dd>: none </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 125</span> {</div>
|
|
<div class="line"><span class="lineno"> 126</span> <span class="keywordtype">int</span> size = vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a55870593ddea19c96770c2521b075059">len</a>;</div>
|
|
<div class="line"><span class="lineno"> 127</span> printf(<span class="stringliteral">"[ "</span>);</div>
|
|
<div class="line"><span class="lineno"> 128</span> <span class="keywordflow">for</span>(<span class="keywordtype">int</span> count = 0; count < size; count++) {</div>
|
|
<div class="line"><span class="lineno"> 129</span> printf(<span class="stringliteral">"%d "</span>, vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">contents</a>[count]);</div>
|
|
<div class="line"><span class="lineno"> 130</span> }</div>
|
|
<div class="line"><span class="lineno"> 131</span> printf(<span class="stringliteral">"]\n"</span>);</div>
|
|
<div class="line"><span class="lineno"> 132</span>}</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a878dddf838dbd6d5a9a1da77a362ce56" name="a878dddf838dbd6d5a9a1da77a362ce56"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a878dddf838dbd6d5a9a1da77a362ce56">◆ </a></span>push()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void push </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../d4/d06/struct_vector.html">Vector</a> * </td>
|
|
<td class="paramname"><em>vec</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>val</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>This function pushes a value to the end of the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. </p>
|
|
<p >@params Vector* (a pointer to the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> struct) @params int (the value to be pushed) </p><dl class="section return"><dt>Returns</dt><dd>: none </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 66</span> {</div>
|
|
<div class="line"><span class="lineno"> 67</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">contents</a> = realloc(vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">contents</a>, (<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>) * (vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a55870593ddea19c96770c2521b075059">len</a> + 1)));</div>
|
|
<div class="line"><span class="lineno"> 68</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">contents</a>[vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a55870593ddea19c96770c2521b075059">len</a>] = val;</div>
|
|
<div class="line"><span class="lineno"> 69</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#a55870593ddea19c96770c2521b075059">len</a>++;</div>
|
|
<div class="line"><span class="lineno"> 70</span>}</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="../../df/dfa/vector_8c_a878dddf838dbd6d5a9a1da77a362ce56_cgraph.svg" width="160" 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="a6facac5424445995bd2f8bb03ffcb548" name="a6facac5424445995bd2f8bb03ffcb548"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a6facac5424445995bd2f8bb03ffcb548">◆ </a></span>set()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void set </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="../../d4/d06/struct_vector.html">Vector</a> * </td>
|
|
<td class="paramname"><em>vec</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>index</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>val</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>This function sets an item at the specified index of the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a>. </p>
|
|
<p >@params Vector* (a pointer to the <a class="el" href="../../d4/d06/struct_vector.html" title="for IO operations">Vector</a> struct) @params int (the index to set value at) </p><dl class="section return"><dt>Returns</dt><dd>: none </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 91</span> {</div>
|
|
<div class="line"><span class="lineno"> 92</span> <span class="keywordflow">if</span>(index < vec->len) {</div>
|
|
<div class="line"><span class="lineno"> 93</span> vec-><a class="code hl_variable" href="../../d4/d06/struct_vector.html#afd870750f3874ee097833fc8a1dc809e">contents</a>[index] = val;</div>
|
|
<div class="line"><span class="lineno"> 94</span> }</div>
|
|
<div class="line"><span class="lineno"> 95</span>}</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="aa8dca7b867074164d5f45b0f3851269d" name="aa8dca7b867074164d5f45b0f3851269d"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aa8dca7b867074164d5f45b0f3851269d">◆ </a></span>test()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">static void test </td>
|
|
<td>(</td>
|
|
<td class="paramtype">void </td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>This function tests the functions used to work with Vectors. </p>
|
|
<dl class="section return"><dt>Returns</dt><dd>: none </dd></dl>
|
|
<div class="fragment"><div class="line"><span class="lineno"> 138</span> {</div>
|
|
<div class="line"><span class="lineno"> 139</span> <a class="code hl_struct" href="../../d4/d06/struct_vector.html">Vector</a> vec;</div>
|
|
<div class="line"><span class="lineno"> 140</span> <a class="code hl_function" href="../../df/dfa/vector_8c.html#a27a32c68950e464846b6730512968e4b">init</a>(&vec, 10);</div>
|
|
<div class="line"><span class="lineno"> 141</span> assert(<a class="code hl_function" href="../../df/dfa/vector_8c.html#a15f534ebe962fda31cc191852befc250">get</a>(&vec, 0) == 10);</div>
|
|
<div class="line"><span class="lineno"> 142</span> <a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#a613462735d30cae1b85b606ecab30554">push</a>(&vec, 20);</div>
|
|
<div class="line"><span class="lineno"> 143</span> assert(<a class="code hl_function" href="../../df/dfa/vector_8c.html#a15f534ebe962fda31cc191852befc250">get</a>(&vec, 1) == 20);</div>
|
|
<div class="line"><span class="lineno"> 144</span> <a class="code hl_function" href="../../df/dfa/vector_8c.html#a6facac5424445995bd2f8bb03ffcb548">set</a>(&vec, 0, 11);</div>
|
|
<div class="line"><span class="lineno"> 145</span> assert(<a class="code hl_function" href="../../df/dfa/vector_8c.html#a15f534ebe962fda31cc191852befc250">get</a>(&vec, 0) == 11);</div>
|
|
<div class="line"><span class="lineno"> 146</span> assert(<a class="code hl_function" href="../../df/dfa/vector_8c.html#af2f92e8cc55e764980bc0573ab5cd06f">next</a>(&vec) == 11);</div>
|
|
<div class="line"><span class="lineno"> 147</span> <a class="code hl_function" href="../../df/dfa/vector_8c.html#a6facac5424445995bd2f8bb03ffcb548">set</a>(&vec, 1, 22);</div>
|
|
<div class="line"><span class="lineno"> 148</span> assert(<a class="code hl_function" href="../../df/dfa/vector_8c.html#a15f534ebe962fda31cc191852befc250">get</a>(&vec, 1) == 22);</div>
|
|
<div class="line"><span class="lineno"> 149</span> assert(len(&vec) == 2);</div>
|
|
<div class="line"><span class="lineno"> 150</span>}</div>
|
|
<div class="ttc" id="avector_8c_html_a15f534ebe962fda31cc191852befc250"><div class="ttname"><a href="../../df/dfa/vector_8c.html#a15f534ebe962fda31cc191852befc250">get</a></div><div class="ttdeci">int get(Vector *vec, int index)</div><div class="ttdoc">This function get the item at the specified index of the Vector.</div><div class="ttdef"><b>Definition:</b> vector.c:78</div></div>
|
|
<div class="ttc" id="avector_8c_html_af2f92e8cc55e764980bc0573ab5cd06f"><div class="ttname"><a href="../../df/dfa/vector_8c.html#af2f92e8cc55e764980bc0573ab5cd06f">next</a></div><div class="ttdeci">int next(Vector *vec)</div><div class="ttdoc">This function gets the next item from the Vector each time it's called.</div><div class="ttdef"><b>Definition:</b> vector.c:102</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="../../df/dfa/vector_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg" width="154" height="258"><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_2e746e9d06bf2d8ff842208bcc6ebcfc.html">data_structures</a></li><li class="navelem"><a class="el" href="../../df/dfa/vector_8c.html">vector.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>
|