다음을 통해 공유


hash_map::end

[!참고]

이 API는 사용되지 않습니다.대신 unordered_map Class.

Hash_map은 마지막 요소 다음에 나오는 위치를 설명 하는 반복기를 반환 합니다.

const_iterator end( ) const; 
iterator end( );

반환 값

주소는 hash_map의 마지막 요소 다음에 나오는 위치는 양방향 반복기입니다.Hash_map은 빈 hash_map::end 이면 hash_map::begin =.

설명

최종 반복기 해당 hash_map의 끝에 도달 했는지 여부를 테스트 하는 데 사용 됩니다.

반환 된 값 최종 역참조 되지 해야 합니다.

예제

// hash_map_end.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( ) 
{
   using namespace std;
   using namespace stdext;
   hash_map <int, int> hm1;

   hash_map <int, int> :: iterator hm1_Iter;
   hash_map <int, int> :: const_iterator hm1_cIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );
   hm1.insert ( Int_Pair ( 3, 30 ) );

   hm1_cIter = hm1.end( );
   hm1_cIter--;
   cout << "The value of last element of hm1 is " 
        << hm1_cIter -> second << "." << endl;
   
   hm1_Iter = hm1.end( );
   hm1_Iter--;
   hm1.erase ( hm1_Iter );

   // The following 2 lines would err because the iterator is const
   // hm1_cIter = hm1.end ( );
   // hm1_cIter--;
   // hm1.erase ( hm1_cIter );

   hm1_cIter = hm1.end( );
   hm1_cIter--;
   cout << "The value of last element of hm1 is now "
        << hm1_cIter -> second << "." << endl;
}
  
  

요구 사항

헤더: <hash_map>

네임 스페이스: stdext

참고 항목

참조

hash_map Class

표준 템플릿 라이브러리