Udostępnij za pośrednictwem


operator>= (<iterator>)

Testuje, czy obiekt iteratora po lewej stronie operatora jest większy niż lub równy obiektowi iteratora po prawej stronie.

template<class RandomIterator> 
   bool operator>=( 
      const reverse_iterator<RandomIterator>& _Left, 
      const reverse_iterator<RandomIterator>& _Right 
   );

Parametry

  • _Left
    Obiekt typu iteratora.

  • _Right
    Obiekt typu iteratora.

Wartość zwracana

TRUE Jeśli sterująca po lewej stronie wyrażenia jest większa niż lub równa sterująca po prawej stronie wyrażenia; false jeżeli jest ona mniejsza niż sterująca po prawej stronie.

Uwagi

Jeden obiekt iteratora jest większa niż lub równa innej liczbie, jeśli dotyczy to tego samego elementu lub element występujący w kontenerze niż element skierowany przez obiekt sterująca później.Jeden obiekt iteratora jest mniejsza niż innego, jeśli dotyczy to element, który nastąpi wcześniej w kontenerze niż element skierowany przez obiekt iteratora.

Przykład

// 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;
}
  

Wymagania

Nagłówek: <iterator>

Przestrzeń nazw: std

Zobacz też

Informacje

Standardowa biblioteka szablonów