hash_multiset::get_allocator
[!참고]
이 API는 사용되지 않습니다.대신 unordered_multiset Class.
Hash_multiset를 만드는 데 사용 되는 할당 기 개체의 복사본을 반환 합니다.
Allocator get_allocator( ) const;
반환 값
Hash_multiset가 사용 되는 클래스의 템플릿 매개 변수는 메모리를 관리 하는 할당 자가 Allocator.
에 대 한 자세한 내용은 Allocator, 설명 부분을 참조를 hash_multiset Class 항목.
설명
할당자는 hash_multiset 클래스에 대 한 클래스 저장소를 관리 하는 방법을 지정 합니다.STL 컨테이너 클래스와 함께 제공 된 기본 할당자 대부분의 프로그래밍 요구에 충분 한 것입니다.작성 하 고 사용자의 할당자 클래스를 사용 하는 고급 C++ 항목입니다.
Visual C++.NET 2003 멤버는 <hash_map> 및 <hash_set> 헤더 파일이 더 이상 std 네임 스페이스에 있지만 오히려 stdext 네임 스페이스로 이동 되었습니다.자세한 내용은 stdext 네임스페이스를 참조하십시오.
예제
// hash_multiset_get_allocator.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
// The following lines declare objects
// that use the default allocator.
hash_multiset <int, hash_compare <int, less<int> > > hms1;
hash_multiset <int, hash_compare <int, greater<int> > > hms2;
hash_multiset <double, hash_compare <double,
less<double> >, allocator<double> > hms3;
hash_multiset <int, hash_compare <int,
greater<int> > >::allocator_type hms2_Alloc;
hash_multiset <double>::allocator_type hms3_Alloc;
hms2_Alloc = hms2.get_allocator( );
cout << "The number of integers that can be allocated"
<< endl << "before free memory is exhausted: "
<< hms1.max_size( ) << "." << endl;
cout << "The number of doubles that can be allocated"
<< endl << "before free memory is exhausted: "
<< hms3.max_size( ) << "." << endl;
// The following lines create a hash_multiset hms4
// with the allocator of hash_multiset hms1.
hash_multiset <int>::allocator_type hms4_Alloc;
hash_multiset <int> hms4;
hms4_Alloc = hms2.get_allocator( );
// Two allocators are interchangeable if
// storage allocated from each can be
// deallocated by the other
if( hms2_Alloc == hms4_Alloc )
{
cout << "The allocators are interchangeable."
<< endl;
}
else
{
cout << "The allocators are not interchangeable."
<< endl;
}
}
샘플 출력
다음 출력 x 86에 대 한 것입니다.
The number of integers that can be allocated
before free memory is exhausted: 1073741823.
The number of doubles that can be allocated
before free memory is exhausted: 536870911.
The allocators are interchangeable.
요구 사항
헤더: <hash_set>
네임 스페이스: stdext