⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cppdeque_details.html

📁 ssd5 数据结构的课件
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <meta name="generator" content="HTML Tidy for Linux/x86 (vers 1st October 2002), see www.w3.org">    <title>C++ Double-Ended Queues</title>  </head>  <body bgcolor="#ffffff">    <table width="100%" bgcolor="#eeeeff">      <tr>        <td><a href="index.html">cppreference.com</a> -&gt; <a href="cppdeque.html">C++ Double-Ended        Queues</a> -&gt; Details</td>      </tr>    </table>    <h1>C++ Double-Ended Queues</h1>    <hr>    <h2><a name="Constructors">Constructors</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tbody>        <tr>          <td><pre>  deque();  deque( size_type size );  deque( size_type num, const <a href="containers.html">TYPE</a> &amp;val );  deque( const deque &amp;from );  deque( <a href="iterators.html">input_iterator</a> start, <a href="iterators.html">input_iterator</a> end );</pre>          </td>        </tr>      </tbody>    </table>    <p>C++ Deques can be constructed with either:</p>    <ul>      <li>Nothing - which creates an empty deque,</li>      <li><i>size</i> - creates a deque of size <i>num</i>,</li>      <li><i>num</i> and <i>val</i> - puts <i>num</i> copies of <i>val</i> in the deque,</li>      <li><i>from</i> - creates a deque with the same contents as <i>from</i>, or</li>      <li><i>start</i> and <i>end</i> - which creates a deque containing elements from <i>start</i> to      <i>end</i>.</li>    </ul>    <br>    <br>         <p>For example, the following code creates and displays a deque:</p><pre>  // create a deque with ten '1's in it  deque&lt;int&gt; dq( 10, 1 );  // create an iterator  deque&lt;int&gt;::iterator iter;  // display the contents of our deque  for( iter = dq.begin(); iter != dq.end(); iter++ ){     cout &lt;&lt; *iter &lt;&lt; endl;  }</pre>    <br>    <br>         <hr>    <h2><a name="Operators">Operators</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  []</pre>        </td>      </tr>    </table>    <p>You can access individual members of the double-ended queue using the [] operator.</p>    <hr>    <h2><a name="assign">assign</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  void assign( <a href="iterators.html">input_iterator</a> start, <a href="iterators.html">input_iterator</a> end);  void assign( Size num, const <a href="containers.html">TYPE</a> &amp;val );</pre>        </td>      </tr>    </table>    <p>The function assign() sets the double-ended queue the sequence denoted by <i>start</i> and <i>end</i>,    or sets <i>num</i> elements to <i>val</i>.</p>    <hr>    <h2><a name="at">at</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  reference at( size_type pos );</pre>        </td>      </tr>    </table>    <p>The at() function returns a reference to the element at <i>pos</i> in the double-ended queue.</p>    <hr>    <h2><a name="back">back</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  reference back();</pre>        </td>      </tr>    </table>    <p>The function back() returns a reference to the back element of the double-ended queue.</p>    <hr>    <h2><a name="begin">begin</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  <a href="iterators.html">iterator</a> begin();</pre>        </td>      </tr>    </table>    <p>The begin() function returns an <a href="iterators.html">iterator</a> to the front element of the    double-ended queue.</p>    <hr>    <h2><a name="clear">clear</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  void clear();</pre>        </td>      </tr>    </table>    <p>The clear() function deletes all of the elements from the double-ended queue.</p>    <hr>    <h2><a name="empty">empty</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  bool empty();</pre>        </td>      </tr>    </table>    <p>The function empty() returns <strong>true</strong> if the double-ended queue is empty, and    <strong>false</strong> otherwise.</p>    <hr>    <h2><a name="end">end</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  <a href="iterators.html">iterator</a> end();</pre>        </td>      </tr>    </table>    <p>The end() function returns an <a href="iterators.html">iterator</a> to the back of the double-ended    queue.</p>    <hr>    <h2><a name="erase">erase</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  <a href="iterators.html">iterator</a> erase( <a href="iterators.html">iterator</a> pos );  <a href="iterators.html">iterator</a> erase( <a href="iterators.html">iterator</a> start, <a href="iterators.html">iterator</a> end );</pre>        </td>      </tr>    </table>    <p>The function erase() erases the element at location <i>pos</i>, or the items between <i>start</i> and    <i>end</i>. The return value is an <a href="iterators.html">iterator</a> to the element just after the    last one erased.</p>    <hr>    <h2><a name="front">front</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  reference front();</pre>        </td>      </tr>    </table>    <p>The front() function returns a reference to the element at the beginning of the double-ended    queue.</p>    <hr>    <h2><a name="get_allocator">get_allocator</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  allocator_type get_allocator();</pre>        </td>      </tr>    </table>    <p>The get_allocator() function returns the double-ended queue's allocator.</p>    <hr>    <h2><a name="insert">insert</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  <a href="iterators.html">iterator</a> insert( <a href="iterators.html">iterator</a> pos, size_type num, const <a href="containers.html">TYPE</a> &amp;val );  void insert( <a href="iterators.html">iterator</a> pos, <a href="iterators.html">input_iterator</a> start, <a href="iterators.html">input_iterator</a> end );</pre>        </td>      </tr>    </table>    <p>The insert() function inserts <i>num</i> copies of <i>val</i> before the element at <i>pos</i>, or    inserts the sequence specified by <i>start</i> and <i>end</i> before the element at <i>pos</i>.</p>    <hr>    <h2><a name="max_size">max_size</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  size_type max_size();</pre>        </td>      </tr>    </table>    <p>The function max_size() returns the maximum number of items that the double-ended queue can hold.</p>    <hr>    <h2><a name="pop_back">pop_back</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  void pop_back();</pre>        </td>      </tr>    </table>    <p>The pop_back() function removes the last element from the double-ended queue.</p>    <hr>    <h2><a name="pop_front">pop_front</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  void pop_front();</pre>        </td>      </tr>    </table>    <p>The function pop_front() removes the first element from the double-ended queue.</p>    <hr>    <h2><a name="push_back">push_back</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  void push_back( const <a href="containers.html">TYPE</a> &amp;val );</pre>        </td>      </tr>    </table>    <p>The push_back() function adds <i>val</i> to the end of the double-ended queue.</p>    <hr>    <h2><a name="push_front">push_front</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  void push_front( const <a href="containers.html">TYPE</a> &amp;val );</pre>        </td>      </tr>    </table>    <p>The function push_front() adds <i>val</i> to the front of the double-ended queue.</p>    <hr>    <h2><a name="rbegin">rbegin</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  <a href="iterators.html">reverse_iterator</a> rbegin();</pre>        </td>      </tr>    </table>    <p>The rbegin() function returns a reverse <a href="iterators.html">iterator</a> to the back of the    double-ended queue.</p>    <hr>    <h2><a name="rend">rend</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  <a href="iterators.html">reverse_iterator</a> rend();</pre>        </td>      </tr>    </table>    <p>The function rend() returns a reverse <a href="iterators.html">iterator</a> to the front of the    double-ended queue.</p>    <hr>    <h2><a name="resize">resize</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  void resize( size_type num, <a href="containers.html">TYPE</a> val );</pre>        </td>      </tr>    </table>    <p>The resize() function changes the size of the double-ended queue to <i>num</i>, padding any added    entries with elements equal to <i>val</i>.</p>    <hr>    <h2><a name="size">size</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  size_type size();</pre>        </td>      </tr>    </table>    <p>The size() function returns the number of elements in the double-ended queue.</p>    <hr>    <h2><a name="swap">swap</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  void swap( deque &amp;target );</pre>        </td>      </tr>    </table>    <p>The swap() function swaps the elements in the current double-ended queue with those in    <i>target</i>.</p>  </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -