deque::rbegin

返回迭代器以执行取消的、向量、双端队列的第一个元素。

const_reverse_iterator rbegin( ) const; 
reverse_iterator rbegin( );

返回值

解决活动反向随机访问迭代器解决已取消的、向量、双端队列的第一个元素或什么是在unreversed、向量、双端队列的最后一个元素。

备注

启动 使用、向量、双端队列,rbegin 使用具有是相反的、向量、双端队列。

如果 rbegin 的返回值赋给 const_reverse_iterator,不能修改、向量、双端队列对象。如果 rbegin 的返回值赋给 reverse_iterator,可以修改、向量、双端队列对象。

rbegin 可用于通过、向量、双端队列向后重复。

示例

// deque_rbegin.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>

int main( ) 
{
   using namespace std;
   deque <int> c1;
   deque <int>::iterator c1_Iter;
   deque <int>::reverse_iterator c1_rIter;

   // If the following line had replaced the line above, an error 
   // would have resulted in the line modifying an element 
   // (commented below) because the iterator would have been const
   // deque <int>::const_reverse_iterator c1_rIter;
   
   c1.push_back( 10 );
   c1.push_back( 20 );
   c1.push_back( 30 );

   c1_rIter = c1.rbegin( );
   cout << "Last element in the deque is " << *c1_rIter << "." << endl;

   cout << "The deque contains the elements: ";
   for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
      cout << *c1_Iter << " ";
   cout << "in that order.";
   cout << endl;

   // rbegin can be used to iterate through a deque in reverse order
   cout << "The reversed deque is: ";
   for ( c1_rIter = c1.rbegin( ); c1_rIter != c1.rend( ); c1_rIter++ )
      cout << *c1_rIter << " ";
   cout << endl;

   c1_rIter = c1.rbegin( );
   *c1_rIter = 40;  // This would have caused an error if a 
                    // const_reverse iterator had been declared as 
                    // noted above
   cout << "Last element in deque is now " << *c1_rIter << "." << endl;
}
  
  
  

要求

标头: <deque>

命名空间: std

请参见

参考

deque Class

deque::rbegin 和 deque::rend

标准模板库