operator!= (<iterator>)

Comprueba si el objeto de iterador en el lado izquierdo del operador no es igual al objeto de iterador en el lado derecho.

template<class RandomIterator>
   bool operator!=(
      const reverse_iterator<RandomIterator>& _Left,
      const reverse_iterator<RandomIterator>& _Right
   );
template<class Type, class CharType, class Traits, class Distance>
   bool operator!=(
      const istream_iterator<Type, CharType, Traits, Distance>& _Left,
      const istream_iterator<Type, CharType, Traits, Distance>& _Right
   );
template<class CharType, class Tr>
   bool operator!=(
      const istreambuf_iterator<CharType, Traits>& _Left,
      const istreambuf_iterator<CharType, Traits>& _Right
);

Parámetros

  • _Left
    un objeto de iteradorescrito.

  • _Right
    un objeto de iteradorescrito.

Valor devuelto

TRUE si los objetos de iterador no son iguales; Falso si los objetos de iterador son iguales.

Comentarios

Un objeto de iterador es igual a otro si dirigen los mismos elementos en un contenedor.Si el punto de dos iteradores a distintos elementos en un contenedor, a ellas no son iguales.

Ejemplo

// iterator_op_ne.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;
   int i;

   vector<int> vec;
   for ( i = 1 ; i < 9 ; ++i )  
   {
      vec.push_back ( i );
   }
   
   vector <int>::iterator vIter;

   cout << "The vector vec is: ( ";
   for ( vIter = vec.begin( ) ; vIter != vec.end( ); vIter++ )
      cout << *vIter << " ";
   cout << ")." << endl;

   // Initializing reverse_iterators to the last element
   vector <int>::reverse_iterator rVPOS1 = vec.rbegin ( ), 
           rVPOS2 = vec.rbegin ( );
   
   cout << "The iterator rVPOS1 initially points to the first "
        << "element\n in the reversed sequence: "
        << *rVPOS1 << "." << endl;

   if ( rVPOS1 != rVPOS2 )
      cout << "The iterators are not equal." << endl;
   else
      cout << "The iterators are equal." << endl;

   rVPOS1++;
   cout << "The iterator rVPOS1 now points to the second "
        << "element\n in the reversed sequence: "
        << *rVPOS1 << "." << endl;

   if ( rVPOS1 != rVPOS2 )
      cout << "The iterators are not equal." << endl;
   else
      cout << "The iterators are equal." << endl;
}
  
  
  
  
  

Requisitos

encabezado: <iterador>

espacio de nombres: std

Vea también

Referencia

Biblioteca de plantillas estándar