set::rbegin

返回解析的迭代器是相反的第一个元素设置。

const_reverse_iterator rbegin( ) const; 
reverse_iterator rbegin( );

返回值

解决活动反向双向的迭代器解决在反转的第一个元素设置或什么是在unreversed的最后一个元素设置。

备注

启动 用于设置,的rbegin 用于取消的设置。

如果 rbegin 的返回值赋给 const_reverse_iterator,则不能修改设置的对象。 如果 rbegin 的返回值赋给 reverse_iterator,则可以修改设置的对象。

rbegin 可用于通过向后设置重复。

示例

// set_rbegin.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main( )
{
   using namespace std;   
   set <int> s1;
   set <int>::iterator s1_Iter;
   set <int>::reverse_iterator s1_rIter;

   s1.insert( 10 );
   s1.insert( 20 );
   s1.insert( 30 );

   s1_rIter = s1.rbegin( );
   cout << "The first element in the reversed set is "
        << *s1_rIter << "." << endl;

   // begin can be used to start an iteration 
   // throught a set in a forward order
   cout << "The set is:";
   for ( s1_Iter = s1.begin( ) ; s1_Iter != s1.end( ); s1_Iter++ )
      cout << " " << *s1_Iter;
   cout << endl;

   // rbegin can be used to start an iteration 
   // throught a set in a reverse order
   cout << "The reversed set is:";
   for ( s1_rIter = s1.rbegin( ) ; s1_rIter != s1.rend( ); s1_rIter++ )
      cout << " " << *s1_rIter;
   cout << endl;

   // A set element can be erased by dereferencing to its key 
   s1_rIter = s1.rbegin( );
   s1.erase ( *s1_rIter );

   s1_rIter = s1.rbegin( );
   cout << "After the erasure, the first element "
        << "in the reversed set is "<< *s1_rIter << "." << endl;
}
  
  

要求

标头: <set>

命名空间: std

请参见

参考

set Class

set::rbegin 和 set::rend

标准模板库