hash_multiset::find
참고
이 API는 사용되지 않습니다.unordered_multiset 클래스를 대신 사용하는 것이 좋습니다.
Returns an iterator addressing the location of an element in a hash_multiset that has a key equivalent to a specified key.
iterator find(
const Key& _Key
);
const_iterator find(
const Key& _Key
) const;
매개 변수
- _Key
The argument key to be matched by the sort key of an element from the hash_multiset being searched.
반환 값
An iterator or const_iterator that addresses the location of an element equivalent to a specified key or that addresses the location succeeding the last element in the hash_multiset if no match is found for the key.
설명
The member function returns an iterator that addresses an element in the hash_multiset whose sort key is equivalent to the argument key under a binary predicate that induces an ordering based on a less-than comparability relation.
If the return value of find is assigned to a const_iterator, the hash_multiset object cannot be modified. If the return value of find is assigned to an iterator, the hash_multiset object can be modified.
Visual C++.NET 2003에서, <hash_map> 및 <hash_set> 헤더 파일의 멤버는 더 이상 std 네임스페이스에 존재하지 않습니다. 대신 stdext 네임스페이스로 이동되었습니다. 자세한 내용은 stdext 네임스페이스를 참조하십시오.
예제
// hash_multiset_find.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_multiset <int> hms1;
hash_multiset <int> :: const_iterator hms1_AcIter, hms1_RcIter;
hms1.insert( 10 );
hms1.insert( 20 );
hms1.insert( 30 );
hms1_RcIter = hms1.find( 20 );
cout << "The element of hash_multiset hms1 with a key of 20 is: "
<< *hms1_RcIter << "." << endl;
hms1_RcIter = hms1.find( 40 );
// If no match is found for the key, end( ) is returned
if ( hms1_RcIter == hms1.end( ) )
cout << "The hash_multiset hms1 doesn't have an element "
<< "with a key of 40." << endl;
else
cout << "The element of hash_multiset hms1 with a key of 40 is: "
<< *hms1_RcIter << "." << endl;
// The element at a specific location in the hash_multiset can be found
// by using a dereferenced iterator addressing the location
hms1_AcIter = hms1.end( );
hms1_AcIter--;
hms1_RcIter = hms1.find( *hms1_AcIter );
cout << "The element of hms1 with a key matching "
<< "that of the last element is: "
<< *hms1_RcIter << "." << endl;
}
요구 사항
헤더: <hash_set>
네임스페이스: stdext