다음을 통해 공유


hash_map::lower_bound

[!참고]

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

지정 된 키 보다 크거나 같은 키 값으로 hash_map의 첫 번째 요소에 반복기를 반환 합니다.

iterator lower_bound(
   const Key& _Key
);
const_iterator lower_bound(
   const Key& _Key
) const;

매개 변수

  • _Key
    검색 중인 hash_map에서 요소의 정렬 키를 비교할 인수 키 값입니다.

반환 값

반복기 또는 const_iterator 요소에는 인수 키 보다 크거나 또는 일치 하는 경우 hash_map의 마지막 요소 다음에 나오는 위치를 해결 키로에 키가 있는 한 hash_map의 위치를 설명 합니다.

경우 반환 값을 lower_bound 배정은 const_iterator, hash_map 개체를 수정할 수 없습니다.경우 반환 값을 lower_bound 배정은 반복기, hash_map 개체를 수정할 수 있습니다.

설명

Visual C++.NET 2003 멤버는 <hash_map><hash_set> 헤더 파일이 더 이상 std 네임 스페이스에 있지만 오히려 stdext 네임 스페이스로 이동 되었습니다.자세한 내용은 stdext 네임스페이스를 참조하십시오.

예제

// hash_map_lower_bound.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> :: const_iterator hm1_AcIter, hm1_RcIter;
   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_RcIter = hm1.lower_bound( 2 );
   cout << "The first element of hash_map hm1 with a key of 2 is: "
        << hm1_RcIter -> second << "." << endl;

   // If no match is found for the key, end( ) is returned
   hm1_RcIter = hm1. lower_bound ( 4 );

   if ( hm1_RcIter == hm1.end( ) )
      cout << "The hash_map hm1 doesn't have an element "
           << "with a key of 4." << endl;
   else
      cout << "The element of hash_map hm1 with a key of 4 is: "
           << hm1_RcIter -> second << "." << endl;

   // An element at a specific location in the hash_map can be 
   // found using a dereferenced iterator addressing the location
   hm1_AcIter = hm1.end( );
   hm1_AcIter--;
   hm1_RcIter = hm1. lower_bound ( hm1_AcIter -> first );
   cout << "The element of hm1 with a key matching "
        << "that of the last element is: "
        << hm1_RcIter -> second << "." << endl;
}
  
  
  

요구 사항

헤더: <hash_map>

네임 스페이스: stdext

참고 항목

참조

hash_map Class

표준 템플릿 라이브러리