Compartir a través de


CRBMultiMap::CRBMultiMap

el constructor.

explicit CRBMultiMap(
   size_t nBlockSize = 10 
) throw( );

Parámetros

  • nBlockSize
    el tamaño de bloque.

Comentarios

El parámetro de nBlockSize es una medida de la cantidad de memoria asignada cuando se requiere un nuevo elemento.Tamaños de bloque mayores reducen llamadas a las rutinas de asignación de memoria, pero se utiliza más recursos.El valor predeterminado asignará el espacio para 10 elementos al mismo tiempo.

Vea la documentación de la clase base CRBTree para obtener información sobre los otros métodos disponibles.

Ejemplo

// Define a multimap object which has an integer
// key, a double value, and a block size of 5
CRBMultiMap<int, double> myMap(5);

// Add some key/values. Notice how three
// different values are associated with 
// one key. In a CRBMap object, the values
// would simply overwrite each other.
myMap.Insert(0, 1.1);
myMap.Insert(0, 1.2);
myMap.Insert(0, 1.3);
myMap.Insert(1, 2.1);

// Look up a key and iterate through
// all associated values

double v;
POSITION myPos = myMap.FindFirstWithKey(0);

while (myPos != NULL)
{
   v = myMap.GetNextValueWithKey(myPos,0);
   // As the loop iterates, v 
   // contains the values 1.3, 1.2, 1.1
}

// Remove all of the values associated with that key
size_t i = myMap.RemoveKey(0);

// Confirm all three values were deleted
ATLASSERT(i == 3);

Requisitos

encabezado: atlcoll.h

Vea también

Referencia

Clase de CRBMultiMap

CRBMultiMap::~CRBMultiMap