📄 group__gdsl__heap.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>gdsl: Heap manipulation module</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.6 --><div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul></div><h1>Heap manipulation module</h1><p><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr><tr><td colspan="2"><br><h2>Typedefs</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">typedef heap * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a></td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">GDSL heap type. <a href="#g78edcc85d3172b3983098958b91d6e44"></a><br></td></tr><tr><td colspan="2"><br><h2>Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#gd1346deeacc31ebad0ec43326210e91b">gdsl_heap_alloc</a> (const char *NAME, <a class="el" href="group__gdsl__types.html#g32a9b4e8b9665183c2741d28a5ced64f">gdsl_alloc_func_t</a> ALLOC_F, <a class="el" href="group__gdsl__types.html#g2c6b3f96b291b5b39d2799f93e350053">gdsl_free_func_t</a> FREE_F, <a class="el" href="group__gdsl__types.html#g200177a9a1ac3f2363e228b0e5faeda7">gdsl_compare_func_t</a> COMP_F)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Create a new heap. <a href="#gd1346deeacc31ebad0ec43326210e91b"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g35fbed7f124a3f5c7e560a7cf9505020">gdsl_heap_free</a> (<a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Destroy a heap. <a href="#g35fbed7f124a3f5c7e560a7cf9505020"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g4ead06c95c01b78c9e5c25389a1dff04">gdsl_heap_flush</a> (<a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Flush a heap. <a href="#g4ead06c95c01b78c9e5c25389a1dff04"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g042886cdec3eab67e5c9846dcf372153">gdsl_heap_get_name</a> (const <a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Get the name of a heap. <a href="#g042886cdec3eab67e5c9846dcf372153"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__gdsl__types.html#g9c34ac44da309b004570530c8cec8a0e">ulong</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g0b07df738a31dea80792fdc09f1faafe">gdsl_heap_get_size</a> (const <a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Get the size of a heap. <a href="#g0b07df738a31dea80792fdc09f1faafe"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__gdsl__types.html#g0e2b9d7fb5ca9e6d50100e5d9e4bcae7">gdsl_element_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#gfb1797eb31cd1c7f9011dc5170b3e694">gdsl_heap_get_top</a> (const <a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Get the top of a heap. <a href="#gfb1797eb31cd1c7f9011dc5170b3e694"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__gdsl__types.html#gf6a258d8f3ee5206d682d799316314b1">bool</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#gec7eb81d14c4509c7d8f8b1e77fdaae3">gdsl_heap_is_empty</a> (const <a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Check if a heap is empty. <a href="#gec7eb81d14c4509c7d8f8b1e77fdaae3"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g006557ed075fb78f548f7d174ba3dc92">gdsl_heap_set_name</a> (<a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H, const char *NEW_NAME)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Set the name of a heap. <a href="#g006557ed075fb78f548f7d174ba3dc92"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__gdsl__types.html#g0e2b9d7fb5ca9e6d50100e5d9e4bcae7">gdsl_element_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g487b264a271d14cb9feeef6f70c31ff0">gdsl_heap_set_top</a> (<a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H, void *VALUE)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Substitute the top element of a heap by a lesser one. <a href="#g487b264a271d14cb9feeef6f70c31ff0"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__gdsl__types.html#g0e2b9d7fb5ca9e6d50100e5d9e4bcae7">gdsl_element_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g908a843511c403c581b5ec6c415c5da3">gdsl_heap_insert</a> (<a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H, void *VALUE)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Insert an element into a heap (PUSH). <a href="#g908a843511c403c581b5ec6c415c5da3"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__gdsl__types.html#g0e2b9d7fb5ca9e6d50100e5d9e4bcae7">gdsl_element_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g1dd8eec61cd56e6dcd7fb3120e634ed1">gdsl_heap_remove_top</a> (<a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Remove the top element from a heap (POP). <a href="#g1dd8eec61cd56e6dcd7fb3120e634ed1"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g3db73501b51ca73ad181342af4003069">gdsl_heap_delete_top</a> (<a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Delete the top element from a heap. <a href="#g3db73501b51ca73ad181342af4003069"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="group__gdsl__types.html#g0e2b9d7fb5ca9e6d50100e5d9e4bcae7">gdsl_element_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g150786779bc204172a7b3479591d49d1">gdsl_heap_map_forward</a> (const <a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H, <a class="el" href="group__gdsl__types.html#g2500bfaaec5df890e72b43f448f13ee8">gdsl_map_func_t</a> MAP_F, void *USER_DATA)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Parse a heap. <a href="#g150786779bc204172a7b3479591d49d1"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#gbed5d8db4aadd03ddf66ca54c3cf8a6d">gdsl_heap_write</a> (const <a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H, <a class="el" href="group__gdsl__types.html#gfc7394b6c8e0a5bd92df75e24512dfd6">gdsl_write_func_t</a> WRITE_F, FILE *OUTPUT_FILE, void *USER_DATA)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Write all the elements of a heap to a file. <a href="#gbed5d8db4aadd03ddf66ca54c3cf8a6d"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#gdcdcbb2f40d4fc3df08d88f0398d0059">gdsl_heap_write_xml</a> (const <a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H, <a class="el" href="group__gdsl__types.html#gfc7394b6c8e0a5bd92df75e24512dfd6">gdsl_write_func_t</a> WRITE_F, FILE *OUTPUT_FILE, void *USER_DATA)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Write the content of a heap to a file into XML. <a href="#gdcdcbb2f40d4fc3df08d88f0398d0059"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__gdsl__heap.html#g443d3d9679d4a2e98d4723674df90475">gdsl_heap_dump</a> (const <a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> H, <a class="el" href="group__gdsl__types.html#gfc7394b6c8e0a5bd92df75e24512dfd6">gdsl_write_func_t</a> WRITE_F, FILE *OUTPUT_FILE, void *USER_DATA)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Dump the internal structure of a heap to a file. <a href="#g443d3d9679d4a2e98d4723674df90475"></a><br></td></tr></table><hr><h2>Typedef Documentation</h2><a class="anchor" name="g78edcc85d3172b3983098958b91d6e44"></a><!-- doxytag: member="gdsl_heap.h::gdsl_heap_t" ref="g78edcc85d3172b3983098958b91d6e44" args="" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">typedef struct heap* <a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> </td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>GDSL heap type. <p>This type is voluntary opaque. Variables of this kind could'nt be directly used, but by the functions of this module. <p>Definition at line <a class="el" href="gdsl__heap_8h-source.html#l00054">54</a> of file <a class="el" href="gdsl__heap_8h-source.html">gdsl_heap.h</a>. </td> </tr></table><hr><h2>Function Documentation</h2><a class="anchor" name="gd1346deeacc31ebad0ec43326210e91b"></a><!-- doxytag: member="gdsl_heap.h::gdsl_heap_alloc" ref="gd1346deeacc31ebad0ec43326210e91b" args="(const char *NAME, gdsl_alloc_func_t ALLOC_F, gdsl_free_func_t FREE_F, gdsl_compare_func_t COMP_F)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"><a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> gdsl_heap_alloc </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const char * </td> <td class="mdname" nowrap> <em>NAME</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="group__gdsl__types.html#g32a9b4e8b9665183c2741d28a5ced64f">gdsl_alloc_func_t</a> </td> <td class="mdname" nowrap> <em>ALLOC_F</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="group__gdsl__types.html#g2c6b3f96b291b5b39d2799f93e350053">gdsl_free_func_t</a> </td> <td class="mdname" nowrap> <em>FREE_F</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="group__gdsl__types.html#g200177a9a1ac3f2363e228b0e5faeda7">gdsl_compare_func_t</a> </td> <td class="mdname" nowrap> <em>COMP_F</em></td> </tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Create a new heap. <p>Allocate a new heap data structure which name is set to a copy of NAME. The function pointers ALLOC_F, FREE_F and COMP_F could be used to respectively, alloc, free and compares elements in the heap. These pointers could be set to NULL to use the default ones:<ul><li>the default ALLOC_F simply returns its argument</li><li>the default FREE_F does nothing</li><li>the default COMP_F always returns 0</li></ul><p><dl compact><dt><b>Note:</b></dt><dd>Complexity: O( 1 ) </dd></dl><dl compact><dt><b>Precondition:</b></dt><dd>nothing </dd></dl><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>NAME</em> </td><td>The name of the new heap to create </td></tr> <tr><td valign="top"></td><td valign="top"><em>ALLOC_F</em> </td><td>Function to alloc element when inserting it in the heap </td></tr> <tr><td valign="top"></td><td valign="top"><em>FREE_F</em> </td><td>Function to free element when removing it from the heap </td></tr> <tr><td valign="top"></td><td valign="top"><em>COMP_F</em> </td><td>Function to compare elements into the heap </td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>the newly allocated heap in case of success. <p>NULL in case of insufficient memory. </dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__gdsl__heap.html#g35fbed7f124a3f5c7e560a7cf9505020">gdsl_heap_free()</a> <p><a class="el" href="group__gdsl__heap.html#g4ead06c95c01b78c9e5c25389a1dff04">gdsl_heap_flush()</a> </dd></dl> </td> </tr></table><a class="anchor" name="g35fbed7f124a3f5c7e560a7cf9505020"></a><!-- doxytag: member="gdsl_heap.h::gdsl_heap_free" ref="g35fbed7f124a3f5c7e560a7cf9505020" args="(gdsl_heap_t H)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">void gdsl_heap_free </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> </td> <td class="mdname1" valign="top" nowrap> <em>H</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Destroy a heap. <p>Deallocate all the elements of the heap H by calling H's FREE_F function passed to <a class="el" href="group__gdsl__heap.html#gd1346deeacc31ebad0ec43326210e91b">gdsl_heap_alloc()</a>. The name of H is deallocated and H is deallocated itself too.<p><dl compact><dt><b>Note:</b></dt><dd>Complexity: O( |H| ) </dd></dl><dl compact><dt><b>Precondition:</b></dt><dd>H must be a valid gdsl_heap_t </dd></dl><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>H</em> </td><td>The heap to destroy </td></tr> </table></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__gdsl__heap.html#gd1346deeacc31ebad0ec43326210e91b">gdsl_heap_alloc()</a> <p><a class="el" href="group__gdsl__heap.html#g4ead06c95c01b78c9e5c25389a1dff04">gdsl_heap_flush()</a> </dd></dl> </td> </tr></table><a class="anchor" name="g4ead06c95c01b78c9e5c25389a1dff04"></a><!-- doxytag: member="gdsl_heap.h::gdsl_heap_flush" ref="g4ead06c95c01b78c9e5c25389a1dff04" args="(gdsl_heap_t H)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">void gdsl_heap_flush </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="group__gdsl__heap.html#g78edcc85d3172b3983098958b91d6e44">gdsl_heap_t</a> </td> <td class="mdname1" valign="top" nowrap> <em>H</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -