Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > c74ab286c3d46f9b82671d206e43a74b > files > 668

libstdc++-docs-4.6.3-2.fc15.i686.rpm

<!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"/>
<title>libstdc++: std::priority_queue&lt; _Tp, _Sequence, _Compare &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">libstdc++</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00662.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">std::priority_queue&lt; _Tp, _Sequence, _Compare &gt; Class Template Reference<div class="ingroups"><a class="el" href="a01159.html">Sequences</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="std::priority_queue" -->
<p>A standard container automatically sorting its contents.  
 <a href="a00662.html#details">More...</a></p>

<p><a href="a02324.html">List of all members.</a></p>
<h2><a name="pub-types"></a>
Public Types</h2>
<ul>
<li><a class="anchor" id="aee5ba345e85d74e43163a38fd0b68711"></a><!-- doxytag: member="std::priority_queue::const_reference" ref="aee5ba345e85d74e43163a38fd0b68711" args="" -->
typedef _Sequence::const_reference <b>const_reference</b>
<li><a class="anchor" id="ad8a7ff58e206f92e5c8d5e0681a3fe99"></a><!-- doxytag: member="std::priority_queue::container_type" ref="ad8a7ff58e206f92e5c8d5e0681a3fe99" args="" -->
typedef _Sequence <b>container_type</b>
<li><a class="anchor" id="ad51180cd1240a49235044c8e5b6fd06e"></a><!-- doxytag: member="std::priority_queue::reference" ref="ad51180cd1240a49235044c8e5b6fd06e" args="" -->
typedef _Sequence::reference <b>reference</b>
<li><a class="anchor" id="abb44ba9344669cb5bf0526427594e184"></a><!-- doxytag: member="std::priority_queue::size_type" ref="abb44ba9344669cb5bf0526427594e184" args="" -->
typedef _Sequence::size_type <b>size_type</b>
<li><a class="anchor" id="a5c5f86402aebad559116330af173b829"></a><!-- doxytag: member="std::priority_queue::value_type" ref="a5c5f86402aebad559116330af173b829" args="" -->
typedef _Sequence::value_type <b>value_type</b>
</ul>
<h2><a name="pub-methods"></a>
Public Member Functions</h2>
<ul>
<li><a class="el" href="a00662.html#a9499ae5886b93b58a2abfe4f73448cc0">priority_queue</a> (const _Compare &amp;__x, const _Sequence &amp;__s)
<li><a class="anchor" id="a2c3fb3490dfcd32e1c0ee535a846c417"></a><!-- doxytag: member="std::priority_queue::priority_queue" ref="a2c3fb3490dfcd32e1c0ee535a846c417" args="(const _Compare &amp;__x=_Compare(), _Sequence &amp;&amp;__s=_Sequence())" -->
<b>priority_queue</b> (const _Compare &amp;__x=_Compare(), _Sequence &amp;&amp;__s=_Sequence())
<li><a class="anchor" id="aadd29318ff8c292c56cb9a23f1fa213d"></a><!-- doxytag: member="std::priority_queue::priority_queue" ref="aadd29318ff8c292c56cb9a23f1fa213d" args="(_InputIterator __first, _InputIterator __last, const _Compare &amp;__x=_Compare(), _Sequence &amp;&amp;__s=_Sequence())" -->
template&lt;typename _InputIterator &gt; <b>priority_queue</b> (_InputIterator __first, _InputIterator __last, const _Compare &amp;__x=_Compare(), _Sequence &amp;&amp;__s=_Sequence())
<li>template&lt;typename _InputIterator &gt; <a class="el" href="a00662.html#ab4514bf6ef3fb1e1b4051428fe4d4627">priority_queue</a> (_InputIterator __first, _InputIterator __last, const _Compare &amp;__x, const _Sequence &amp;__s)
<li><a class="anchor" id="a048a609f036134f86432b1771b80a816"></a><!-- doxytag: member="std::priority_queue::emplace" ref="a048a609f036134f86432b1771b80a816" args="(_Args &amp;&amp;...__args)" -->
template&lt;typename... _Args&gt; void <b>emplace</b> (_Args &amp;&amp;...__args)
<li>bool <a class="el" href="a00662.html#af3eaf1d61f0e394e569c5779765023a8">empty</a> () const 
<li>void <a class="el" href="a00662.html#a935091a0132d887f9d3f87686c5598ac">pop</a> ()
<li>void <a class="el" href="a00662.html#acf5286a0e5aa7354459ca1553ba54688">push</a> (const value_type &amp;__x)
<li><a class="anchor" id="ae1a14112c5c831a96231845da4ccf6f3"></a><!-- doxytag: member="std::priority_queue::push" ref="ae1a14112c5c831a96231845da4ccf6f3" args="(value_type &amp;&amp;__x)" -->
void <b>push</b> (value_type &amp;&amp;__x)
<li>size_type <a class="el" href="a00662.html#a0b0f6e210f112b5c5f75318481fc9059">size</a> () const 
<li><a class="anchor" id="ac22e36c74f8bb6453ce0823a07a16af0"></a><!-- doxytag: member="std::priority_queue::swap" ref="ac22e36c74f8bb6453ce0823a07a16af0" args="(priority_queue &amp;__pq)" -->
void <b>swap</b> (<a class="el" href="a00662.html">priority_queue</a> &amp;__pq)
<li>const_reference <a class="el" href="a00662.html#a2203f7a919d0a72561a8e05cb570fd17">top</a> () const 
</ul>
<h2><a name="pro-attribs"></a>
Protected Attributes</h2>
<ul>
<li><a class="anchor" id="afb4b0f6fc110c254cd402518808556b7"></a><!-- doxytag: member="std::priority_queue::c" ref="afb4b0f6fc110c254cd402518808556b7" args="" -->
_Sequence <b>c</b>
<li><a class="anchor" id="a0666ffbc53da52251ae8e1c8dd99188a"></a><!-- doxytag: member="std::priority_queue::comp" ref="a0666ffbc53da52251ae8e1c8dd99188a" args="" -->
_Compare <b>comp</b>
</ul>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename _Tp, typename _Sequence = vector&lt;_Tp&gt;, typename _Compare = less&lt;typename _Sequence::value_type&gt;&gt;<br/>
class std::priority_queue&lt; _Tp, _Sequence, _Compare &gt;</h3>

