multiset::upper_bound
반복기 multiset 지정한 키 보다 큰 키를 가진 첫 번째 요소를 반환 합니다.
const_iterator upper_bound(
const Key& _Key
) const;
iterator upper_bound(
const Key& _Key
);
매개 변수
- _Key
검색 중인 복수 집합에서 요소의 정렬 키를 비교할 인수 키.
반환 값
반복기 또는 const_iterator 주소 요소의 위치에 multiset 키 인수 키 보다 큰 또는 주소 위치 키에 일치 하는 항목이 있는 경우 마지막 요소가 multiset에 성공 합니다.
예제
// multiset_upper_bound.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
multiset <int> ms1;
multiset <int> :: const_iterator ms1_AcIter, ms1_RcIter;
ms1.insert( 10 );
ms1.insert( 20 );
ms1.insert( 30 );
ms1_RcIter = ms1.upper_bound( 20 );
cout << "The first element of multiset ms1 with a key greater "
<< "than 20 is: " << *ms1_RcIter << "." << endl;
ms1_RcIter = ms1.upper_bound( 30 );
// If no match is found for the key, end( ) is returned
if ( ms1_RcIter == ms1.end( ) )
cout << "The multiset ms1 doesn't have an element "
<< "with a key greater than 30." << endl;
else
cout << "The element of multiset ms1 with a key > 40 is: "
<< *ms1_RcIter << "." << endl;
// The element at a specific location in the multiset can be
// found using a dereferenced iterator addressing the location
ms1_AcIter = ms1.begin( );
ms1_RcIter = ms1.upper_bound( *ms1_AcIter );
cout << "The first element of ms1 with a key greater than"
<< endl << "that of the initial element of ms1 is: "
<< *ms1_RcIter << "." << endl;
}
요구 사항
헤더: <set>
네임 스페이스: std