operator>= (<iterator>)
測試運算子左邊的迭代器物件是否大於或等於右邊的迭代器物件。
template<class RandomIterator>
bool operator>=(
const reverse_iterator<RandomIterator>& _Left,
const reverse_iterator<RandomIterator>& _Right
);
參數
_Left
型別的物件。_Right
型別的物件。
傳回值
true ,如果在運算式的左側的 Iterator 大於或等於 Iterator 在運算式右邊; false ,如果小於右邊的 Iterator。
備註
一個 Iterator 物件大於或等於另一個,則處理相同項目或在容器比另一個 Iterator 物件單元位址之後產生的項目。 一個 Iterator 物件小於另一個,則說明容器比另一個 Iterator 物件單元位址之前的項目。
範例
// iterator_op_ge.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
int i;
vector<int> vec;
for (i = 0 ; i < 6 ; ++i ) {
vec.push_back ( 2 * i );
}
vector <int>::iterator vIter;
cout << "The initial vector vec is: ( ";
for ( vIter = vec.begin( ) ; vIter != vec.end( ); vIter++)
cout << *vIter << " ";
cout << ")." << endl;
vector <int>::reverse_iterator rVPOS1 = vec.rbegin ( ),
rVPOS2 = vec.rbegin ( ) + 1;
cout << "The iterator rVPOS1 initially points to the "
<< "first element\n in the reversed sequence: "
<< *rVPOS1 << "." << endl;
cout << "The iterator rVPOS2 initially points to the "
<< "second element\n in the reversed sequence: "
<< *rVPOS2 << "." << endl;
if ( rVPOS1 >= rVPOS2 )
cout << "The iterator rVPOS1 is greater than or "
<< "equal to the iterator rVPOS2." << endl;
else
cout << "The iterator rVPOS1 is less than "
<< "the iterator rVPOS2." << endl;
rVPOS1++;
cout << "The iterator rVPOS1 now points to the second "
<< "element\n in the reversed sequence: "
<< *rVPOS1 << "." << endl;
if ( rVPOS1 >= rVPOS2 )
cout << "The iterator rVPOS1 is greater than or "
<< "equal to the iterator rVPOS2." << endl;
else
cout << "The iterator rVPOS1 is less than "
<< "the iterator rVPOS2." << endl;
}
需求
標頭:<迭代器>
命名空間: std