<p>A standard container automatically sorting its contents. </p>
<p>This is not a true container, but an <em>adaptor</em>. It holds another container, and provides a wrapper interface to that container. The wrapper is what enforces priority-based sorting and queue behavior. Very few of the standard container/sequence interface requirements are met (e.g., iterators).</p>
<p>The second template parameter defines the type of the underlying sequence/container. It defaults to <a class="el" href="a00739.html" title="A standard container which offers fixed time access to individual elements in any order...">std::vector</a>, but it can be any type that supports <code>front()</code>, <code>push_back</code>, <code>pop_back</code>, and random-access iterators, such as <a class="el" href="a00455.html" title="A standard container using fixed-size memory allocation and constant-time manipulation of elements at...">std::deque</a> or an appropriate user-defined type.</p>
<p>The third template parameter supplies the means of making priority comparisons. It defaults to <code>less&lt;value_type&gt;</code> but can be anything defining a strict weak ordering.</p>
<p>Members not found in <em>normal</em> containers are <code>container_type</code>, which is a typedef for the second Sequence parameter, and <code>push</code>, <code>pop</code>, and <code>top</code>, which are standard queue operations.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>No equality/comparison operators are provided for priority_queue.</dd>
<dd>
Sorting of the elements takes place as they are added to, and removed from, the priority_queue using the priority_queue's member functions. If you access the elements by other means, and change their data such that the sorting order would be different, the priority_queue will not re-sort the elements for you. (How could it know to do so?) </dd></dl>

<p>Definition at line <a class="el" href="a01061_source.html#l00359">359</a> of file <a class="el" href="a01061_source.html">stl_queue.h</a>.</p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a9499ae5886b93b58a2abfe4f73448cc0"></a><!-- doxytag: member="std::priority_queue::priority_queue" ref="a9499ae5886b93b58a2abfe4f73448cc0" args="(const _Compare &amp;__x, const _Sequence &amp;__s)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename _Tp, typename _Sequence = vector&lt;_Tp&gt;, typename _Compare = less&lt;typename _Sequence::value_type&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00662.html">std::priority_queue</a>&lt; _Tp, _Sequence, _Compare &gt;::<a class="el" href="a00662.html">priority_queue</a> </td>
          <td>(</td>
          <td class="paramtype">const _Compare &amp;&#160;</td>
          <td class="paramname"><em>__x</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const _Sequence &amp;&#160;</td>
          <td class="paramname"><em>__s</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline, explicit]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Default constructor creates no elements. </p>

