다음을 통해 공유


hash_set::get_allocator

[!참고]

이 API는 사용되지 않습니다.대신 unordered_set Class.

Hash_set를 만드는 데 사용 되는 할당 기 개체의 복사본을 반환 합니다.

Allocator get_allocator( ) const;

반환 값

할당자 템플릿 매개 변수가 메모리를 관리 하 여 hash_set 사용 Allocator.

에 대 한 자세한 내용은 Allocator, 설명 부분을 참조를 hash_set Class 항목.

설명

할당자는 hash_set 클래스에 대 한 클래스 저장소를 관리 하는 방법을 지정 합니다.STL 컨테이너 클래스와 함께 제공 된 기본 할당자 대부분의 프로그래밍 요구에 충분 한 것입니다.작성 하 고 사용자의 할당자 클래스를 사용 하는 고급 C++ 항목입니다.

Visual C++.NET 2003 멤버는 <hash_map><hash_set> 헤더 파일이 더 이상 std 네임 스페이스에 있지만 오히려 stdext 네임 스페이스로 이동 되었습니다.자세한 내용은 stdext 네임스페이스를 참조하십시오.

예제

// hash_set_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_set <int, hash_compare <int, less<int> > > hs1;
   hash_set <int,  hash_compare <int, greater<int> > > hs2;
   hash_set <double, hash_compare <double,
      less<double> >, allocator<double> > hs3;

   hash_set <int, hash_compare <int,
      greater<int> > >::allocator_type hs2_Alloc;
   hash_set <double>::allocator_type hs3_Alloc;
   hs2_Alloc = hs2.get_allocator( );

   cout << "The number of integers that can be allocated"
        << endl << "before free memory is exhausted: "
        << hs1.max_size( ) << "." << endl;

   cout << "The number of doubles that can be allocated"
        << endl << "before free memory is exhausted: "
        << hs3.max_size( ) <<  "." << endl;

   // The following lines create a hash_set hs4
   // with the allocator of hash_set hs1.
   hash_set <int>::allocator_type hs4_Alloc;
   hash_set <int> hs4;
   hs4_Alloc = hs2.get_allocator( );

   // Two allocators are interchangeable if
   // storage allocated from each can be
   // deallocated by the other
   if( hs2_Alloc == hs4_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

참고 항목

참조

hash_set Class

표준 템플릿 라이브러리