hash_map::at
참고
이 API는 사용되지 않습니다.unordered_map 클래스를 대신 사용하는 것이 좋습니다.
Finds an element in a hash_map with a specified key value.
Type& at(
const Key& _Key
);
const Type& at(
const Key& _Key
) const;
매개 변수
Parameter |
설명 |
_Key |
The key value of the element that is to be found. |
반환 값
찾은 요소의 데이터 값에 대한 참조입니다.
설명
If the argument key value is not found, then the function throws an object of class out_of_range 클래스.
Visual C++.NET 2003에서, <hash_map> 및 <hash_set> 헤더 파일의 멤버는 더 이상 std 네임스페이스에 존재하지 않습니다. 대신 stdext 네임스페이스로 이동되었습니다. 자세한 내용은 stdext 네임스페이스를 참조하십시오.
예제
// hash_map_at.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
typedef pair <const int, int> cInt2Int;
hash_map <int, int> hm1;
// Insert data values
hm1.insert ( cInt2Int ( 1, 10 ) );
hm1.insert ( cInt2Int ( 2, 20 ) );
hm1.insert ( cInt2Int ( 3, 30 ) );
cout << "The values of the mapped elements are:";
for ( int i = 1 ; i <= hm1.size() ; i++ )
cout << " " << hm1.at(i);
cout << "." << endl;
}
Output
The values of the mapped elements are: 10 20 30.
요구 사항
헤더: <hash_map>
네임스페이스: stdext