a00006.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
  5. <title>GTL - Graph Template Library: bin_heap&lt; T, Pred &gt; Class Template Reference</title>
  6. <link href="doxygen.css" rel="stylesheet" type="text/css">
  7. </head>
  8. <body>
  9. <p class="links">
  10. <a href="../index.html">Home</a> |
  11. Documentation |
  12. <a href="../register.html">Download</a> |
  13. <a href="../platforms.html">Platforms</a> |
  14. <a href="../refer.html">Projects</a> |
  15. <a href="../lists.html">Mailing Lists</a> |
  16. <a href="../history.html">Version History</a>
  17. </p>
  18. <!-- Generated by Doxygen 1.5.3 -->
  19. <div class="tabs">
  20. <ul>
  21. <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
  22. <li class="current"><a href="classes.html"><span>Classes</span></a></li>
  23. <li><a href="files.html"><span>Files</span></a></li>
  24. <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  25. </ul>
  26. </div>
  27. <div class="tabs">
  28. <ul>
  29. <li><a href="classes.html"><span>Alphabetical&nbsp;List</span></a></li>
  30. <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
  31. <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
  32. <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
  33. </ul>
  34. </div>
  35. <h1>bin_heap&lt; T, Pred &gt; Class Template Reference</h1><!-- doxytag: class="bin_heap" -->Binary heap.
  36. <a href="#_details">More...</a>
  37. <p>
  38. <p>
  39. <a href="a00125.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
  40. <tr><td></td></tr>
  41. <tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
  42. <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00006.html#9de42b60fac4b0d38aa738522eb7c4cd">bin_heap</a> (const Pred &amp;prd)</td></tr>
  43. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Creates empty binary heap. <a href="#9de42b60fac4b0d38aa738522eb7c4cd"></a><br></td></tr>
  44. <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00006.html#b911dd559d9d9fd665b9fdf2d8202bb8">bin_heap</a> (const Pred &amp;prd, const int est_size)</td></tr>
  45. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Creates empty binary heap. <a href="#b911dd559d9d9fd665b9fdf2d8202bb8"></a><br></td></tr>
  46. <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00006.html#19bd4241e097852ffda83b72557ffbdc">bin_heap</a> (const <a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt; &amp;bh)</td></tr>
  47. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Copy constructor. <a href="#19bd4241e097852ffda83b72557ffbdc"></a><br></td></tr>
  48. <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt; &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00006.html#d31b6806316a272686015fcbf5f633cd">operator=</a> (const <a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt; &amp;bh)</td></tr>
  49. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Assigns <code>bh</code> to this binary heap. <a href="#d31b6806316a272686015fcbf5f633cd"></a><br></td></tr>
  50. <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="5283db56783a84ee28dea9d393acf905"></a><!-- doxytag: member="bin_heap::~bin_heap" ref="5283db56783a84ee28dea9d393acf905" args="()" -->
  51. &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00006.html#5283db56783a84ee28dea9d393acf905">~bin_heap</a> ()</td></tr>
  52. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destructor. <br></td></tr>
  53. <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00006.html#6d658d61533e66cf83dce2f8e35bed17">push</a> (const T &amp;ins)</td></tr>
  54. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Inserts <code>ins</code> in heap. <a href="#6d658d61533e66cf83dce2f8e35bed17"></a><br></td></tr>
  55. <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="b463bc655b2f46cd5ff021cab28b1210"></a><!-- doxytag: member="bin_heap::pop" ref="b463bc655b2f46cd5ff021cab28b1210" args="()" -->
  56. void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00006.html#b463bc655b2f46cd5ff021cab28b1210">pop</a> ()</td></tr>
  57. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Removes the element on top of the heap. <br></td></tr>
  58. <tr><td class="memItemLeft" nowrap align="right" valign="top">const T &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00006.html#09924a9669f054bc6fdcf2dc5637f7f3">top</a> () const </td></tr>
  59. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns a reference to the element at the top of the heap. <a href="#09924a9669f054bc6fdcf2dc5637f7f3"></a><br></td></tr>
  60. <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00006.html#b1353fe40c5cfc1205314a4db6334f1b">changeKey</a> (const T &amp;cha)</td></tr>
  61. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Reconstructs heap condition after changing key value of <code>cha</code> externally. <a href="#b1353fe40c5cfc1205314a4db6334f1b"></a><br></td></tr>
  62. <tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00006.html#6c6f5bf251a2a85ebdd1a1730eb7934d">is_empty</a> () const </td></tr>
  63. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Checks if heap is empty. <a href="#6c6f5bf251a2a85ebdd1a1730eb7934d"></a><br></td></tr>
  64. </table>
  65. <hr><a name="_details"></a><h2>Detailed Description</h2>
  66. <h3>template&lt;class T, class Pred&gt;<br>
  67. class bin_heap&lt; T, Pred &gt;</h3>
  68. Binary heap.
  69. <p>
  70. <dl class="author" compact><dt><b>Author:</b></dt><dd>Christian Bachmaier <a href="mailto:chris@infosun.fmi.uni-passau.de">chris@infosun.fmi.uni-passau.de</a> </dd></dl>
  71. <hr><h2>Constructor &amp; Destructor Documentation</h2>
  72. <a class="anchor" name="9de42b60fac4b0d38aa738522eb7c4cd"></a><!-- doxytag: member="bin_heap::bin_heap" ref="9de42b60fac4b0d38aa738522eb7c4cd" args="(const Pred &amp;prd)" -->
  73. <div class="memitem">
  74. <div class="memproto">
  75. <div class="memtemplate">
  76. template&lt;class T, class Pred&gt; </div>
  77. <table class="memname">
  78. <tr>
  79. <td class="memname"><a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt;::<a class="el" href="a00006.html">bin_heap</a> </td>
  80. <td>(</td>
  81. <td class="paramtype">const Pred &amp;&nbsp;</td>
  82. <td class="paramname"> <em>prd</em> </td>
  83. <td>&nbsp;)&nbsp;</td>
  84. <td width="100%"><code> [inline]</code></td>
  85. </tr>
  86. </table>
  87. </div>
  88. <div class="memdoc">
  89. <p>
  90. Creates empty binary heap.
  91. <p>
  92. <dl compact><dt><b>Parameters:</b></dt><dd>
  93. <table border="0" cellspacing="2" cellpadding="0">
  94. <tr><td valign="top"></td><td valign="top"><em>prd</em>&nbsp;</td><td>binary predicate to compare two <code>T</code>s </td></tr>
  95. </table>
  96. </dl>
  97. </div>
  98. </div><p>
  99. <a class="anchor" name="b911dd559d9d9fd665b9fdf2d8202bb8"></a><!-- doxytag: member="bin_heap::bin_heap" ref="b911dd559d9d9fd665b9fdf2d8202bb8" args="(const Pred &amp;prd, const int est_size)" -->
  100. <div class="memitem">
  101. <div class="memproto">
  102. <div class="memtemplate">
  103. template&lt;class T, class Pred&gt; </div>
  104. <table class="memname">
  105. <tr>
  106. <td class="memname"><a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt;::<a class="el" href="a00006.html">bin_heap</a> </td>
  107. <td>(</td>
  108. <td class="paramtype">const Pred &amp;&nbsp;</td>
  109. <td class="paramname"> <em>prd</em>, </td>
  110. </tr>
  111. <tr>
  112. <td class="paramkey"></td>
  113. <td></td>
  114. <td class="paramtype">const int&nbsp;</td>
  115. <td class="paramname"> <em>est_size</em></td><td>&nbsp;</td>
  116. </tr>
  117. <tr>
  118. <td></td>
  119. <td>)</td>
  120. <td></td><td></td><td width="100%"><code> [inline]</code></td>
  121. </tr>
  122. </table>
  123. </div>
  124. <div class="memdoc">
  125. <p>
  126. Creates empty binary heap.
  127. <p>
  128. <dl compact><dt><b>Parameters:</b></dt><dd>
  129. <table border="0" cellspacing="2" cellpadding="0">
  130. <tr><td valign="top"></td><td valign="top"><em>prd</em>&nbsp;</td><td>binary predicate to compare two <code>Ts</code> </td></tr>
  131. <tr><td valign="top"></td><td valign="top"><em>est_size</em>&nbsp;</td><td>estimated maximal size of heap </td></tr>
  132. </table>
  133. </dl>
  134. </div>
  135. </div><p>
  136. <a class="anchor" name="19bd4241e097852ffda83b72557ffbdc"></a><!-- doxytag: member="bin_heap::bin_heap" ref="19bd4241e097852ffda83b72557ffbdc" args="(const bin_heap&lt; T, Pred &gt; &amp;bh)" -->
  137. <div class="memitem">
  138. <div class="memproto">
  139. <div class="memtemplate">
  140. template&lt;class T, class Pred&gt; </div>
  141. <table class="memname">
  142. <tr>
  143. <td class="memname"><a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt;::<a class="el" href="a00006.html">bin_heap</a> </td>
  144. <td>(</td>
  145. <td class="paramtype">const <a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt; &amp;&nbsp;</td>
  146. <td class="paramname"> <em>bh</em> </td>
  147. <td>&nbsp;)&nbsp;</td>
  148. <td width="100%"><code> [inline]</code></td>
  149. </tr>
  150. </table>
  151. </div>
  152. <div class="memdoc">
  153. <p>
  154. Copy constructor.
  155. <p>
  156. <dl compact><dt><b>Parameters:</b></dt><dd>
  157. <table border="0" cellspacing="2" cellpadding="0">
  158. <tr><td valign="top"></td><td valign="top"><em>bh</em>&nbsp;</td><td>binary heap to copy </td></tr>
  159. </table>
  160. </dl>
  161. </div>
  162. </div><p>
  163. <hr><h2>Member Function Documentation</h2>
  164. <a class="anchor" name="d31b6806316a272686015fcbf5f633cd"></a><!-- doxytag: member="bin_heap::operator=" ref="d31b6806316a272686015fcbf5f633cd" args="(const bin_heap&lt; T, Pred &gt; &amp;bh)" -->
  165. <div class="memitem">
  166. <div class="memproto">
  167. <div class="memtemplate">
  168. template&lt;class T, class Pred&gt; </div>
  169. <table class="memname">
  170. <tr>
  171. <td class="memname"><a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt; &amp; <a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt;::operator= </td>
  172. <td>(</td>
  173. <td class="paramtype">const <a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt; &amp;&nbsp;</td>
  174. <td class="paramname"> <em>bh</em> </td>
  175. <td>&nbsp;)&nbsp;</td>
  176. <td width="100%"><code> [inline]</code></td>
  177. </tr>
  178. </table>
  179. </div>
  180. <div class="memdoc">
  181. <p>
  182. Assigns <code>bh</code> to this binary heap.
  183. <p>
  184. All elements in this heap will be deleted. The predicate of this heap must be physically the same as the one of <code>bh</code>.<p>
  185. <dl compact><dt><b>Parameters:</b></dt><dd>
  186. <table border="0" cellspacing="2" cellpadding="0">
  187. <tr><td valign="top"></td><td valign="top"><em>bh</em>&nbsp;</td><td>binary heap</td></tr>
  188. </table>
  189. </dl>
  190. <dl class="return" compact><dt><b>Returns:</b></dt><dd>this heap </dd></dl>
  191. </div>
  192. </div><p>
  193. <a class="anchor" name="6d658d61533e66cf83dce2f8e35bed17"></a><!-- doxytag: member="bin_heap::push" ref="6d658d61533e66cf83dce2f8e35bed17" args="(const T &amp;ins)" -->
  194. <div class="memitem">
  195. <div class="memproto">
  196. <div class="memtemplate">
  197. template&lt;class T, class Pred&gt; </div>
  198. <table class="memname">
  199. <tr>
  200. <td class="memname">void <a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt;::push </td>
  201. <td>(</td>
  202. <td class="paramtype">const T &amp;&nbsp;</td>
  203. <td class="paramname"> <em>ins</em> </td>
  204. <td>&nbsp;)&nbsp;</td>
  205. <td width="100%"><code> [inline]</code></td>
  206. </tr>
  207. </table>
  208. </div>
  209. <div class="memdoc">
  210. <p>
  211. Inserts <code>ins</code> in heap.
  212. <p>
  213. <dl compact><dt><b>Parameters:</b></dt><dd>
  214. <table border="0" cellspacing="2" cellpadding="0">
  215. <tr><td valign="top"></td><td valign="top"><em>ins</em>&nbsp;</td><td>data element to be inserted </td></tr>
  216. </table>
  217. </dl>
  218. </div>
  219. </div><p>
  220. <a class="anchor" name="09924a9669f054bc6fdcf2dc5637f7f3"></a><!-- doxytag: member="bin_heap::top" ref="09924a9669f054bc6fdcf2dc5637f7f3" args="() const " -->
  221. <div class="memitem">
  222. <div class="memproto">
  223. <div class="memtemplate">
  224. template&lt;class T, class Pred&gt; </div>
  225. <table class="memname">
  226. <tr>
  227. <td class="memname">const T &amp; <a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt;::top </td>
  228. <td>(</td>
  229. <td class="paramname"> </td>
  230. <td>&nbsp;)&nbsp;</td>
  231. <td width="100%"> const<code> [inline]</code></td>
  232. </tr>
  233. </table>
  234. </div>
  235. <div class="memdoc">
  236. <p>
  237. Returns a reference to the element at the top of the heap.
  238. <p>
  239. <dl class="return" compact><dt><b>Returns:</b></dt><dd>top element of the heap </dd></dl>
  240. </div>
  241. </div><p>
  242. <a class="anchor" name="b1353fe40c5cfc1205314a4db6334f1b"></a><!-- doxytag: member="bin_heap::changeKey" ref="b1353fe40c5cfc1205314a4db6334f1b" args="(const T &amp;cha)" -->
  243. <div class="memitem">
  244. <div class="memproto">
  245. <div class="memtemplate">
  246. template&lt;class T, class Pred&gt; </div>
  247. <table class="memname">
  248. <tr>
  249. <td class="memname">void <a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt;::changeKey </td>
  250. <td>(</td>
  251. <td class="paramtype">const T &amp;&nbsp;</td>
  252. <td class="paramname"> <em>cha</em> </td>
  253. <td>&nbsp;)&nbsp;</td>
  254. <td width="100%"><code> [inline]</code></td>
  255. </tr>
  256. </table>
  257. </div>
  258. <div class="memdoc">
  259. <p>
  260. Reconstructs heap condition after changing key value of <code>cha</code> externally.
  261. <p>
  262. <dl compact><dt><b>Parameters:</b></dt><dd>
  263. <table border="0" cellspacing="2" cellpadding="0">
  264. <tr><td valign="top"></td><td valign="top"><em>cha</em>&nbsp;</td><td>element with changed key value</td></tr>
  265. </table>
  266. </dl>
  267. <dl class="note" compact><dt><b>Note:</b></dt><dd><code>changeKey</code> doesn't operate if <code>cha</code> is a primitive data structure, because it represents its key value itself, or if one object is stored more than once in the data structure.</dd></dl>
  268. <dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="a00009.html" title="Dijkstra&#39;s Algorithm for computing single source shortest path.">dijkstra</a> </dd></dl>
  269. </div>
  270. </div><p>
  271. <a class="anchor" name="6c6f5bf251a2a85ebdd1a1730eb7934d"></a><!-- doxytag: member="bin_heap::is_empty" ref="6c6f5bf251a2a85ebdd1a1730eb7934d" args="() const " -->
  272. <div class="memitem">
  273. <div class="memproto">
  274. <div class="memtemplate">
  275. template&lt;class T, class Pred&gt; </div>
  276. <table class="memname">
  277. <tr>
  278. <td class="memname">bool <a class="el" href="a00006.html">bin_heap</a>&lt; T, Pred &gt;::is_empty </td>
  279. <td>(</td>
  280. <td class="paramname"> </td>
  281. <td>&nbsp;)&nbsp;</td>
  282. <td width="100%"> const<code> [inline]</code></td>
  283. </tr>
  284. </table>
  285. </div>
  286. <div class="memdoc">
  287. <p>
  288. Checks if heap is empty.
  289. <p>
  290. <dl class="return" compact><dt><b>Returns:</b></dt><dd><code>true</code> iff empty </dd></dl>
  291. </div>
  292. </div><p>
  293. <p class="links">
  294. <a href="http://www.uni-passau.de/">University of Passau</a>
  295. &nbsp;-&nbsp;
  296. <a href="http://www.fmi.uni-passau.de/">FMI</a>
  297. &nbsp;-&nbsp;
  298. <a href="http://www.fmi.uni-passau.de/fmi/lehrstuehle/brandenburg/">Theoretical
  299. Computer Science</a>
  300. </p>
  301. <div class="copyright">
  302. Design &copy; 2002, 2003 <a href="mailto:raitner@fmi.uni-passau.de">Marcus Raitner</a>, University of Passau
  303. </div>
  304. </body>
  305. </html>