<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.8"/> <title>SphinxBase: include/sphinxbase/heap.h 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="navtree.js"></script> <script type="text/javascript"> $(document).ready(initResizable); $(window).load(resizeHeight); </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 style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">SphinxBase  <span id="projectnumber">0.6</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.8 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </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"> $(document).ready(function(){initNavTree('heap_8h.html','');}); </script> <div id="doc-content"> <div class="header"> <div class="summary"> <a href="#typedef-members">Typedefs</a> | <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">heap.h File Reference</div> </div> </div><!--header--> <div class="contents"> <p>Heap Implementation. <a href="#details">More...</a></p> <div class="textblock"><code>#include <stdlib.h></code><br /> <code>#include <sphinxbase/sphinxbase_export.h></code><br /> <code>#include <<a class="el" href="prim__type_8h_source.html">sphinxbase/prim_type.h</a>></code><br /> </div> <p><a href="heap_8h_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 name="typedef-members"></a> Typedefs</h2></td></tr> <tr class="memitem:a0ffa4ec8648c254bf19eee352b69dc7a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0ffa4ec8648c254bf19eee352b69dc7a"></a> typedef struct <a class="el" href="structheap__s.html">heap_s</a> </td><td class="memItemRight" valign="bottom"><b>heap_t</b></td></tr> <tr class="separator:a0ffa4ec8648c254bf19eee352b69dc7a"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:a9bc21333ce58caaf58e802d8b0190efd"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9bc21333ce58caaf58e802d8b0190efd"></a> SPHINXBASE_EXPORT <a class="el" href="structheap__s.html">heap_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#a9bc21333ce58caaf58e802d8b0190efd">heap_new</a> (void)</td></tr> <tr class="memdesc:a9bc21333ce58caaf58e802d8b0190efd"><td class="mdescLeft"> </td><td class="mdescRight">Allocate a new heap and return handle to it. <br /></td></tr> <tr class="separator:a9bc21333ce58caaf58e802d8b0190efd"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a64bcded2de5086c5d246ff760caa74a3"><td class="memItemLeft" align="right" valign="top">SPHINXBASE_EXPORT int </td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#a64bcded2de5086c5d246ff760caa74a3">heap_insert</a> (<a class="el" href="structheap__s.html">heap_t</a> *heap, void *data, int32 val)</td></tr> <tr class="memdesc:a64bcded2de5086c5d246ff760caa74a3"><td class="mdescLeft"> </td><td class="mdescRight">Insert a new item into the given heap. <a href="#a64bcded2de5086c5d246ff760caa74a3">More...</a><br /></td></tr> <tr class="separator:a64bcded2de5086c5d246ff760caa74a3"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ae70da6b59215654c2cd5ec177eaf2aec"><td class="memItemLeft" align="right" valign="top">SPHINXBASE_EXPORT int </td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#ae70da6b59215654c2cd5ec177eaf2aec">heap_top</a> (<a class="el" href="structheap__s.html">heap_t</a> *heap, void **data, int32 *val)</td></tr> <tr class="memdesc:ae70da6b59215654c2cd5ec177eaf2aec"><td class="mdescLeft"> </td><td class="mdescRight">Return the topmost item in the heap. <a href="#ae70da6b59215654c2cd5ec177eaf2aec">More...</a><br /></td></tr> <tr class="separator:ae70da6b59215654c2cd5ec177eaf2aec"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a387c8913b4c62ad1a5c4702a4e6dbdbf"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a387c8913b4c62ad1a5c4702a4e6dbdbf"></a> SPHINXBASE_EXPORT int </td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#a387c8913b4c62ad1a5c4702a4e6dbdbf">heap_pop</a> (<a class="el" href="structheap__s.html">heap_t</a> *heap, void **data, int32 *val)</td></tr> <tr class="memdesc:a387c8913b4c62ad1a5c4702a4e6dbdbf"><td class="mdescLeft"> </td><td class="mdescRight">Like heap_top but also pop the top item off the heap. <br /></td></tr> <tr class="separator:a387c8913b4c62ad1a5c4702a4e6dbdbf"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:aa2dbc059f9707e434098694e8c69157e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa2dbc059f9707e434098694e8c69157e"></a> SPHINXBASE_EXPORT int </td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#aa2dbc059f9707e434098694e8c69157e">heap_remove</a> (<a class="el" href="structheap__s.html">heap_t</a> *heap, void *data)</td></tr> <tr class="memdesc:aa2dbc059f9707e434098694e8c69157e"><td class="mdescLeft"> </td><td class="mdescRight">Remove an item from the heap. <br /></td></tr> <tr class="separator:aa2dbc059f9707e434098694e8c69157e"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a1c713d67123e96974505edfa4346cb0f"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1c713d67123e96974505edfa4346cb0f"></a> SPHINXBASE_EXPORT size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#a1c713d67123e96974505edfa4346cb0f">heap_size</a> (<a class="el" href="structheap__s.html">heap_t</a> *heap)</td></tr> <tr class="memdesc:a1c713d67123e96974505edfa4346cb0f"><td class="mdescLeft"> </td><td class="mdescRight">Return the number of items in the heap. <br /></td></tr> <tr class="separator:a1c713d67123e96974505edfa4346cb0f"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ab12b1efd6392eb574d2da9c981e7320c"><td class="memItemLeft" align="right" valign="top">SPHINXBASE_EXPORT int </td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#ab12b1efd6392eb574d2da9c981e7320c">heap_destroy</a> (<a class="el" href="structheap__s.html">heap_t</a> *heap)</td></tr> <tr class="memdesc:ab12b1efd6392eb574d2da9c981e7320c"><td class="mdescLeft"> </td><td class="mdescRight">Destroy the given heap; free the heap nodes. <a href="#ab12b1efd6392eb574d2da9c981e7320c">More...</a><br /></td></tr> <tr class="separator:ab12b1efd6392eb574d2da9c981e7320c"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>Heap Implementation. </p> <p>General Comment: Sorted heap structure with three main operations:</p> <ol type="1"> <li>Insert a data item (with two attributes: an application supplied pointer and an integer value; the heap is maintained in ascending order of the integer value).</li> <li>Return the currently topmost item (i.e., item with smallest associated value).</li> <li>Return the currently topmost item and pop it off the heap. </li> </ol> <p>Definition in file <a class="el" href="heap_8h_source.html">heap.h</a>.</p> </div><h2 class="groupheader">Function Documentation</h2> <a class="anchor" id="ab12b1efd6392eb574d2da9c981e7320c"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">SPHINXBASE_EXPORT int heap_destroy </td> <td>(</td> <td class="paramtype"><a class="el" href="structheap__s.html">heap_t</a> * </td> <td class="paramname"><em>heap</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Destroy the given heap; free the heap nodes. </p> <p>NOTE: Data pointers in the nodes are NOT freed. Return value: 0 if successful, -1 otherwise. </p> <p>Definition at line <a class="el" href="heap_8c_source.html#l00281">281</a> of file <a class="el" href="heap_8c_source.html">heap.c</a>.</p> <p>References <a class="el" href="ckd__alloc_8c_source.html#l00241">ckd_free()</a>, and <a class="el" href="heap_8c_source.html#l00209">heap_pop()</a>.</p> <p>Referenced by <a class="el" href="huff__code_8c_source.html#l00229">huff_code_build_int()</a>, and <a class="el" href="huff__code_8c_source.html#l00269">huff_code_build_str()</a>.</p> </div> </div> <a class="anchor" id="a64bcded2de5086c5d246ff760caa74a3"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">SPHINXBASE_EXPORT int heap_insert </td> <td>(</td> <td class="paramtype"><a class="el" href="structheap__s.html">heap_t</a> * </td> <td class="paramname"><em>heap</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void * </td> <td class="paramname"><em>data</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int32 </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>Insert a new item into the given heap. </p> <p>Return value: 0 if successful, -1 otherwise. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">heap</td><td>In: Heap into which item is to be inserted </td></tr> <tr><td class="paramname">data</td><td>In: Application-determined data pointer </td></tr> <tr><td class="paramname">val</td><td>In: According to item entered in sorted heap </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="heap_8c_source.html#l00161">161</a> of file <a class="el" href="heap_8c_source.html">heap.c</a>.</p> <p>Referenced by <a class="el" href="huff__code_8c_source.html#l00229">huff_code_build_int()</a>, and <a class="el" href="huff__code_8c_source.html#l00269">huff_code_build_str()</a>.</p> </div> </div> <a class="anchor" id="ae70da6b59215654c2cd5ec177eaf2aec"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">SPHINXBASE_EXPORT int heap_top </td> <td>(</td> <td class="paramtype"><a class="el" href="structheap__s.html">heap_t</a> * </td> <td class="paramname"><em>heap</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void ** </td> <td class="paramname"><em>data</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int32 * </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>Return the topmost item in the heap. </p> <p>Return value: 1 if heap is not empty and the topmost value is returned; 0 if heap is empty; -1 if some error occurred. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">heap</td><td>In: Heap whose topmost item is to be returned </td></tr> <tr><td class="paramname">data</td><td>Out: Data pointer associated with the topmost item </td></tr> <tr><td class="paramname">val</td><td>Out: Value associated with the topmost item </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="heap_8c_source.html#l00221">221</a> of file <a class="el" href="heap_8c_source.html">heap.c</a>.</p> <p>References <a class="el" href="heap_8c_source.html#l00078">heapnode_s::data</a>, and <a class="el" href="heap_8c_source.html#l00079">heapnode_s::val</a>.</p> </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_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_e3d154c296a8e9be2797a4f81e9375b2.html">sphinxbase</a></li><li class="navelem"><a class="el" href="heap_8h.html">heap.h</a></li> <li class="footer">Generated on Sat Oct 18 2014 15:21:17 for SphinxBase by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.8 </li> </ul> </div> </body> </html>