hash_multiset::equal_range
[!참고]
이 API는 사용되지 않습니다.대신 unordered_multiset Class.
반복기 쌍입니다 각각 첫 번째 요소에서 지정 된 키 보다 큰 키를 hash_multiset 하 고 hash_multiset 키 키 보다 크거나 같은 경우에 첫 번째 요소를 반환 합니다.
pair <const_iterator, const_iterator> equal_range (
const Key& _Key
) const;
pair <iterator, iterator> equal_range (
const Key& _Key
);
매개 변수
- _Key
요소를 검색 하 고 hash_multiset에서 정렬 키를 비교할 인수 키.
반환 값
첫 번째는 반복기 쌍입니다의 lower_bound 키가 고 두 번째의의 upper_bound 키.
먼저 반복기 쌍에 액세스 하려면 pr 멤버 함수에 의해 반환 된를 사용 하 여 pr. 첫 번째 및 역참조 하한값 반복기를 사용 하 여 * (pr.첫 번째).두 번째 반복기 쌍에 액세스 하려면 pr 멤버 함수에 의해 반환 된를 사용 하 여 pr. 두 번째 상한 반복기를 역참조를 사용 하 고 * (pr.두 번째).
Visual C++.NET 2003 멤버는 <hash_map> 및 <hash_set> 헤더 파일이 더 이상 std 네임 스페이스에 있지만 오히려 stdext 네임 스페이스로 이동 되었습니다.자세한 내용은 stdext 네임스페이스를 참조하십시오.
예제
// hash_multiset_equal_range.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
typedef hash_multiset<int> IntHSet;
IntHSet hms1;
hash_multiset <int> :: const_iterator hms1_RcIter;
hms1.insert( 10 );
hms1.insert( 20 );
hms1.insert( 30 );
pair <IntHSet::const_iterator, IntHSet::const_iterator> p1, p2;
p1 = hms1.equal_range( 20 );
cout << "The upper bound of the element with "
<< "a key of 20\nin the hash_multiset hms1 is: "
<< *(p1.second) << "." << endl;
cout << "The lower bound of the element with "
<< "a key of 20\nin the hash_multiset hms1 is: "
<< *(p1.first) << "." << endl;
// Compare the upper_bound called directly
hms1_RcIter = hms1.upper_bound( 20 );
cout << "A direct call of upper_bound( 20 ) gives "
<< *hms1_RcIter << "," << endl
<< "matching the 2nd element of the pair"
<< " returned by equal_range( 20 )." << endl;
p2 = hms1.equal_range( 40 );
// If no match is found for the key,
// both elements of the pair return end( )
if ( ( p2.first == hms1.end( ) )
&& ( p2.second == hms1.end( ) ) )
cout << "The hash_multiset hms1 doesn't have an element "
<< "with a key less than 40." << endl;
else
cout << "The element of hash_multiset hms1"
<< "with a key >= 40 is: "
<< *(p1.first) << "." << endl;
}
요구 사항
헤더: <hash_set>
네임 스페이스: stdext