다음을 통해 공유


map::lower_bound

맵의 같거나 보다는 지정 된 키의 키 값을 가진 첫 번째 요소에 반복기를 반환 합니다.

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

매개 변수

  • _Key
    검색 되는 지도 요소의 정렬 키를 비교할 인수 키 값입니다.

반환 값

반복기 또는 const_iterator 입니다 인수 키 보다 크거나 또는 주소가 일치 하면 맵의 마지막 요소 뒤에 위치 하는 키와 키에 대해 발견 되는 지도 요소의 위치를 해결 합니다.

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

예제

// map_lower_bound.cpp
// compile with: /EHsc
#include <map>
#include <iostream>

int main( )
{
   using namespace std;   
   map <int, int> m1;
   map <int, int> :: const_iterator m1_AcIter, m1_RcIter;
   typedef pair <int, int> Int_Pair;

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

   m1_RcIter = m1.lower_bound( 2 );
   cout << "The first element of map m1 with a key of 2 is: "
        << m1_RcIter -> second << "." << endl;

   // If no match is found for this key, end( ) is returned
   m1_RcIter = m1. lower_bound ( 4 );

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

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

요구 사항

헤더: <map>

네임 스페이스: std

참고 항목

참조

map Class

표준 템플릿 라이브러리