1 <!-- HTML header for doxygen 1.8.20-->
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
5 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
6 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
7 <meta name="generator" content="Doxygen 1.9.4"/>
8 <meta name="viewport" content="width=device-width, initial-scale=1"/>
9 <title>Raspberry Pi Pico SDK: include/pico/util/pheap.h File Reference</title>
10 <!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
11 <script type="text/javascript" src="jquery.js"></script>
12 <script type="text/javascript" src="dynsections.js"></script>
13 <link href="navtree.css" rel="stylesheet" type="text/css"/>
14 <script type="text/javascript" src="resize.js"></script>
15 <script type="text/javascript" src="navtreedata.js"></script>
16 <script type="text/javascript" src="navtree.js"></script>
17 <link href="search/search.css" rel="stylesheet" type="text/css"/>
18 <script type="text/javascript" src="search/searchdata.js"></script>
19 <script type="text/javascript" src="search/search.js"></script>
20 <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
21 <link href="doxygen.css" rel="stylesheet" type="text/css" />
22 <link href="normalise.css" rel="stylesheet" type="text/css"/>
23 <link href="main.css" rel="stylesheet" type="text/css"/>
24 <link href="styles.css" rel="stylesheet" type="text/css"/>
27 <div class="navigation-mobile">
28 <div class="logo--mobile">
29 <a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
31 <div class="navigation-toggle">
32 <span class="line-1"></span>
36 <span class="line-3"></span>
39 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
41 <a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
42 <span style="display: inline-block; margin-top: 10px;">
46 <div class="navigation-footer">
47 <img src="logo-mobile.svg" alt="Raspberry Pi">
48 <a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
50 <!-- <div class="search">
52 <input type="search" name="search" id="search" placeholder="Search">
53 <input type="submit" value="Search">
56 <!-- Generated by Doxygen 1.9.4 -->
57 <script type="text/javascript">
58 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
59 var searchBox = new SearchBox("searchBox", "search",'Search','.html');
62 <script type="text/javascript" src="menudata.js"></script>
63 <script type="text/javascript" src="menu.js"></script>
64 <script type="text/javascript">
65 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
67 initMenu('',true,false,'search.php','Search');
68 $(document).ready(function() { init_search(); });
72 <div id="main-nav"></div>
74 <div id="side-nav" class="ui-resizable side-nav-resizable">
76 <div id="nav-tree-contents">
77 <div id="nav-sync" class="sync"></div>
80 <div id="splitbar" style="-moz-user-select:none;"
81 class="ui-resizable-handle">
84 <script type="text/javascript">
85 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
86 $(document).ready(function(){initNavTree('pheap_8h.html',''); initResizable(); });
89 <div id="doc-content">
90 <!-- window showing the filter options -->
91 <div id="MSearchSelectWindow"
92 onmouseover="return searchBox.OnSearchSelectShow()"
93 onmouseout="return searchBox.OnSearchSelectHide()"
94 onkeydown="return searchBox.OnSearchSelectKey(event)">
97 <!-- iframe showing the search results (closed by default) -->
98 <div id="MSearchResultsWindow">
99 <iframe src="javascript:void(0)" frameborder="0"
100 name="MSearchResults" id="MSearchResults">
105 <div class="summary">
106 <a href="#nested-classes">Data Structures</a> |
107 <a href="#define-members">Macros</a> |
108 <a href="#typedef-members">Typedefs</a> |
109 <a href="#func-members">Functions</a> </div>
110 <div class="headertitle"><div class="title">pheap.h File Reference</div></div>
112 <div class="contents">
113 <div class="textblock"><code>#include "<a class="el" href="pico_8h_source.html">pico.h</a>"</code><br />
114 </div><div class="textblock"><div class="dynheader">
115 Include dependency graph for pheap.h:</div>
116 <div class="dyncontent">
117 <div class="center"><img src="pheap_8h__incl.png" border="0" usemap="#ainclude_2pico_2util_2pheap_8h" alt=""/></div>
118 <map name="ainclude_2pico_2util_2pheap_8h" id="ainclude_2pico_2util_2pheap_8h">
119 <area shape="rect" title=" " alt="" coords="351,5,533,32"/>
120 <area shape="rect" href="pico_8h.html" title=" " alt="" coords="411,80,473,107"/>
121 <area shape="rect" href="common_2pico__base__headers_2include_2pico_2types_8h_source.html" title=" " alt="" coords="158,304,259,331"/>
122 <area shape="rect" title=" " alt="" coords="252,155,365,181"/>
123 <area shape="rect" href="common_2pico__base__headers_2include_2pico_2config_8h_source.html" title=" " alt="" coords="390,155,494,181"/>
124 <area shape="rect" href="platform_8h.html" title=" " alt="" coords="596,155,717,181"/>
125 <area shape="rect" href="error_8h_source.html" title=" " alt="" coords="741,155,836,181"/>
126 <area shape="rect" href="assert_8h_source.html" title=" " alt="" coords="5,379,111,405"/>
127 <area shape="rect" title=" " alt="" coords="74,453,157,480"/>
128 <area shape="rect" title=" " alt="" coords="211,379,281,405"/>
129 <area shape="rect" title=" " alt="" coords="306,379,381,405"/>
130 <area shape="rect" title=" " alt="" coords="173,229,337,256"/>
131 <area shape="rect" href="compiler_8h_source.html" title=" " alt="" coords="362,229,543,256"/>
132 <area shape="rect" href="sections_8h_source.html" title=" " alt="" coords="567,229,746,256"/>
133 <area shape="rect" href="panic_8h_source.html" title=" " alt="" coords="770,229,930,256"/>
134 <area shape="rect" title=" " alt="" coords="954,229,1165,256"/>
135 <area shape="rect" title=" " alt="" coords="1189,229,1340,256"/>
136 <area shape="rect" title=" " alt="" coords="357,304,548,331"/>
140 <p><a href="pheap_8h_source.html">Go to the source code of this file.</a></p>
141 <table class="memberdecls">
142 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
143 Data Structures</h2></td></tr>
144 <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structpheap__node.html">pheap_node</a></td></tr>
145 <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
146 <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structpheap.html">pheap</a></td></tr>
147 <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
148 </table><table class="memberdecls">
149 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
150 Macros</h2></td></tr>
151 <tr class="memitem:a2c1ba272dbf334681e0858c6094f8cd9"><td class="memItemLeft" align="right" valign="top"><a id="a2c1ba272dbf334681e0858c6094f8cd9" name="a2c1ba272dbf334681e0858c6094f8cd9"></a>
152 #define </td><td class="memItemRight" valign="bottom"><b>PARAM_ASSERTIONS_ENABLED_PHEAP</b>   0</td></tr>
153 <tr class="separator:a2c1ba272dbf334681e0858c6094f8cd9"><td class="memSeparator" colspan="2"> </td></tr>
154 <tr class="memitem:afadcd7576ad42f9276fc1e83d642aad2"><td class="memItemLeft" align="right" valign="top"><a id="afadcd7576ad42f9276fc1e83d642aad2" name="afadcd7576ad42f9276fc1e83d642aad2"></a>
155 #define </td><td class="memItemRight" valign="bottom"><b>PICO_PHEAP_MAX_ENTRIES</b>   255</td></tr>
156 <tr class="separator:afadcd7576ad42f9276fc1e83d642aad2"><td class="memSeparator" colspan="2"> </td></tr>
157 <tr class="memitem:a9b69785185d58a5f82204c9ee3c2a2d5"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#a9b69785185d58a5f82204c9ee3c2a2d5">PHEAP_DEFINE_STATIC</a>(name, _max_nodes)</td></tr>
158 <tr class="memdesc:a9b69785185d58a5f82204c9ee3c2a2d5"><td class="mdescLeft"> </td><td class="mdescRight">Define a statically allocated pairing heap. This must be initialized by ph_post_alloc_init. <a href="pheap_8h.html#a9b69785185d58a5f82204c9ee3c2a2d5">More...</a><br /></td></tr>
159 <tr class="separator:a9b69785185d58a5f82204c9ee3c2a2d5"><td class="memSeparator" colspan="2"> </td></tr>
160 </table><table class="memberdecls">
161 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
162 Typedefs</h2></td></tr>
163 <tr class="memitem:a0692045973f15c3302c72f623244ed70"><td class="memItemLeft" align="right" valign="top"><a id="a0692045973f15c3302c72f623244ed70" name="a0692045973f15c3302c72f623244ed70"></a>
164 typedef uint8_t </td><td class="memItemRight" valign="bottom"><b>pheap_node_id_t</b></td></tr>
165 <tr class="separator:a0692045973f15c3302c72f623244ed70"><td class="memSeparator" colspan="2"> </td></tr>
166 <tr class="memitem:a55cc841f8c9956ab1facf0c150bcb81a"><td class="memItemLeft" align="right" valign="top"><a id="a55cc841f8c9956ab1facf0c150bcb81a" name="a55cc841f8c9956ab1facf0c150bcb81a"></a>
167 typedef struct <a class="el" href="structpheap__node.html">pheap_node</a> </td><td class="memItemRight" valign="bottom"><b>pheap_node_t</b></td></tr>
168 <tr class="separator:a55cc841f8c9956ab1facf0c150bcb81a"><td class="memSeparator" colspan="2"> </td></tr>
169 <tr class="memitem:a0656dff462e9c9b41b60b7c86ba39f09"><td class="memItemLeft" align="right" valign="top">typedef bool(* </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#a0656dff462e9c9b41b60b7c86ba39f09">pheap_comparator</a>) (void *user_data, pheap_node_id_t a, pheap_node_id_t b)</td></tr>
170 <tr class="memdesc:a0656dff462e9c9b41b60b7c86ba39f09"><td class="mdescLeft"> </td><td class="mdescRight">A user comparator function for nodes in a pairing heap. <a href="pheap_8h.html#a0656dff462e9c9b41b60b7c86ba39f09">More...</a><br /></td></tr>
171 <tr class="separator:a0656dff462e9c9b41b60b7c86ba39f09"><td class="memSeparator" colspan="2"> </td></tr>
172 <tr class="memitem:a08712072a1b1a0c405e0c1807357888f"><td class="memItemLeft" align="right" valign="top"><a id="a08712072a1b1a0c405e0c1807357888f" name="a08712072a1b1a0c405e0c1807357888f"></a>
173 typedef struct <a class="el" href="structpheap.html">pheap</a> </td><td class="memItemRight" valign="bottom"><b>pheap_t</b></td></tr>
174 <tr class="separator:a08712072a1b1a0c405e0c1807357888f"><td class="memSeparator" colspan="2"> </td></tr>
175 </table><table class="memberdecls">
176 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
177 Functions</h2></td></tr>
178 <tr class="memitem:acde2f3fabd67330b56dbb8473387b272"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structpheap.html">pheap_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#acde2f3fabd67330b56dbb8473387b272">ph_create</a> (uint max_nodes, <a class="el" href="pheap_8h.html#a0656dff462e9c9b41b60b7c86ba39f09">pheap_comparator</a> comparator, void *user_data)</td></tr>
179 <tr class="memdesc:acde2f3fabd67330b56dbb8473387b272"><td class="mdescLeft"> </td><td class="mdescRight">Create a pairing heap, which effectively maintains an efficient sorted ordering of nodes. The heap itself stores no user per-node state, it is expected that the user maintains a companion array. A comparator function must be provided so that the heap implementation can determine the relative ordering of nodes. <a href="pheap_8h.html#acde2f3fabd67330b56dbb8473387b272">More...</a><br /></td></tr>
180 <tr class="separator:acde2f3fabd67330b56dbb8473387b272"><td class="memSeparator" colspan="2"> </td></tr>
181 <tr class="memitem:a1fe718acebd018d31cab37071a65c61b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#a1fe718acebd018d31cab37071a65c61b">ph_clear</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap)</td></tr>
182 <tr class="memdesc:a1fe718acebd018d31cab37071a65c61b"><td class="mdescLeft"> </td><td class="mdescRight">Removes all nodes from the pairing heap. <a href="pheap_8h.html#a1fe718acebd018d31cab37071a65c61b">More...</a><br /></td></tr>
183 <tr class="separator:a1fe718acebd018d31cab37071a65c61b"><td class="memSeparator" colspan="2"> </td></tr>
184 <tr class="memitem:a0ad42a7be2446ffcdbce6c9c3590eb8e"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#a0ad42a7be2446ffcdbce6c9c3590eb8e">ph_destroy</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap)</td></tr>
185 <tr class="memdesc:a0ad42a7be2446ffcdbce6c9c3590eb8e"><td class="mdescLeft"> </td><td class="mdescRight">De-allocates a pairing heap. <a href="pheap_8h.html#a0ad42a7be2446ffcdbce6c9c3590eb8e">More...</a><br /></td></tr>
186 <tr class="separator:a0ad42a7be2446ffcdbce6c9c3590eb8e"><td class="memSeparator" colspan="2"> </td></tr>
187 <tr class="memitem:a93788bb2795becc23f12e268bdeea213"><td class="memItemLeft" align="right" valign="top"><a id="a93788bb2795becc23f12e268bdeea213" name="a93788bb2795becc23f12e268bdeea213"></a>
188 static <a class="el" href="structpheap__node.html">pheap_node_t</a> * </td><td class="memItemRight" valign="bottom"><b>ph_get_node</b> (<a class="el" href="structpheap.html">pheap_t</a> *heap, pheap_node_id_t id)</td></tr>
189 <tr class="separator:a93788bb2795becc23f12e268bdeea213"><td class="memSeparator" colspan="2"> </td></tr>
190 <tr class="memitem:a8a21f776fcd536ab440eed0651a93851"><td class="memItemLeft" align="right" valign="top"><a id="a8a21f776fcd536ab440eed0651a93851" name="a8a21f776fcd536ab440eed0651a93851"></a>
191 static void </td><td class="memItemRight" valign="bottom"><b>ph_add_child_node</b> (<a class="el" href="structpheap.html">pheap_t</a> *heap, pheap_node_id_t parent_id, pheap_node_id_t child_id)</td></tr>
192 <tr class="separator:a8a21f776fcd536ab440eed0651a93851"><td class="memSeparator" colspan="2"> </td></tr>
193 <tr class="memitem:ac62c59afb18a731e763149c20c03d224"><td class="memItemLeft" align="right" valign="top"><a id="ac62c59afb18a731e763149c20c03d224" name="ac62c59afb18a731e763149c20c03d224"></a>
194 static pheap_node_id_t </td><td class="memItemRight" valign="bottom"><b>ph_merge_nodes</b> (<a class="el" href="structpheap.html">pheap_t</a> *heap, pheap_node_id_t a, pheap_node_id_t b)</td></tr>
195 <tr class="separator:ac62c59afb18a731e763149c20c03d224"><td class="memSeparator" colspan="2"> </td></tr>
196 <tr class="memitem:af631622b2fe9dbd39f39d457eef502d0"><td class="memItemLeft" align="right" valign="top">static pheap_node_id_t </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#af631622b2fe9dbd39f39d457eef502d0">ph_new_node</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap)</td></tr>
197 <tr class="memdesc:af631622b2fe9dbd39f39d457eef502d0"><td class="mdescLeft"> </td><td class="mdescRight">Allocate a new node from the unused space in the heap. <a href="pheap_8h.html#af631622b2fe9dbd39f39d457eef502d0">More...</a><br /></td></tr>
198 <tr class="separator:af631622b2fe9dbd39f39d457eef502d0"><td class="memSeparator" colspan="2"> </td></tr>
199 <tr class="memitem:ab68363a744cae76cf6cce07fc60f4a5c"><td class="memItemLeft" align="right" valign="top">static pheap_node_id_t </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#ab68363a744cae76cf6cce07fc60f4a5c">ph_insert_node</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap, pheap_node_id_t id)</td></tr>
200 <tr class="memdesc:ab68363a744cae76cf6cce07fc60f4a5c"><td class="mdescLeft"> </td><td class="mdescRight">Inserts a node into the heap. <a href="pheap_8h.html#ab68363a744cae76cf6cce07fc60f4a5c">More...</a><br /></td></tr>
201 <tr class="separator:ab68363a744cae76cf6cce07fc60f4a5c"><td class="memSeparator" colspan="2"> </td></tr>
202 <tr class="memitem:a9723f40e88f36de3cd6cd955e3410600"><td class="memItemLeft" align="right" valign="top">static pheap_node_id_t </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#a9723f40e88f36de3cd6cd955e3410600">ph_peek_head</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap)</td></tr>
203 <tr class="memdesc:a9723f40e88f36de3cd6cd955e3410600"><td class="mdescLeft"> </td><td class="mdescRight">Returns the head node in the heap, i.e. the node which compares first, but without removing it from the heap. <a href="pheap_8h.html#a9723f40e88f36de3cd6cd955e3410600">More...</a><br /></td></tr>
204 <tr class="separator:a9723f40e88f36de3cd6cd955e3410600"><td class="memSeparator" colspan="2"> </td></tr>
205 <tr class="memitem:a8ebc494b4ad703fe080bee5f18775fec"><td class="memItemLeft" align="right" valign="top">pheap_node_id_t </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#a8ebc494b4ad703fe080bee5f18775fec">ph_remove_head</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap, bool free)</td></tr>
206 <tr class="memdesc:a8ebc494b4ad703fe080bee5f18775fec"><td class="mdescLeft"> </td><td class="mdescRight">Remove the head node from the pairing heap. This head node is the node which compares first in the logical ordering provided by the comparator. <a href="pheap_8h.html#a8ebc494b4ad703fe080bee5f18775fec">More...</a><br /></td></tr>
207 <tr class="separator:a8ebc494b4ad703fe080bee5f18775fec"><td class="memSeparator" colspan="2"> </td></tr>
208 <tr class="memitem:aee7c4944ce644b92572b48b7d14fc65e"><td class="memItemLeft" align="right" valign="top">static pheap_node_id_t </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#aee7c4944ce644b92572b48b7d14fc65e">ph_remove_and_free_head</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap)</td></tr>
209 <tr class="memdesc:aee7c4944ce644b92572b48b7d14fc65e"><td class="mdescLeft"> </td><td class="mdescRight">Remove the head node from the pairing heap. This head node is the node which compares first in the logical ordering provided by the comparator. <a href="pheap_8h.html#aee7c4944ce644b92572b48b7d14fc65e">More...</a><br /></td></tr>
210 <tr class="separator:aee7c4944ce644b92572b48b7d14fc65e"><td class="memSeparator" colspan="2"> </td></tr>
211 <tr class="memitem:a852301ee2d8d4c3985dd61c14eb820a8"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#a852301ee2d8d4c3985dd61c14eb820a8">ph_remove_and_free_node</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap, pheap_node_id_t id)</td></tr>
212 <tr class="memdesc:a852301ee2d8d4c3985dd61c14eb820a8"><td class="mdescLeft"> </td><td class="mdescRight">Remove and free an arbitrary node from the pairing heap. This is a more costly operation than removing the head via <a class="el" href="pheap_8h.html#aee7c4944ce644b92572b48b7d14fc65e" title="Remove the head node from the pairing heap. This head node is the node which compares first in the lo...">ph_remove_and_free_head()</a> <a href="pheap_8h.html#a852301ee2d8d4c3985dd61c14eb820a8">More...</a><br /></td></tr>
213 <tr class="separator:a852301ee2d8d4c3985dd61c14eb820a8"><td class="memSeparator" colspan="2"> </td></tr>
214 <tr class="memitem:a799a2b5a1db608401482816d371a02a5"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#a799a2b5a1db608401482816d371a02a5">ph_contains_node</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap, pheap_node_id_t id)</td></tr>
215 <tr class="memdesc:a799a2b5a1db608401482816d371a02a5"><td class="mdescLeft"> </td><td class="mdescRight">Determine if the heap contains a given node. Note containment refers to whether the node is inserted (<a class="el" href="pheap_8h.html#ab68363a744cae76cf6cce07fc60f4a5c" title="Inserts a node into the heap.">ph_insert_node()</a>) vs allocated (<a class="el" href="pheap_8h.html#af631622b2fe9dbd39f39d457eef502d0" title="Allocate a new node from the unused space in the heap.">ph_new_node()</a>) <a href="pheap_8h.html#a799a2b5a1db608401482816d371a02a5">More...</a><br /></td></tr>
216 <tr class="separator:a799a2b5a1db608401482816d371a02a5"><td class="memSeparator" colspan="2"> </td></tr>
217 <tr class="memitem:a16d2f59279aad9419ebab05bf15d70b2"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#a16d2f59279aad9419ebab05bf15d70b2">ph_free_node</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap, pheap_node_id_t id)</td></tr>
218 <tr class="memdesc:a16d2f59279aad9419ebab05bf15d70b2"><td class="mdescLeft"> </td><td class="mdescRight">Free a node that is not currently in the heap, but has been allocated. <a href="pheap_8h.html#a16d2f59279aad9419ebab05bf15d70b2">More...</a><br /></td></tr>
219 <tr class="separator:a16d2f59279aad9419ebab05bf15d70b2"><td class="memSeparator" colspan="2"> </td></tr>
220 <tr class="memitem:aaac9dd2a264364a16a5753ba08c268cf"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#aaac9dd2a264364a16a5753ba08c268cf">ph_dump</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap, void(*dump_key)(pheap_node_id_t id, void *user_data), void *user_data)</td></tr>
221 <tr class="memdesc:aaac9dd2a264364a16a5753ba08c268cf"><td class="mdescLeft"> </td><td class="mdescRight">Print a representation of the heap for debugging. <a href="pheap_8h.html#aaac9dd2a264364a16a5753ba08c268cf">More...</a><br /></td></tr>
222 <tr class="separator:aaac9dd2a264364a16a5753ba08c268cf"><td class="memSeparator" colspan="2"> </td></tr>
223 <tr class="memitem:a5f8a3b950288b90310216126750ae0ef"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="pheap_8h.html#a5f8a3b950288b90310216126750ae0ef">ph_post_alloc_init</a> (<a class="el" href="structpheap.html">pheap_t</a> *heap, uint max_nodes, <a class="el" href="pheap_8h.html#a0656dff462e9c9b41b60b7c86ba39f09">pheap_comparator</a> comparator, void *user_data)</td></tr>
224 <tr class="memdesc:a5f8a3b950288b90310216126750ae0ef"><td class="mdescLeft"> </td><td class="mdescRight">Initialize a statically allocated heap (<a class="el" href="pheap_8h.html#acde2f3fabd67330b56dbb8473387b272" title="Create a pairing heap, which effectively maintains an efficient sorted ordering of nodes....">ph_create()</a> using the C heap). The heap member <code>nodes</code> must be allocated of size max_nodes. <a href="pheap_8h.html#a5f8a3b950288b90310216126750ae0ef">More...</a><br /></td></tr>
225 <tr class="separator:a5f8a3b950288b90310216126750ae0ef"><td class="memSeparator" colspan="2"> </td></tr>
227 <h2 class="groupheader">Macro Definition Documentation</h2>
228 <a id="a9b69785185d58a5f82204c9ee3c2a2d5" name="a9b69785185d58a5f82204c9ee3c2a2d5"></a>
229 <h2 class="memtitle"><span class="permalink"><a href="#a9b69785185d58a5f82204c9ee3c2a2d5">◆ </a></span>PHEAP_DEFINE_STATIC</h2>
231 <div class="memitem">
232 <div class="memproto">
233 <table class="memname">
235 <td class="memname">#define PHEAP_DEFINE_STATIC</td>
237 <td class="paramtype"> </td>
238 <td class="paramname">name, </td>
241 <td class="paramkey"></td>
243 <td class="paramtype"> </td>
244 <td class="paramname">_max_nodes </td>
252 </div><div class="memdoc">
253 <b>Value:</b><div class="fragment"><div class="line"> <span class="keyword">static_assert</span>(_max_nodes && _max_nodes < (1u << (8 * <span class="keyword">sizeof</span>(pheap_node_id_t))), <span class="stringliteral">""</span>); \</div>
254 <div class="line"> static <a class="code hl_struct" href="structpheap__node.html">pheap_node_t</a> name ## _nodes[_max_nodes]; \</div>
255 <div class="line"> static <a class="code hl_struct" href="structpheap.html">pheap_t</a> name = { \</div>
256 <div class="line"> .nodes = name ## _nodes, \</div>
257 <div class="line"> .max_nodes = _max_nodes \</div>
258 <div class="line"> };</div>
259 <div class="ttc" id="astructpheap__node_html"><div class="ttname"><a href="structpheap__node.html">pheap_node</a></div><div class="ttdef"><b>Definition:</b> pheap.h:51</div></div>
260 <div class="ttc" id="astructpheap_html"><div class="ttname"><a href="structpheap.html">pheap</a></div><div class="ttdef"><b>Definition:</b> pheap.h:62</div></div>
261 </div><!-- fragment -->
262 <p>Define a statically allocated pairing heap. This must be initialized by ph_post_alloc_init. </p>
266 <h2 class="groupheader">Typedef Documentation</h2>
267 <a id="a0656dff462e9c9b41b60b7c86ba39f09" name="a0656dff462e9c9b41b60b7c86ba39f09"></a>
268 <h2 class="memtitle"><span class="permalink"><a href="#a0656dff462e9c9b41b60b7c86ba39f09">◆ </a></span>pheap_comparator</h2>
270 <div class="memitem">
271 <div class="memproto">
272 <table class="memname">
274 <td class="memname">typedef bool(* pheap_comparator) (void *user_data, pheap_node_id_t a, pheap_node_id_t b)</td>
277 </div><div class="memdoc">
279 <p>A user comparator function for nodes in a pairing heap. </p>
280 <dl class="section return"><dt>Returns</dt><dd>true if a < b in natural order. Note this relative ordering must be stable from call to call. </dd></dl>
284 <h2 class="groupheader">Function Documentation</h2>
285 <a id="a1fe718acebd018d31cab37071a65c61b" name="a1fe718acebd018d31cab37071a65c61b"></a>
286 <h2 class="memtitle"><span class="permalink"><a href="#a1fe718acebd018d31cab37071a65c61b">◆ </a></span>ph_clear()</h2>
288 <div class="memitem">
289 <div class="memproto">
290 <table class="memname">
292 <td class="memname">void ph_clear </td>
294 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
295 <td class="paramname"><em>heap</em></td><td>)</td>
299 </div><div class="memdoc">
301 <p>Removes all nodes from the pairing heap. </p>
302 <dl class="params"><dt>Parameters</dt><dd>
303 <table class="params">
304 <tr><td class="paramname">heap</td><td>the heap </td></tr>
311 <a id="a799a2b5a1db608401482816d371a02a5" name="a799a2b5a1db608401482816d371a02a5"></a>
312 <h2 class="memtitle"><span class="permalink"><a href="#a799a2b5a1db608401482816d371a02a5">◆ </a></span>ph_contains_node()</h2>
314 <div class="memitem">
315 <div class="memproto">
316 <table class="mlabels">
318 <td class="mlabels-left">
319 <table class="memname">
321 <td class="memname">static bool ph_contains_node </td>
323 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
324 <td class="paramname"><em>heap</em>, </td>
327 <td class="paramkey"></td>
329 <td class="paramtype">pheap_node_id_t </td>
330 <td class="paramname"><em>id</em> </td>
339 <td class="mlabels-right">
340 <span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span> </td>
343 </div><div class="memdoc">
345 <p>Determine if the heap contains a given node. Note containment refers to whether the node is inserted (<a class="el" href="pheap_8h.html#ab68363a744cae76cf6cce07fc60f4a5c" title="Inserts a node into the heap.">ph_insert_node()</a>) vs allocated (<a class="el" href="pheap_8h.html#af631622b2fe9dbd39f39d457eef502d0" title="Allocate a new node from the unused space in the heap.">ph_new_node()</a>) </p>
346 <dl class="params"><dt>Parameters</dt><dd>
347 <table class="params">
348 <tr><td class="paramname">heap</td><td>the heap </td></tr>
349 <tr><td class="paramname">id</td><td>the id of the node </td></tr>
353 <dl class="section return"><dt>Returns</dt><dd>true if the heap contains a node with the given id, false otherwise. </dd></dl>
357 <a id="acde2f3fabd67330b56dbb8473387b272" name="acde2f3fabd67330b56dbb8473387b272"></a>
358 <h2 class="memtitle"><span class="permalink"><a href="#acde2f3fabd67330b56dbb8473387b272">◆ </a></span>ph_create()</h2>
360 <div class="memitem">
361 <div class="memproto">
362 <table class="memname">
364 <td class="memname"><a class="el" href="structpheap.html">pheap_t</a> * ph_create </td>
366 <td class="paramtype">uint </td>
367 <td class="paramname"><em>max_nodes</em>, </td>
370 <td class="paramkey"></td>
372 <td class="paramtype"><a class="el" href="pheap_8h.html#a0656dff462e9c9b41b60b7c86ba39f09">pheap_comparator</a> </td>
373 <td class="paramname"><em>comparator</em>, </td>
376 <td class="paramkey"></td>
378 <td class="paramtype">void * </td>
379 <td class="paramname"><em>user_data</em> </td>
387 </div><div class="memdoc">
389 <p>Create a pairing heap, which effectively maintains an efficient sorted ordering of nodes. The heap itself stores no user per-node state, it is expected that the user maintains a companion array. A comparator function must be provided so that the heap implementation can determine the relative ordering of nodes. </p>
390 <dl class="params"><dt>Parameters</dt><dd>
391 <table class="params">
392 <tr><td class="paramname">max_nodes</td><td>the maximum number of nodes that may be in the heap (this is bounded by PICO_PHEAP_MAX_ENTRIES which defaults to 255 to be able to store indexes in a single byte). </td></tr>
393 <tr><td class="paramname">comparator</td><td>the node comparison function </td></tr>
394 <tr><td class="paramname">user_data</td><td>a user data pointer associated with the heap that is provided in callbacks </td></tr>
398 <dl class="section return"><dt>Returns</dt><dd>a newly allocated and initialized heap </dd></dl>
402 <a id="a0ad42a7be2446ffcdbce6c9c3590eb8e" name="a0ad42a7be2446ffcdbce6c9c3590eb8e"></a>
403 <h2 class="memtitle"><span class="permalink"><a href="#a0ad42a7be2446ffcdbce6c9c3590eb8e">◆ </a></span>ph_destroy()</h2>
405 <div class="memitem">
406 <div class="memproto">
407 <table class="memname">
409 <td class="memname">void ph_destroy </td>
411 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
412 <td class="paramname"><em>heap</em></td><td>)</td>
416 </div><div class="memdoc">
418 <p>De-allocates a pairing heap. </p>
419 <p >Note this method must <em>ONLY</em> be called on heaps created by <a class="el" href="pheap_8h.html#acde2f3fabd67330b56dbb8473387b272" title="Create a pairing heap, which effectively maintains an efficient sorted ordering of nodes....">ph_create()</a> </p><dl class="params"><dt>Parameters</dt><dd>
420 <table class="params">
421 <tr><td class="paramname">heap</td><td>the heap </td></tr>
428 <a id="aaac9dd2a264364a16a5753ba08c268cf" name="aaac9dd2a264364a16a5753ba08c268cf"></a>
429 <h2 class="memtitle"><span class="permalink"><a href="#aaac9dd2a264364a16a5753ba08c268cf">◆ </a></span>ph_dump()</h2>
431 <div class="memitem">
432 <div class="memproto">
433 <table class="memname">
435 <td class="memname">void ph_dump </td>
437 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
438 <td class="paramname"><em>heap</em>, </td>
441 <td class="paramkey"></td>
443 <td class="paramtype">void(*)(pheap_node_id_t id, void *user_data) </td>
444 <td class="paramname"><em>dump_key</em>, </td>
447 <td class="paramkey"></td>
449 <td class="paramtype">void * </td>
450 <td class="paramname"><em>user_data</em> </td>
458 </div><div class="memdoc">
460 <p>Print a representation of the heap for debugging. </p>
461 <dl class="params"><dt>Parameters</dt><dd>
462 <table class="params">
463 <tr><td class="paramname">heap</td><td>the heap </td></tr>
464 <tr><td class="paramname">dump_key</td><td>a method to print a node value </td></tr>
465 <tr><td class="paramname">user_data</td><td>the user data to pass to the dump_key method </td></tr>
472 <a id="a16d2f59279aad9419ebab05bf15d70b2" name="a16d2f59279aad9419ebab05bf15d70b2"></a>
473 <h2 class="memtitle"><span class="permalink"><a href="#a16d2f59279aad9419ebab05bf15d70b2">◆ </a></span>ph_free_node()</h2>
475 <div class="memitem">
476 <div class="memproto">
477 <table class="mlabels">
479 <td class="mlabels-left">
480 <table class="memname">
482 <td class="memname">static void ph_free_node </td>
484 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
485 <td class="paramname"><em>heap</em>, </td>
488 <td class="paramkey"></td>
490 <td class="paramtype">pheap_node_id_t </td>
491 <td class="paramname"><em>id</em> </td>
500 <td class="mlabels-right">
501 <span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span> </td>
504 </div><div class="memdoc">
506 <p>Free a node that is not currently in the heap, but has been allocated. </p>
507 <dl class="params"><dt>Parameters</dt><dd>
508 <table class="params">
509 <tr><td class="paramname">heap</td><td>the heap </td></tr>
510 <tr><td class="paramname">id</td><td>the id of the node </td></tr>
517 <a id="ab68363a744cae76cf6cce07fc60f4a5c" name="ab68363a744cae76cf6cce07fc60f4a5c"></a>
518 <h2 class="memtitle"><span class="permalink"><a href="#ab68363a744cae76cf6cce07fc60f4a5c">◆ </a></span>ph_insert_node()</h2>
520 <div class="memitem">
521 <div class="memproto">
522 <table class="mlabels">
524 <td class="mlabels-left">
525 <table class="memname">
527 <td class="memname">static pheap_node_id_t ph_insert_node </td>
529 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
530 <td class="paramname"><em>heap</em>, </td>
533 <td class="paramkey"></td>
535 <td class="paramtype">pheap_node_id_t </td>
536 <td class="paramname"><em>id</em> </td>
545 <td class="mlabels-right">
546 <span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span> </td>
549 </div><div class="memdoc">
551 <p>Inserts a node into the heap. </p>
552 <p >This method inserts a node (previously allocated by <a class="el" href="pheap_8h.html#af631622b2fe9dbd39f39d457eef502d0" title="Allocate a new node from the unused space in the heap.">ph_new_node()</a>) into the heap, determining the correct order by calling the heap's comparator</p>
553 <dl class="params"><dt>Parameters</dt><dd>
554 <table class="params">
555 <tr><td class="paramname">heap</td><td>the heap </td></tr>
556 <tr><td class="paramname">id</td><td>the id of the node to insert </td></tr>
560 <dl class="section return"><dt>Returns</dt><dd>the id of the new head of the pairing heap (i.e. node that compares first) </dd></dl>
564 <a id="af631622b2fe9dbd39f39d457eef502d0" name="af631622b2fe9dbd39f39d457eef502d0"></a>
565 <h2 class="memtitle"><span class="permalink"><a href="#af631622b2fe9dbd39f39d457eef502d0">◆ </a></span>ph_new_node()</h2>
567 <div class="memitem">
568 <div class="memproto">
569 <table class="mlabels">
571 <td class="mlabels-left">
572 <table class="memname">
574 <td class="memname">static pheap_node_id_t ph_new_node </td>
576 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
577 <td class="paramname"><em>heap</em></td><td>)</td>
582 <td class="mlabels-right">
583 <span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span> </td>
586 </div><div class="memdoc">
588 <p>Allocate a new node from the unused space in the heap. </p>
589 <dl class="params"><dt>Parameters</dt><dd>
590 <table class="params">
591 <tr><td class="paramname">heap</td><td>the heap </td></tr>
595 <dl class="section return"><dt>Returns</dt><dd>an identifier for the node, or 0 if the heap is full </dd></dl>
599 <a id="a9723f40e88f36de3cd6cd955e3410600" name="a9723f40e88f36de3cd6cd955e3410600"></a>
600 <h2 class="memtitle"><span class="permalink"><a href="#a9723f40e88f36de3cd6cd955e3410600">◆ </a></span>ph_peek_head()</h2>
602 <div class="memitem">
603 <div class="memproto">
604 <table class="mlabels">
606 <td class="mlabels-left">
607 <table class="memname">
609 <td class="memname">static pheap_node_id_t ph_peek_head </td>
611 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
612 <td class="paramname"><em>heap</em></td><td>)</td>
617 <td class="mlabels-right">
618 <span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span> </td>
621 </div><div class="memdoc">
623 <p>Returns the head node in the heap, i.e. the node which compares first, but without removing it from the heap. </p>
624 <dl class="params"><dt>Parameters</dt><dd>
625 <table class="params">
626 <tr><td class="paramname">heap</td><td>the heap </td></tr>
630 <dl class="section return"><dt>Returns</dt><dd>the current head node id </dd></dl>
634 <a id="a5f8a3b950288b90310216126750ae0ef" name="a5f8a3b950288b90310216126750ae0ef"></a>
635 <h2 class="memtitle"><span class="permalink"><a href="#a5f8a3b950288b90310216126750ae0ef">◆ </a></span>ph_post_alloc_init()</h2>
637 <div class="memitem">
638 <div class="memproto">
639 <table class="memname">
641 <td class="memname">void ph_post_alloc_init </td>
643 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
644 <td class="paramname"><em>heap</em>, </td>
647 <td class="paramkey"></td>
649 <td class="paramtype">uint </td>
650 <td class="paramname"><em>max_nodes</em>, </td>
653 <td class="paramkey"></td>
655 <td class="paramtype"><a class="el" href="pheap_8h.html#a0656dff462e9c9b41b60b7c86ba39f09">pheap_comparator</a> </td>
656 <td class="paramname"><em>comparator</em>, </td>
659 <td class="paramkey"></td>
661 <td class="paramtype">void * </td>
662 <td class="paramname"><em>user_data</em> </td>
670 </div><div class="memdoc">
672 <p>Initialize a statically allocated heap (<a class="el" href="pheap_8h.html#acde2f3fabd67330b56dbb8473387b272" title="Create a pairing heap, which effectively maintains an efficient sorted ordering of nodes....">ph_create()</a> using the C heap). The heap member <code>nodes</code> must be allocated of size max_nodes. </p>
673 <dl class="params"><dt>Parameters</dt><dd>
674 <table class="params">
675 <tr><td class="paramname">heap</td><td>the heap </td></tr>
676 <tr><td class="paramname">max_nodes</td><td>the max number of nodes in the heap (matching the size of the heap's nodes array) </td></tr>
677 <tr><td class="paramname">comparator</td><td>the comparator for the heap </td></tr>
678 <tr><td class="paramname">user_data</td><td>the user data for the heap. </td></tr>
685 <a id="aee7c4944ce644b92572b48b7d14fc65e" name="aee7c4944ce644b92572b48b7d14fc65e"></a>
686 <h2 class="memtitle"><span class="permalink"><a href="#aee7c4944ce644b92572b48b7d14fc65e">◆ </a></span>ph_remove_and_free_head()</h2>
688 <div class="memitem">
689 <div class="memproto">
690 <table class="mlabels">
692 <td class="mlabels-left">
693 <table class="memname">
695 <td class="memname">static pheap_node_id_t ph_remove_and_free_head </td>
697 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
698 <td class="paramname"><em>heap</em></td><td>)</td>
703 <td class="mlabels-right">
704 <span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span> </td>
707 </div><div class="memdoc">
709 <p>Remove the head node from the pairing heap. This head node is the node which compares first in the logical ordering provided by the comparator. </p>
710 <p >Note that the returned id will be freed, and thus may be re-used by future node allocations, so the caller should retrieve any per node state from the companion array before modifying the heap further.</p>
711 <dl class="params"><dt>Parameters</dt><dd>
712 <table class="params">
713 <tr><td class="paramname">heap</td><td>the heap </td></tr>
717 <dl class="section return"><dt>Returns</dt><dd>the old head node id. </dd></dl>
721 <a id="a852301ee2d8d4c3985dd61c14eb820a8" name="a852301ee2d8d4c3985dd61c14eb820a8"></a>
722 <h2 class="memtitle"><span class="permalink"><a href="#a852301ee2d8d4c3985dd61c14eb820a8">◆ </a></span>ph_remove_and_free_node()</h2>
724 <div class="memitem">
725 <div class="memproto">
726 <table class="memname">
728 <td class="memname">bool ph_remove_and_free_node </td>
730 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
731 <td class="paramname"><em>heap</em>, </td>
734 <td class="paramkey"></td>
736 <td class="paramtype">pheap_node_id_t </td>
737 <td class="paramname"><em>id</em> </td>
745 </div><div class="memdoc">
747 <p>Remove and free an arbitrary node from the pairing heap. This is a more costly operation than removing the head via <a class="el" href="pheap_8h.html#aee7c4944ce644b92572b48b7d14fc65e" title="Remove the head node from the pairing heap. This head node is the node which compares first in the lo...">ph_remove_and_free_head()</a> </p>
748 <dl class="params"><dt>Parameters</dt><dd>
749 <table class="params">
750 <tr><td class="paramname">heap</td><td>the heap </td></tr>
751 <tr><td class="paramname">id</td><td>the id of the node to free </td></tr>
755 <dl class="section return"><dt>Returns</dt><dd>true if the the node was in the heap, false otherwise </dd></dl>
759 <a id="a8ebc494b4ad703fe080bee5f18775fec" name="a8ebc494b4ad703fe080bee5f18775fec"></a>
760 <h2 class="memtitle"><span class="permalink"><a href="#a8ebc494b4ad703fe080bee5f18775fec">◆ </a></span>ph_remove_head()</h2>
762 <div class="memitem">
763 <div class="memproto">
764 <table class="memname">
766 <td class="memname">pheap_node_id_t ph_remove_head </td>
768 <td class="paramtype"><a class="el" href="structpheap.html">pheap_t</a> * </td>
769 <td class="paramname"><em>heap</em>, </td>
772 <td class="paramkey"></td>
774 <td class="paramtype">bool </td>
775 <td class="paramname"><em>free</em> </td>
783 </div><div class="memdoc">
785 <p>Remove the head node from the pairing heap. This head node is the node which compares first in the logical ordering provided by the comparator. </p>
786 <p >Note that in the case of free == true, the returned id is no longer allocated and may be re-used by future node allocations, so the caller should retrieve any per node state from the companion array before modifying the heap further.</p>
787 <dl class="params"><dt>Parameters</dt><dd>
788 <table class="params">
789 <tr><td class="paramname">heap</td><td>the heap </td></tr>
790 <tr><td class="paramname">free</td><td>true if the id is also to be freed; false if not - useful if the caller may wish to re-insert an item with the same id) </td></tr>
794 <dl class="section return"><dt>Returns</dt><dd>the old head node id. </dd></dl>
798 </div><!-- contents -->
799 </div><!-- doc-content -->
801 <script src="main.js"></script>