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