<p>Definition at line <a class="el" href="a01061_source.html#l00394">394</a> of file <a class="el" href="a01061_source.html">stl_queue.h</a>.</p>

<p>References <a class="el" href="a01051_source.html#l00415">std::make_heap()</a>.</p>

</div>
</div>
<a class="anchor" id="ab4514bf6ef3fb1e1b4051428fe4d4627"></a><!-- doxytag: member="std::priority_queue::priority_queue" ref="ab4514bf6ef3fb1e1b4051428fe4d4627" args="(_InputIterator __first, _InputIterator __last, const _Compare &amp;__x, const _Sequence &amp;__s)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename _Tp, typename _Sequence = vector&lt;_Tp&gt;, typename _Compare = less&lt;typename _Sequence::value_type&gt;&gt; </div>
<div class="memtemplate">
template&lt;typename _InputIterator &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00662.html">std::priority_queue</a>&lt; _Tp, _Sequence, _Compare &gt;::<a class="el" href="a00662.html">priority_queue</a> </td>
          <td>(</td>
          <td class="paramtype">_InputIterator&#160;</td>
          <td class="paramname"><em>__first</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">_InputIterator&#160;</td>
          <td class="paramname"><em>__last</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const _Compare &amp;&#160;</td>
          <td class="paramname"><em>__x</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const _Sequence &amp;&#160;</td>
          <td class="paramname"><em>__s</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Builds a queue from a range. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">first</td><td>An input iterator. </td></tr>
    <tr><td class="paramname">last</td><td>An input iterator. </td></tr>
    <tr><td class="paramname">x</td><td>A comparison functor describing a strict weak ordering. </td></tr>
    <tr><td class="paramname">s</td><td>An initial sequence with which to start.</td></tr>
  </table>
  </dd>
</dl>
<p>Begins by copying <em>s</em>, inserting a copy of the elements from <em></em>[first,last) into the copy of <em>s</em>, then ordering the copy according to <em>x</em>.</p>
<p>For more information on function objects, see the documentation on <a class="el" href="a01193.html">functor base classes</a>. </p>

<p>Definition at line <a class="el" href="a01061_source.html#l00434">434</a> of file <a class="el" href="a01061_source.html">stl_queue.h</a>.</p>

<p>References <a class="el" href="a01051_source.html#l00415">std::make_heap()</a>.</p>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="af3eaf1d61f0e394e569c5779765023a8"></a><!-- doxytag: member="std::priority_queue::empty" ref="af3eaf1d61f0e394e569c5779765023a8" args="() const " -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename _Tp, typename _Sequence = vector&lt;_Tp&gt;, typename _Compare = less&lt;typename _Sequence::value_type&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="a00662.html">std::priority_queue</a>&lt; _Tp, _Sequence, _Compare &gt;::empty </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns true if the queue is empty. </p>

<p>Definition at line <a class="el" href="a01061_source.html#l00460">460</a> of file <a class="el" href="a01061_source.html">stl_queue.h</a>.</p>

<p>Referenced by <a class="el" href="a00950_source.html#l00124">__gnu_parallel::multiseq_partition()</a>, and <a class="el" href="a00950_source.html#l00390">__gnu_parallel::multiseq_selection()</a>.</p>

</div>
</div>
<a class="anchor" id="a935091a0132d887f9d3f87686c5598ac"></a><!-- doxytag: member="std::priority_queue::pop" ref="a935091a0132d887f9d3f87686c5598ac" args="()" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename _Tp, typename _Sequence = vector&lt;_Tp&gt;, typename _Compare = less&lt;typename _Sequence::value_type&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="a00662.html">std::priority_queue</a>&lt; _Tp, _Sequence, _Compare &gt;::pop </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Removes first element. </p>
<p>This is a typical queue operation. It shrinks the queue by one. The time complexity of the operation depends on the underlying sequence.</p>
<p>Note that no data is returned, and if the first element's data is needed, it should be retrieved before <a class="el" href="a00662.html#a935091a0132d887f9d3f87686c5598ac" title="Removes first element.">pop()</a> is called. </p>

<p>Definition at line <a class="el" href="a01061_source.html#l00523">523</a> of file <a class="el" href="a01061_source.html">stl_queue.h</a>.</p>

<p>References <a class="el" href="a01051_source.html#l00352">std::pop_heap()</a>.</p>

<p>Referenced by <a class="el" href="a00950_source.html#l00124">__gnu_parallel::multiseq_partition()</a>, and <a class="el" href="a00950_source.html#l00390">__gnu_parallel::multiseq_selection()</a>.</p>

</div>
</div>
<a class="anchor" id="acf5286a0e5aa7354459ca1553ba54688"></a><!-- doxytag: member="std::priority_queue::push" ref="acf5286a0e5aa7354459ca1553ba54688" args="(const value_type &amp;__x)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename _Tp, typename _Sequence = vector&lt;_Tp&gt;, typename _Compare = less&lt;typename _Sequence::value_type&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="a00662.html">std::priority_queue</a>&lt; _Tp, _Sequence, _Compare &gt;::push </td>
          <td>(</td>
          <td class="paramtype">const value_type &amp;&#160;</td>
          <td class="paramname"><em>__x</em></td><td>)</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Add data to the queue. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">x</td><td>Data to be added.</td></tr>
  </table>
  </dd>
</dl>
<p>This is a typical queue operation. The time complexity of the operation depends on the underlying sequence. </p>

<p>Definition at line <a class="el" href="a01061_source.html#l00488">488</a> of file <a class="el" href="a01061_source.html">stl_queue.h</a>.</p>

<p>References <a class="el" href="a01051_source.html#l00205">std::push_heap()</a>.</p>

<p>Referenced by <a class="el" href="a00950_source.html#l00124">__gnu_parallel::multiseq_partition()</a>, and <a class="el" href="a00950_source.html#l00390">__gnu_parallel::multiseq_selection()</a>.</p>

</div>
</div>
<a class="anchor" id="a0b0f6e210f112b5c5f75318481fc9059"></a><!-- doxytag: member="std::priority_queue::size" ref="a0b0f6e210f112b5c5f75318481fc9059" args="() const " -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename _Tp, typename _Sequence = vector&lt;_Tp&gt;, typename _Compare = less&lt;typename _Sequence::value_type&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">size_type <a class="el" href="a00662.html">std::priority_queue</a>&lt; _Tp, _Sequence, _Compare &gt;::size </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns the number of elements in the queue. </p>

<p>Definition at line <a class="el" href="a01061_source.html#l00465">465</a> of file <a class="el" href="a01061_source.html">stl_queue.h</a>.</p>

</div>
</div>
<a class="anchor" id="a2203f7a919d0a72561a8e05cb570fd17"></a><!-- doxytag: member="std::priority_queue::top" ref="a2203f7a919d0a72561a8e05cb570fd17" args="() const " -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename _Tp, typename _Sequence = vector&lt;_Tp&gt;, typename _Compare = less&lt;typename _Sequence::value_type&gt;&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">const_reference <a class="el" href="a00662.html">std::priority_queue</a>&lt; _Tp, _Sequence, _Compare &gt;::top </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns a read-only (constant) reference to the data at the first element of the queue. </p>

<p>Definition at line <a class="el" href="a01061_source.html#l00473">473</a> of file <a class="el" href="a01061_source.html">stl_queue.h</a>.</p>

<p>Referenced by <a class="el" href="a00950_source.html#l00124">__gnu_parallel::multiseq_partition()</a>, and <a class="el" href="a00950_source.html#l00390">__gnu_parallel::multiseq_selection()</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="a01061_source.html">stl_queue.h</a></li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a01137.html">std</a>      </li>
      <li class="navelem"><a class="el" href="a00662.html">priority_queue</a>      </li>
      <li class="footer">Generated by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </li>
    </ul>
  </div>

</body>
</html>