Compartir a través de


hash_multiset::get_allocator

Nota

Esta API está obsoleta.La alternativa es unordered_multiset (Clase).

Devuelve una copia del objeto de asignador utilizado para construir el hash_multiset.

Allocator get_allocator( ) const;

Valor devuelto

El asignador utilizado por el hash_multiset para administrar la memoria, que es el parámetro Allocatorde la plantilla de clase.

Para obtener más información sobre Allocator, vea la sección comentarios de tema de hash_multiset (Clase) .

Comentarios

Los asignadores para la clase de hash_multiset especifican cómo la clase administra el almacenamiento. Los asignadores predeterminados proporcionados con las clases de contenedor de STL son suficientes para la mayoría de programación necesitan. La escritura y using dispone de la clase de asignador es un tema avanzado de C++.

En Visual C++ .NET 2003, los miembros de los archivos de encabezado <hash_map> y <hash_set> ya no están en el espacio de nombres std, sino que se han movido al espacio de nombres stdext. Vea El espacio de nombres stdext para obtener más información.

Ejemplo

// 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;
   }
}

Resultados del ejemplo

El siguiente resultado corresponde a x86.

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.

Requisitos

Encabezado: <hash_set>

Espacio de nombres: stdext

Vea también

Referencia

hash_multiset (Clase)

Biblioteca de plantillas estándar