Udostępnij za pośrednictwem


set::end

Zwraca iterację likwidującą lokalizacji przejmującej ostatni element w zestawie.

const_iterator end( ) const; 
iterator end( );

Wartość zwracana

Iteratora dwukierunkowy likwidującą lokalizacji przejmującej ostatni element w zestawie.Jeśli zbiór jest pusty, a następnie set::end == set::begin.

Uwagi

koniec jest używany do testowania, czy iterację osiągnął koniec zestawu.Wartość zwracana przez celu nie należy usunąć odwołania.

Przykład

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

int main( )
{
   using namespace std;   
   set <int> s1;
   set <int> :: iterator s1_Iter;
   set <int> :: const_iterator s1_cIter;
   
   s1.insert( 1 );
   s1.insert( 2 );
   s1.insert( 3 );

   s1_Iter = s1.end( );
   s1_Iter--;
   cout << "The last element of s1 is " << *s1_Iter << endl;

   s1.erase( s1_Iter );

   // The following 3 lines would err because the iterator is const
   // s1_cIter = s1.end( );
   // s1_cIter--;
   // s1.erase( s1_cIter );

   s1_cIter = s1.end( );
   s1_cIter--;
   cout << "The last element of s1 is now " << *s1_cIter << endl;
}
  

Wymagania

Nagłówek: <set>

Obszar nazw: std

Zobacz też

Informacje

set Class

set::swap, set::begin, i set::end

Standardowa biblioteka szablonu