hash_map (STL/CLR)hash_map (STL/CLR)

La clase de plantilla describe un objeto que controla una secuencia de elementos de longitud variable que tiene acceso bidireccional.The template class describes an object that controls a varying-length sequence of elements that has bidirectional access. Usar el contenedor hash_map para administrar una secuencia de elementos como una tabla hash, cada entrada de la tabla almacenar un bidireccional vinculado lista de nodos y cada nodo almacenar un elemento.You use the container hash_map to manage a sequence of elements as a hash table, each table entry storing a bidirectional linked list of nodes, and each node storing one element. Un elemento consta de una clave, para ordenar la secuencia y un valor asignado que va a lo largo de la carrera.An element consists of a key, for ordering the sequence, and a mapped value, which goes along for the ride.

En la descripción siguiente, GValue es igual que:In the description below, GValue is the same as:

Microsoft::VisualC::StlClr::GenericPair<GKey, GMapped>

donde:where:

GKey es el mismo que Key a menos que este último es un tipo de referencia, en cuyo caso es Key^GKey is the same as Key unless the latter is a ref type, in which case it is Key^

GMapped es el mismo que Mapped a menos que este último es un tipo de referencia, en cuyo caso es Mapped^GMapped is the same as Mapped unless the latter is a ref type, in which case it is Mapped^

SintaxisSyntax

template<typename Key,
    typename Mapped>
    ref class hash_map
        :   public
        System::ICloneable,
        System::Collections::IEnumerable,
        System::Collections::ICollection,
        System::Collections::Generic::IEnumerable<GValue>,
        System::Collections::Generic::ICollection<GValue>,
        System::Collections::Generic::IList<GValue>,
        System::Collections::Generic::IDictionary<Gkey, GMapped>,
        Microsoft::VisualC::StlClr::IHash<Gkey, GValue>
    { ..... };

ParámetrosParameters

KeyKey
El tipo del componente clave de un elemento de la secuencia controlada.The type of the key component of an element in the controlled sequence.

asignadoMapped
El tipo del componente adicional de un elemento de la secuencia controlada.The type of the additional component of an element in the controlled sequence.

RequisitosRequirements

Encabezado: <cliext/hash_map >Header: <cliext/hash_map>

Namespace: cliextNamespace: cliext

DeclaracionesDeclarations

Definición de tipoType Definition DescripciónDescription
hash_map::const_iterator (STL/CLR)hash_map::const_iterator (STL/CLR) El tipo de un iterador constante para la secuencia controlada.The type of a constant iterator for the controlled sequence.
hash_map::const_reference (STL/CLR)hash_map::const_reference (STL/CLR) El tipo de una referencia constante a un elemento.The type of a constant reference to an element.
hash_map::const_reverse_iterator (STL/CLR)hash_map::const_reverse_iterator (STL/CLR) El tipo de un iterador invertido constante para la secuencia controlada.The type of a constant reverse iterator for the controlled sequence.
hash_map::difference_type (STL/CLR)hash_map::difference_type (STL/CLR) El tipo de una distancia entre dos elementos (posiblemente con signo).The type of a (possibly signed) distance between two elements.
hash_map::generic_container (STL/CLR)hash_map::generic_container (STL/CLR) El tipo de la interfaz genérica para el contenedor.The type of the generic interface for the container.
hash_map::generic_iterator (STL/CLR)hash_map::generic_iterator (STL/CLR) El tipo de iterador para la interfaz genérica para el contenedor.The type of an iterator for the generic interface for the container.
hash_map::generic_reverse_iterator (STL/CLR)hash_map::generic_reverse_iterator (STL/CLR) El tipo de un iterador inverso de la interfaz genérica para el contenedor.The type of a reverse iterator for the generic interface for the container.
hash_map::generic_value (STL/CLR)hash_map::generic_value (STL/CLR) El tipo de un elemento de la interfaz genérica para el contenedor.The type of an element for the generic interface for the container.
hash_map::hasher (STL/CLR)hash_map::hasher (STL/CLR) El delegado de hash para una clave.The hashing delegate for a key.
hash_map::iterator (STL/CLR)hash_map::iterator (STL/CLR) El tipo de un iterador para la secuencia controlada.The type of an iterator for the controlled sequence.
hash_map::key_compare (STL/CLR)hash_map::key_compare (STL/CLR) Delegado de ordenación para dos claves.The ordering delegate for two keys.
hash_map::key_type (STL/CLR)hash_map::key_type (STL/CLR) El tipo de una clave de ordenación.The type of an ordering key.
hash_map::mapped_type (STL/CLR)hash_map::mapped_type (STL/CLR) El tipo del valor asignado asociado a cada clave.The type of the mapped value associated with each key.
hash_map::reference (STL/CLR)hash_map::reference (STL/CLR) El tipo de una referencia a un elemento.The type of a reference to an element.
hash_map::reverse_iterator (STL/CLR)hash_map::reverse_iterator (STL/CLR) El tipo de un iterador invertido para la secuencia controlada.The type of a reverse iterator for the controlled sequence.
hash_map::size_type (STL/CLR)hash_map::size_type (STL/CLR) El tipo de una distancia (no negativo) entre dos elementos.The type of a (non-negative) distance between two elements.
hash_map::value_compare (STL/CLR)hash_map::value_compare (STL/CLR) Delegado de ordenación para dos valores de elemento.The ordering delegate for two element values.
hash_map::value_type (STL/CLR)hash_map::value_type (STL/CLR) El tipo de un elemento.The type of an element.
Función miembroMember Function DescripciónDescription
hash_map::begin (STL/CLR)hash_map::begin (STL/CLR) Designa el principio de la secuencia controlada.Designates the beginning of the controlled sequence.
hash_map::bucket_count (STL/CLR)hash_map::bucket_count (STL/CLR) Cuenta el número de depósitos.Counts the number of buckets.
hash_map::clear (STL/CLR)hash_map::clear (STL/CLR) Quita todos los elementos.Removes all elements.
hash_map::count (STL/CLR)hash_map::count (STL/CLR) Recuentos de elementos que coinciden con una clave especificada.Counts elements matching a specified key.
hash_map::empty (STL/CLR)hash_map::empty (STL/CLR) Comprueba si no hay ningún elemento presente.Tests whether no elements are present.
hash_map::end (STL/CLR)hash_map::end (STL/CLR) Designa el final de la secuencia controlada.Designates the end of the controlled sequence.
hash_map::equal_range (STL/CLR)hash_map::equal_range (STL/CLR) Busca el intervalo que coincide con una clave especificada.Finds range that matches a specified key.
hash_map::erase (STL/CLR)hash_map::erase (STL/CLR) Quita los elementos de las posiciones especificadas.Removes elements at specified positions.
hash_map::find (STL/CLR)hash_map::find (STL/CLR) Busca un elemento que coincide con una clave especificada.Finds an element that matches a specified key.
hash_map::hash_delegate (STL/CLR)hash_map::hash_delegate (STL/CLR) Copia al delegado de hash para una clave.Copies the hashing delegate for a key.
hash_map::hash_map (STL/CLR)hash_map::hash_map (STL/CLR) Construye un objeto contenedor.Constructs a container object.
hash_map::insert (STL/CLR)hash_map::insert (STL/CLR) Agrega elementos.Adds elements.
hash_map::key_comp (STL/CLR)hash_map::key_comp (STL/CLR) Copia al delegado de ordenación de dos claves.Copies the ordering delegate for two keys.
hash_map::load_factor (STL/CLR)hash_map::load_factor (STL/CLR) Cuenta los elementos promedio por depósito.Counts the average elements per bucket.
hash_map::lower_bound (STL/CLR)hash_map::lower_bound (STL/CLR) Busca el principio del intervalo que coincide con una clave especificada.Finds beginning of range that matches a specified key.
hash_map::make_value (STL/CLR)hash_map::make_value (STL/CLR) Construye un objeto de valor.Constructs a value object.
hash_map::max_load_factor (STL/CLR)hash_map::max_load_factor (STL/CLR) Obtiene o establece los elementos máximos por depósito.Gets or sets the maximum elements per bucket.
hash_map::rbegin (STL/CLR)hash_map::rbegin (STL/CLR) Designa el principio de la secuencia controlada inversa.Designates the beginning of the reversed controlled sequence.
hash_map::rehash (STL/CLR)hash_map::rehash (STL/CLR) Recompila la tabla hash.Rebuilds the hash table.
hash_map::rend (STL/CLR)hash_map::rend (STL/CLR) Designa el final de la secuencia controlada inversa.Designates the end of the reversed controlled sequence.
hash_map::size (STL/CLR)hash_map::size (STL/CLR) Cuenta el número de elementos.Counts the number of elements.
hash_map::swap (STL/CLR)hash_map::swap (STL/CLR) Intercambia el contenido de dos contenedores.Swaps the contents of two containers.
hash_map::to_array (STL/CLR)hash_map::to_array (STL/CLR) Copia la secuencia controlada a una nueva matriz.Copies the controlled sequence to a new array.
hash_map::upper_bound (STL/CLR)hash_map::upper_bound (STL/CLR) Busca el final del intervalo que coincide con una clave especificada.Finds end of range that matches a specified key.
hash_map::value_comp (STL/CLR)hash_map::value_comp (STL/CLR) Copia al delegado de ordenación de dos valores de elemento.Copies the ordering delegate for two element values.
OperadorOperator DescripciónDescription
hash_map::operator= (STL/CLR)hash_map::operator= (STL/CLR) Reemplaza la secuencia controlada.Replaces the controlled sequence.
hash_map::operator(STL/CLR)hash_map::operator(STL/CLR) Asigna una clave a su valor asignado asociado.Maps a key to its associated mapped value.

InterfacesInterfaces

InterfazInterface DescripciónDescription
ICloneable Duplicar un objeto.Duplicate an object.
IEnumerable Secuencia a través de los elementos.Sequence through elements.
ICollection Mantener el grupo de elementos.Maintain group of elements.
IEnumerable<T> Secuencia a través de los elementos con tipo.Sequence through typed elements.
ICollection<T> Mantener el grupo de elementos con tipo.Maintain group of typed elements.
IDictionary<TKey, TValue> Mantener el grupo de {clave, valor} pares.Maintain group of {key, value} pairs.
IHash < clave, valor >IHash<Key, Value> Mantener contenedor genérico.Maintain generic container.

ComentariosRemarks

El objeto asigna y libera almacenamiento para la secuencia que controla como nodos individuales en una lista vinculada bidireccional.The object allocates and frees storage for the sequence it controls as individual nodes in a bidirectional linked list. Para acelerar el acceso, el objeto también mantiene una matriz de longitud variable de punteros en la lista (la tabla hash), administrar de forma eficaz la lista completa como una secuencia de sublistas, o cubos.To speed access, the object also maintains a varying-length array of pointers into the list (the hash table), effectively managing the whole list as a sequence of sublists, or buckets. Inserta elementos en un cubo que mantiene ordenada por la modificación de los vínculos entre los nodos nunca copiando el contenido de un nodo a otro.It inserts elements into a bucket that it keeps ordered by altering the links between nodes, never by copying the contents of one node to another. Esto significa que puede insertar y quitar elementos libremente sin perturbar elementos restantes.That means you can insert and remove elements freely without disturbing remaining elements.

El objeto ordena cada depósito controla mediante una llamada a un objeto delegado almacenado de tipo hash_set:: key_compare (STL/CLR).The object orders each bucket it controls by calling a stored delegate object of type hash_set::key_compare (STL/CLR). Puede especificar el objeto de delegado almacenado cuando se construye el objeto hash_set; Si se especifica ningún objeto de delegado, el valor predeterminado es la comparación operator<=(key_type, key_type).You can specify the stored delegate object when you construct the hash_set; if you specify no delegate object, the default is the comparison operator<=(key_type, key_type).

Tiene acceso al objeto de delegado almacenado mediante una llamada a la función miembro hash_set:: key_comp (STL/CLR)().You access the stored delegate object by calling the member function hash_set::key_comp (STL/CLR)(). Este tipo de objeto de delegado debe definir una ordenación equivalente entre las claves de tipo hash_set:: KEY_TYPE (STL/CLR).Such a delegate object must define equivalent ordering between keys of type hash_set::key_type (STL/CLR). Esto significa que, en las dos claves X y Y:That means, for any two keys X and Y:

key_comp()(X, Y) Devuelve el valor booleano mismo resultado en cada llamada.key_comp()(X, Y) returns the same Boolean result on every call.

Si key_comp()(X, Y) && key_comp()(Y, X) es true, a continuación, X y Y se dice que tienen una ordenación equivalente.If key_comp()(X, Y) && key_comp()(Y, X) is true, then X and Y are said to have equivalent ordering.

Cualquier regla de ordenación que se comporta como operator<=(key_type, key_type), operator>=(key_type, key_type) o operator==(key_type, key_type) define eqivalent orden.Any ordering rule that behaves like operator<=(key_type, key_type), operator>=(key_type, key_type) or operator==(key_type, key_type) defines eqivalent ordering.

Tenga en cuenta que el contenedor solo garantiza que los elementos cuyas claves tienen una ordenación equivalente (y qué hash en el mismo valor entero) son adyacentes dentro de un depósito.Note that the container ensures only that elements whose keys have equivalent ordering (and which hash to the same integer value) are adjacent within a bucket. A diferencia de la clase de plantilla hash_multimap (STL/CLR), un objeto de clase de plantilla hash_map garantiza que las claves para todos los elementos son únicas.Unlike template class hash_multimap (STL/CLR), an object of template class hash_map ensures that keys for all elements are unique. (No hay dos claves tienen una ordenación equivalente).(No two keys have equivalent ordering.)

El objeto determina qué cubo debe contener una clave de ordenación especificada mediante una llamada a un objeto delegado almacenado de tipo hash_set::hasher (STL/CLR).The object determines which bucket should contain a given ordering key by calling a stored delegate object of type hash_set::hasher (STL/CLR). Acceder a este objeto almacenado llamando a la función miembro hash_set::hash_delegate (STL/CLR) () para obtener un valor entero que depende del valor de clave.You access this stored object by calling the member function hash_set::hash_delegate (STL/CLR)() to obtain an integer value that depends on the key value. Puede especificar el objeto de delegado almacenado cuando se construye el objeto hash_set; Si se especifica ningún objeto de delegado, el valor predeterminado es la función System::Object::hash_value(key_type).You can specify the stored delegate object when you construct the hash_set; if you specify no delegate object, the default is the function System::Object::hash_value(key_type). Esto significa que para cualquier clave X y Y:That means, for any keys X and Y:

hash_delegate()(X) Devuelve el mismo resultado entero en cada llamada.hash_delegate()(X) returns the same integer result on every call.

Si X y Y tienen una ordenación equivalente, a continuación, hash_delegate()(X) debe devolver el mismo resultado entero como hash_delegate()(Y).If X and Y have equivalent ordering, then hash_delegate()(X) should return the same integer result as hash_delegate()(Y).

Cada elemento contiene una clave independiente y un valor asignado.Each element contains a separate key and a mapped value. La secuencia se representa de forma que permita la búsqueda, inserción y eliminación de un elemento arbitrario con un número de operaciones que es independiente del número de elementos de la secuencia (tiempo constante): al menos en el mejor de los casos.The sequence is represented in a way that permits lookup, insertion, and removal of an arbitrary element with a number of operations that is independent of the number of elements in the sequence (constant time) -- at least in the best of cases. Además, la inserción de un elemento no invalida ningún iterador y al quitar un elemento solo se invalidan los iteradores que apuntan al elemento quitado.Moreover, inserting an element invalidates no iterators, and removing an element invalidates only those iterators which point at the removed element.

Si los valores hash no se distribuyen uniformemente, sin embargo, puede degenerar una tabla hash.If hashed values are not uniformly distributed, however, a hash table can degenerate. En casos extremos, para una función hash que siempre devuelve el mismo valor, búsqueda, inserción y eliminación son proporcionales al número de elementos de la secuencia (tiempo lineal).In the extreme -- for a hash function that always returns the same value -- lookup, insertion, and removal are proportional to the number of elements in the sequence (linear time). El contenedor protegida elegir una función hash razonable, el tamaño de depósito promedio y tamaño de la tabla hash (número total de depósitos), pero puede invalidar cualquiera o todas estas opciones.The container endeavors to choose a reasonable hash function, mean bucket size, and hash-table size (total number of buckets), but you can override any or all of these choices. Consulte, por ejemplo, las funciones hash_set::max_load_factor (STL/CLR) y hash_set::rehash (STL/CLR).See, for example, the functions hash_set::max_load_factor (STL/CLR) and hash_set::rehash (STL/CLR).

Un objeto hash_map es compatible con los iteradores bidireccionales, lo que significa que puede ejecutar paso a paso para los elementos adyacentes que proporciona un iterador que designa un elemento de la secuencia controlada.A hash_map supports bidirectional iterators, which means you can step to adjacent elements given an iterator that designates an element in the controlled sequence. Un nodo principal especial que se corresponde con el iterador devuelto por hash_map:: end (STL/CLR)().A special head node corresponds to the iterator returned by hash_map::end (STL/CLR)(). Puede reducir este iterador para alcanzar el último elemento de la secuencia controlada, si está presente.You can decrement this iterator to reach the last element in the controlled sequence, if present. Puede incrementar un iterador de hash_map para alcanzar el nodo principal y, a continuación, comparará igual a end().You can increment a hash_map iterator to reach the head node, and it will then compare equal to end(). Pero no se puede desreferenciar el iterador devuelto por end().But you cannot dereference the iterator returned by end().

Tenga en cuenta que no puede hacer referencia a un elemento de hash_map directamente dado su posición numérica--que requiera un iterador de acceso aleatorio.Note that you cannot refer to a hash_map element directly given its numerical position -- that requires a random-access iterator.

Un iterador de hash_map almacena un identificador a su nodo asociado hash_map, que a su vez almacena un identificador de su contenedor asociado.A hash_map iterator stores a handle to its associated hash_map node, which in turn stores a handle to its associated container. Puede usar iteradores sólo con sus objetos de contenedor asociado.You can use iterators only with their associated container objects. Un iterador de hash_map sigue siendo válido siempre y cuando su nodo asociado hash_map está asociado a algún objeto hash_map.A hash_map iterator remains valid so long as its associated hash_map node is associated with some hash_map. Además, un iterador válido es dereferenceable, puede usar para tener acceso o modificar el valor del elemento designa--siempre y cuando no es igual a end().Moreover, a valid iterator is dereferencable -- you can use it to access or alter the element value it designates -- so long as it is not equal to end().

Borrar o quitar un elemento llama al destructor para su valor almacenado.Erasing or removing an element calls the destructor for its stored value. Destruir el contenedor, borra todos los elementos.Destroying the container erases all elements. Por lo tanto, un contenedor cuyo tipo de elemento es una clase ref garantiza que ningún elemento durar más que el contenedor.Thus, a container whose element type is a ref class ensures that no elements outlive the container. Sin embargo, tenga en cuenta que un contenedor de controladores no no destruir sus elementos.Note, however, that a container of handles does not destroy its elements.

MiembrosMembers

hash_map::begin (STL/CLR)hash_map::begin (STL/CLR)

Designa el principio de la secuencia controlada.Designates the beginning of the controlled sequence.

SintaxisSyntax

iterator begin();

ComentariosRemarks

La función miembro devuelve un iterador bidireccional que designa el primer elemento de la secuencia controlada o justo después del final de una secuencia vacía.The member function returns a bidirectional iterator that designates the first element of the controlled sequence, or just beyond the end of an empty sequence. Se usa para obtener un iterador que designa el current principio de la secuencia controlada, pero su estado puede cambiar si cambia la longitud de la secuencia controlada.You use it to obtain an iterator that designates the current beginning of the controlled sequence, but its status can change if the length of the controlled sequence changes.

EjemploExample

// cliext_hash_map_begin.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect first two items
    Myhash_map::iterator it = c1.begin();
    System::Console::WriteLine("*begin() = [{0} {1}]",
        it->first, it->second);
    ++it;
    System::Console::WriteLine("*++begin() = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*begin() = [a 1]
*++begin() = [b 2]

hash_map::bucket_count (STL/CLR)hash_map::bucket_count (STL/CLR)

Cuenta el número de depósitos.Counts the number of buckets.

SintaxisSyntax

int bucket_count();

ComentariosRemarks

Las funciones miembro devuelve el número actual de depósitos.The member functions returns the current number of buckets. Se usa para determinar el tamaño de la tabla hash.You use it to determine the size of the hash table.

EjemploExample

// cliext_hash_map_bucket_count.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1 = gcnew Myhash_map;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect current parameters
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // change max_load_factor and redisplay
    c1.max_load_factor(0.25f);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // rehash and redisplay
    c1.rehash(100);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    return (0);
    }
[a 1] [b 2] [c 3]
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4

bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25

bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25

hash_map::clear (STL/CLR)hash_map::clear (STL/CLR)

Quita todos los elementos.Removes all elements.

SintaxisSyntax

void clear();

ComentariosRemarks

La función miembro llama eficazmente a hash_map:: Erase (STL/CLR) ( hash_map:: begin (STL/CLR) (), hash_map:: end (STL/CLR) ()).The member function effectively calls hash_map::erase (STL/CLR)( hash_map::begin (STL/CLR)(), hash_map::end (STL/CLR)()). Usarlo para asegurarse de que está vacía la secuencia controlada.You use it to ensure that the controlled sequence is empty.

EjemploExample

// cliext_hash_map_clear.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // clear the container and reinspect
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());

    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));

    // display contents " [a 1] [b 2]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());
    return (0);
    }
[a 1] [b 2] [c 3]
size() = 0
[a 1] [b 2]
size() = 0

hash_map::const_iterator (STL/CLR)hash_map::const_iterator (STL/CLR)

El tipo de un iterador constante para la secuencia controlada.The type of a constant iterator for the controlled sequence.

SintaxisSyntax

typedef T2 const_iterator;

ComentariosRemarks

El tipo describe un objeto de tipo sin especificar T2 que puede actuar como un iterador constante bidireccional para la secuencia controlada.The type describes an object of unspecified type T2 that can serve as a constant bidirectional iterator for the controlled sequence.

EjemploExample

// cliext_hash_map_const_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    Myhash_map::const_iterator cit = c1.begin();
    for (; cit != c1.end(); ++cit)
        System::Console::Write("[{0} {1}] ", cit->first, cit->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

hash_map::const_reference (STL/CLR)hash_map::const_reference (STL/CLR)

El tipo de una referencia constante a un elemento.The type of a constant reference to an element.

SintaxisSyntax

typedef value_type% const_reference;

ComentariosRemarks

El tipo describe una referencia constante a un elemento.The type describes a constant reference to an element.

EjemploExample

// cliext_hash_map_const_reference.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    Myhash_map::const_iterator cit = c1.begin();
    for (; cit != c1.end(); ++cit)
        {   // get a const reference to an element
        Myhash_map::const_reference cref = *cit;
        System::Console::Write("[{0} {1}] ", cref->first, cref->second);
        }
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

hash_map::const_reverse_iterator (STL/CLR)hash_map::const_reverse_iterator (STL/CLR)

El tipo de un iterador inverso constante de la secuencia controlada...The type of a constant reverse iterator for the controlled sequence..

SintaxisSyntax

typedef T4 const_reverse_iterator;

ComentariosRemarks

El tipo describe un objeto de tipo sin especificar T4 que puede actuar como un iterador inverso constante de la secuencia controlada.The type describes an object of unspecified type T4 that can serve as a constant reverse iterator for the controlled sequence.

EjemploExample

// cliext_hash_map_const_reverse_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]" reversed
    Myhash_map::const_reverse_iterator crit = c1.rbegin();
    for (; crit != c1.rend(); ++crit)
        System::Console::Write("[{0} {1}] ", crit->first, crit->second);
    System::Console::WriteLine();
    return (0);
    }
[c 3] [b 2] [a 1]

hash_map::count (STL/CLR)hash_map::count (STL/CLR)

Busca el número de elementos que coinciden con una clave especificada.Finds the number of elements matching a specified key.

SintaxisSyntax

size_type count(key_type key);

ParámetrosParameters

keykey
Valor de clave que se va a buscar.Key value to search for.

ComentariosRemarks

La función miembro devuelve el número de elementos de la secuencia controlada que tienen una ordenación equivalente con clave.The member function returns the number of elements in the controlled sequence that have equivalent ordering with key. Se usa para determinar el número de elementos actualmente en la secuencia controlada que coinciden con una clave especificada.You use it to determine the number of elements currently in the controlled sequence that match a specified key.

EjemploExample

// cliext_hash_map_count.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("count(L'A') = {0}", c1.count(L'A'));
    System::Console::WriteLine("count(L'b') = {0}", c1.count(L'b'));
    System::Console::WriteLine("count(L'C') = {0}", c1.count(L'C'));
    return (0);
    }
[a 1] [b 2] [c 3]
count(L'A') = 0
count(L'b') = 1
count(L'C') = 0

hash_map::difference_type (STL/CLR)hash_map::difference_type (STL/CLR)

Los tipos de una distancia con signo entre dos elementos.The types of a signed distance between two elements.

SintaxisSyntax

typedef int difference_type;

ComentariosRemarks

El tipo describe un recuento de elemento posiblemente negativo.The type describes a possibly negative element count.

EjemploExample

// cliext_hash_map_difference_type.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // compute positive difference
    Myhash_map::difference_type diff = 0;
    for (Myhash_map::iterator it = c1.begin(); it != c1.end(); ++it)
        ++diff;
    System::Console::WriteLine("end()-begin() = {0}", diff);

    // compute negative difference
    diff = 0;
    for (Myhash_map::iterator it = c1.end(); it != c1.begin(); --it)
        --diff;
    System::Console::WriteLine("begin()-end() = {0}", diff);
    return (0);
    }
[a 1] [b 2] [c 3]
end()-begin() = 3
begin()-end() = -3

hash_map::empty (STL/CLR)hash_map::empty (STL/CLR)

Comprueba si no hay ningún elemento presente.Tests whether no elements are present.

SintaxisSyntax

bool empty();

ComentariosRemarks

La función miembro devuelve true para una secuencia controlada vacía.The member function returns true for an empty controlled sequence. Equivale a hash_map:: Size (STL/CLR)() == 0.It is equivalent to hash_map::size (STL/CLR)() == 0. Usa para comprobar si el objeto hash_map está vacío.You use it to test whether the hash_map is empty.

EjemploExample

// cliext_hash_map_empty.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    System::Console::WriteLine("size() = {0}", c1.size());
    System::Console::WriteLine("empty() = {0}", c1.empty());

    // clear the container and reinspect
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());
    System::Console::WriteLine("empty() = {0}", c1.empty());
    return (0);
    }
[a 1] [b 2] [c 3]
size() = 3
empty() = False
size() = 0
empty() = True

hash_map::end (STL/CLR)hash_map::end (STL/CLR)

Designa el final de la secuencia controlada.Designates the end of the controlled sequence.

SintaxisSyntax

iterator end();

ComentariosRemarks

La función miembro devuelve un iterador bidireccional que apunta justo después del final de la secuencia controlada.The member function returns a bidirectional iterator that points just beyond the end of the controlled sequence. Se usa para obtener un iterador que designa el final de la secuencia controlada; su estado se no cambiar si cambia la longitud de la secuencia controlada.You use it to obtain an iterator that designates the end of the controlled sequence; its status doesn not change if the length of the controlled sequence changes.

EjemploExample

// cliext_hash_map_end.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect last two items
    Myhash_map::iterator it = c1.end();
    --it;
    --it;
    System::Console::WriteLine("*-- --end() = [{0} {1}]",
        it->first, it->second);
    ++it;
    System::Console::WriteLine("*--end() = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*-- --end() = [b 2]
*--end() = [c 3]

hash_map::equal_range (STL/CLR)hash_map::equal_range (STL/CLR)

Busca el intervalo que coincide con una clave especificada.Finds range that matches a specified key.

SintaxisSyntax

cliext::pair<iterator, iterator> equal_range(key_type key);

ParámetrosParameters

keykey
Valor de clave que se va a buscar.Key value to search for.

ComentariosRemarks

La función miembro devuelve un par de iteradores cliext::pair<iterator, iterator>(lower_bound(key), upper_bound(key)).The member function returns a pair of iterators cliext::pair<iterator, iterator>(lower_bound(key), upper_bound(key)). Se usa para determinar el intervalo de elementos actualmente en la secuencia controlada que coinciden con una clave especificada.You use it to determine the range of elements currently in the controlled sequence that match a specified key.

EjemploExample

// cliext_hash_map_equal_range.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
typedef Myhash_map::pair_iter_iter Pairii;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // display results of failed search
    Pairii pair1 = c1.equal_range(L'x');
    System::Console::WriteLine("equal_range(L'x') empty = {0}",
        pair1.first == pair1.second);

    // display results of successful search
    pair1 = c1.equal_range(L'b');
    for (; pair1.first != pair1.second; ++pair1.first)
        System::Console::Write("[{0} {1}] ",
            pair1.first->first, pair1.first->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
equal_range(L'x') empty = True
[b 2]

hash_map::erase (STL/CLR)hash_map::erase (STL/CLR)

Quita los elementos de las posiciones especificadas.Removes elements at specified positions.

SintaxisSyntax

iterator erase(iterator where);
iterator erase(iterator first, iterator last);
bool erase(key_type key)

ParámetrosParameters

firstfirst
Principio del intervalo que se va a borrar.Beginning of range to erase.

keykey
Valor de clave para borrar.Key value to erase.

lastlast
Fin del intervalo que se va a borrar.End of range to erase.

wherewhere
Elemento que se va a borrar.Element to erase.

ComentariosRemarks

La primera función miembro quita el elemento de la secuencia controlada señalada por dondey devuelve un iterador que designa el primer elemento que permanece más allá del elemento quitado, o hash_map:: end (STL / CLR) () si no existe ese elemento.The first member function removes the element of the controlled sequence pointed to by where, and returns an iterator that designates the first element remaining beyond the element removed, or hash_map::end (STL/CLR)() if no such element exists. Usa para quitar un elemento único.You use it to remove a single element.

La segunda función miembro quita los elementos de la secuencia controlada en el intervalo [first, last) y devuelve un iterador que designa el primer elemento que permanece más allá de los elementos quitados, o end() si ningún elemento existe...The second member function removes the elements of the controlled sequence in the range [first, last), and returns an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists.. Usa para quitar cero o más elementos contiguos.You use it to remove zero or more contiguous elements.

La tercera función miembro quita cualquier elemento de la secuencia controlada cuyo criterio de ordenación es equivalente a clavey devuelve un recuento del número de elementos quitados.The third member function removes any element of the controlled sequence whose key has equivalent ordering to key, and returns a count of the number of elements removed. Usa para quitar y contar todos los elementos que coinciden con una clave especificada.You use it to remove and count all elements that match a specified key.

Eliminación de cada elemento tarda tiempo proporcional al logaritmo del número de elementos de la secuencia controlada.Each element erasure takes time proportional to the logarithm of the number of elements in the controlled sequence.

EjemploExample

// cliext_hash_map_erase.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    cliext::hash_map<wchar_t, int> c1;
    c1.insert(cliext::hash_map<wchar_t, int>::make_value(L'a', 1));
    c1.insert(cliext::hash_map<wchar_t, int>::make_value(L'b', 2));
    c1.insert(cliext::hash_map<wchar_t, int>::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (cliext::hash_map<wchar_t, int>::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // erase an element and reinspect
    cliext::hash_map<wchar_t, int>::iterator it =
        c1.erase(c1.begin());
    System::Console::WriteLine("erase(begin()) = [{0} {1}]",
        it->first, it->second);

    // add elements and display " b c d e"
    c1.insert(cliext::hash_map<wchar_t, int>::make_value(L'd', 4));
    c1.insert(cliext::hash_map<wchar_t, int>::make_value(L'e', 5));
    for each (cliext::hash_map<wchar_t, int>::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // erase all but end
    it = c1.end();
    it = c1.erase(c1.begin(), --it);
    System::Console::WriteLine("erase(begin(), end()-1) = [{0} {1}]",
        it->first, it->second);
    System::Console::WriteLine("size() = {0}", c1.size());

    // erase end
    System::Console::WriteLine("erase(L'x') = {0}", c1.erase(L'x'));
    System::Console::WriteLine("erase(L'e') = {0}", c1.erase(L'e'));
    return (0);
    }
[a 1] [b 2] [c 3]
erase(begin()) = [b 2]
[b 2] [c 3] [d 4] [e 5]
erase(begin(), end()-1) = [e 5]
size() = 1
erase(L'x') = 0
erase(L'e') = 1

hash_map::find (STL/CLR)hash_map::find (STL/CLR)

Busca un elemento que coincide con una clave especificada.Finds an element that matches a specified key.

SintaxisSyntax

iterator find(key_type key);

ParámetrosParameters

keykey
Valor de clave que se va a buscar.Key value to search for.

ComentariosRemarks

Si al menos un elemento de la secuencia controlada tiene una ordenación equivalente con clave, la función miembro devuelve un iterador que designa uno de esos elementos; de lo contrario, devuelve hash_map:: end (STL/CLR) ().If at least one element in the controlled sequence has equivalent ordering with key, the member function returns an iterator designating one of those elements; otherwise it returns hash_map::end (STL/CLR)(). Usa para buscar un elemento actualmente en la secuencia controlada que coincide con una clave especificada.You use it to locate an element currently in the controlled sequence that matches a specified key.

EjemploExample

// cliext_hash_map_find.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("find {0} = {1}",
        L'A', c1.find(L'A') != c1.end());

    Myhash_map::iterator it = c1.find(L'b');
    System::Console::WriteLine("find {0} = [{1} {2}]",
        L'b', it->first, it->second);

    System::Console::WriteLine("find {0} = {1}",
        L'C', c1.find(L'C') != c1.end());
    return (0);
    }
[a 1] [b 2] [c 3]
find A = False
find b = [b 2]
find C = False

hash_map::generic_container (STL/CLR)hash_map::generic_container (STL/CLR)

El tipo de la interfaz genérica para el contenedor.The type of the generic interface for the container.

SintaxisSyntax

typedef Microsoft::VisualC::StlClr::
    IHash<GKey, GValue>
    generic_container;

ComentariosRemarks

El tipo describe la interfaz genérica para esta clase de contenedor de plantilla.The type describes the generic interface for this template container class.

EjemploExample

// cliext_hash_map_generic_container.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Myhash_map::generic_container^ gc1 = %c1;
    for each (Myhash_map::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // modify generic and display original
    gc1->insert(Myhash_map::make_value(L'd', 4));
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // modify original and display generic
    c1.insert(Myhash_map::make_value(L'e', 5));
    for each (Myhash_map::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3] [d 4]
[a 1] [b 2] [c 3] [d 4] [e 5]

hash_map::generic_iterator (STL/CLR)hash_map::generic_iterator (STL/CLR)

El tipo de iterador para su uso con la interfaz genérica para el contenedor.The type of an iterator for use with the generic interface for the container.

SintaxisSyntax

typedef Microsoft::VisualC::StlClr::Generic::
    ContainerBidirectionalIterator<generic_value>
    generic_iterator;

ComentariosRemarks

El tipo describe un iterador genérico que puede usarse con la interfaz genérica para esta clase de contenedor de plantilla.The type describes a generic iterator that can be used with the generic interface for this template container class.

EjemploExample

// cliext_hash_map_generic_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Myhash_map::generic_container^ gc1 = %c1;
    for each (Myhash_map::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // get an element and display it
    Myhash_map::generic_iterator gcit = gc1->begin();
    Myhash_map::generic_value gcval = *gcit;
    System::Console::Write("[{0} {1}] ", gcval->first, gcval->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[a 1]

hash_map::generic_reverse_iterator (STL/CLR)hash_map::generic_reverse_iterator (STL/CLR)

El tipo de un iterador inverso para su uso con la interfaz genérica para el contenedor.The type of a reverse iterator for use with the generic interface for the container.

SintaxisSyntax

typedef Microsoft::VisualC::StlClr::Generic::
    ReverseRandomAccessIterator<generic_value>
    generic_reverse_iterator;

ComentariosRemarks

El tipo describe un iterador inverso genérico que puede usarse con la interfaz genérica para esta clase de contenedor de plantilla.The type describes a generic reverse iterator that can be used with the generic interface for this template container class.

EjemploExample

// cliext_hash_map_generic_reverse_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Myhash_map::generic_container^ gc1 = %c1;
    for each (Myhash_map::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // get an element and display it
    Myhash_map::generic_reverse_iterator gcit = gc1->rbegin();
    Myhash_map::generic_value gcval = *gcit;
    System::Console::WriteLine("[{0} {1}] ", gcval->first, gcval->second);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[c 3]

hash_map::generic_value (STL/CLR)hash_map::generic_value (STL/CLR)

El tipo de un elemento para su uso con la interfaz genérica para el contenedor.The type of an element for use with the generic interface for the container.

SintaxisSyntax

typedef GValue generic_value;

ComentariosRemarks

El tipo describe un objeto de tipo GValue que describe el valor del elemento almacenados para su uso con la interfaz genérica para esta clase de contenedor de plantilla.The type describes an object of type GValue that describes the stored element value for use with the generic interface for this template container class.

EjemploExample

// cliext_hash_map_generic_value.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Myhash_map::generic_container^ gc1 = %c1;
    for each (Myhash_map::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // get an element and display it
    Myhash_map::generic_iterator gcit = gc1->begin();
    Myhash_map::generic_value gcval = *gcit;
    System::Console::WriteLine("[{0} {1}] ", gcval->first, gcval->second);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[a 1]

hash_map::hash_delegate (STL/CLR)hash_map::hash_delegate (STL/CLR)

Busca un elemento que coincide con una clave especificada.Finds an element that matches a specified key.

SintaxisSyntax

hasher^ hash_delegate();

ComentariosRemarks

La función miembro devuelve al delegado que se usa para convertir un valor de clave en un entero.The member function returns the delegate used to convert a key value to an integer. Se usa para una clave de hash.You use it to hash a key.

EjemploExample

// cliext_hash_map_hash_delegate.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    Myhash_map::hasher^ myhash = c1.hash_delegate();

    System::Console::WriteLine("hash(L'a') = {0}", myhash(L'a'));
    System::Console::WriteLine("hash(L'b') = {0}", myhash(L'b'));
    return (0);
    }
hash(L'a') = 1616896120
hash(L'b') = 570892832

hash_map::hash_map (STL/CLR)hash_map::hash_map (STL/CLR)

Construye un objeto contenedor.Constructs a container object.

SintaxisSyntax

hash_map();
explicit hash_map(key_compare^ pred);
hash_map(key_compare^ pred, hasher^ hashfn);
hash_map(hash_map<Key, Mapped>% right);
hash_map(hash_map<Key, Mapped>^ right);
template<typename InIter>
    hash_maphash_map(InIter first, InIter last);
template<typename InIter>
    hash_map(InIter first, InIter last,
        key_compare^ pred);
template<typename InIter>
    hash_map(InIter first, InIter last,
        key_compare^ pred, hasher^ hashfn);
hash_map(System::Collections::Generic::IEnumerable<GValue>^ right);
hash_map(System::Collections::Generic::IEnumerable<GValue>^ right,
    key_compare^ pred);
hash_map(System::Collections::Generic::IEnumerable<GValue>^ right,
    key_compare^ pred, hasher^ hashfn);

ParámetrosParameters

firstfirst
Principio del intervalo que se va a insertar.Beginning of range to insert.

hashfnhashfn
Función para las claves de asignación a los depósitos de hash.Hash function for mapping keys to buckets.

lastlast
Fin del intervalo que se va a insertar.End of range to insert.

predpred
Orden de predicado de la secuencia controlada.Ordering predicate for the controlled sequence.

rightright
Objeto o intervalo que se va a insertar.Object or range to insert.

ComentariosRemarks

El constructor:The constructor:

hash_map();

Inicializa la secuencia controlada sin elementos, con el valor predeterminado ordenación predicado key_compare()y con la función hash predeterminada.initializes the controlled sequence with no elements, with the default ordering predicate key_compare(), and with the default hash function. Se usa para especificar una secuencia controlada inicial vacía, con el valor predeterminado ordenación en función de predicado y hash.You use it to specify an empty initial controlled sequence, with the default ordering predicate and hash function.

El constructor:The constructor:

explicit hash_map(key_compare^ pred);

Inicializa la secuencia controlada con ningún elemento con el predicado de ordenación predy con la función hash predeterminada.initializes the controlled sequence with no elements, with the ordering predicate pred, and with the default hash function. Se usa para especificar una secuencia controlada inicial vacía, con el predicado de ordenación especificado y la función hash predeterminada.You use it to specify an empty initial controlled sequence, with the specified ordering predicate and the default hash function.

El constructor:The constructor:

hash_map(key_compare^ pred, hasher^ hashfn);

Inicializa la secuencia controlada con ningún elemento con el predicado de ordenación predy con la función hash hashfn.initializes the controlled sequence with no elements, with the ordering predicate pred, and with the hash function hashfn. Se usa para especificar una secuencia controlada inicial vacía, con la función de predicado y hash de ordenación especificada.You use it to specify an empty initial controlled sequence, with the specified ordering predicate and hash function.

El constructor:The constructor:

hash_map(hash_map<Key, Mapped>% right);

Inicializa la secuencia controlada por la secuencia [right.begin(), right.end()), con el predicado del orden de predeterminado y con la función hash predeterminada.initializes the controlled sequence with the sequence [right.begin(), right.end()), with the default ordering predicate, and with the default hash function. Se usa para especificar una secuencia controlada inicial que es una copia de la secuencia controlada por el objeto hash_map derecho, con el predicado de ordenación predeterminada y la función hash.You use it to specify an initial controlled sequence that is a copy of the sequence controlled by the hash_map object right, with the default ordering predicate and hash function.

El constructor:The constructor:

hash_map(hash_map<Key, Mapped>^ right);

Inicializa la secuencia controlada por la secuencia [right->begin(), right->end()), con el predicado del orden de predeterminado y con la función hash predeterminada.initializes the controlled sequence with the sequence [right->begin(), right->end()), with the default ordering predicate, and with the default hash function. Se usa para especificar una secuencia controlada inicial que es una copia de la secuencia controlada por el objeto hash_map derecho, con el predicado de ordenación predeterminada y la función hash.You use it to specify an initial controlled sequence that is a copy of the sequence controlled by the hash_map object right, with the default ordering predicate and hash function.

El constructor:The constructor:

template<typename InIter> hash_map(InIter first, InIter last);

Inicializa la secuencia controlada por la secuencia [first, last), con el predicado del orden de predeterminado y con la función hash predeterminada.initializes the controlled sequence with the sequence [first, last), with the default ordering predicate, and with the default hash function. Usarlo para realizar una copia de otra secuencia de la secuencia controlada con el valor predeterminado ordenación en función de predicado y hash.You use it to make the controlled sequence a copy of another sequence, with the default ordering predicate and hash function.

El constructor:The constructor:

template<typename InIter> hash_map(InIter first, InIter last, key_compare^ pred);

Inicializa la secuencia controlada por la secuencia [first, last), con el predicado de ordenación predy con la función hash predeterminada.initializes the controlled sequence with the sequence [first, last), with the ordering predicate pred, and with the default hash function. Usa para realizar una copia de otra secuencia, con el predicado de ordenación especificado y la función hash predeterminada de la secuencia controlada.You use it to make the controlled sequence a copy of another sequence, with the specified ordering predicate and the default hash function.

El constructor:The constructor:

template<typename InIter> hash_map(InIter first, InIter last, key_compare^ pred, hasher^ hashfn);

Inicializa la secuencia controlada por la secuencia [first, last), con el predicado de ordenación predy con la función hash hashfn.initializes the controlled sequence with the sequence [first, last), with the ordering predicate pred, and with the hash function hashfn. Usa para realizar una copia de otra secuencia, con la función de predicado y hash de ordenación especificada de la secuencia controlada.You use it to make the controlled sequence a copy of another sequence, with the specified ordering predicate and hash function.

El constructor:The constructor:

hash_map(System::Collections::Generic::IEnumerable<Key>^ right);

Inicializa la secuencia controlada con la secuencia designada por el enumerador derecho, con el predicado del orden de predeterminado y con la función hash predeterminada.initializes the controlled sequence with the sequence designated by the enumerator right, with the default ordering predicate, and with the default hash function. Usa para realizar una copia de otra secuencia que se describe mediante un enumerador, con el valor predeterminado ordenación en función de predicado y hash de la secuencia controlada.You use it to make the controlled sequence a copy of another sequence described by an enumerator, with the default ordering predicate and hash function.

El constructor:The constructor:

hash_map(System::Collections::Generic::IEnumerable<Key>^ right, key_compare^ pred);

Inicializa la secuencia controlada con la secuencia designada por el enumerador derecho, con el predicado de ordenación predy con la función hash predeterminada.initializes the controlled sequence with the sequence designated by the enumerator right, with the ordering predicate pred, and with the default hash function. Usa para realizar una copia de otra secuencia descrita por un enumerador con la ordenación predeterminada y el predicado hash función especificada de la secuencia controlada.You use it to make the controlled sequence a copy of another sequence described by an enumerator, with the specified ordering predicate and default hash function.

El constructor:The constructor:

hash_map(System::Collections::Generic::IEnumerable<Key>^ right, key_compare^ pred, hasher^ hashfn);

Inicializa la secuencia controlada con la secuencia designada por el enumerador derecho, con el predicado de ordenación predy con la función hash hashfn.initializes the controlled sequence with the sequence designated by the enumerator right, with the ordering predicate pred, and with the hash function hashfn. Usa para realizar una copia de otra secuencia descrita por un enumerador con la función de predicado y hash de ordenación especificado de la secuencia controlada.You use it to make the controlled sequence a copy of another sequence described by an enumerator, with the specified ordering predicate and hash function.

EjemploExample

// cliext_hash_map_construct.cpp
// compile with: /clr
#include <cliext/hash_map>

int myfun(wchar_t key)
    { // hash a key
    return (key ^ 0xdeadbeef);
    }

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
// construct an empty container
    Myhash_map c1;
    System::Console::WriteLine("size() = {0}", c1.size());

    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct with an ordering rule
    Myhash_map c2 = cliext::greater_equal<wchar_t>();
    System::Console::WriteLine("size() = {0}", c2.size());

    c2.insert(c1.begin(), c1.end());
    for each (Myhash_map::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct with an ordering rule and hash function
    Myhash_map c2h(cliext::greater_equal<wchar_t>(),
        gcnew Myhash_map::hasher(&myfun));
    System::Console::WriteLine("size() = {0}", c2h.size());

    c2h.insert(c1.begin(), c1.end());
    for each (Myhash_map::value_type elem in c2h)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    System::Console::WriteLine();

    // construct with an iterator range
    Myhash_map c3(c1.begin(), c1.end());
    for each (Myhash_map::value_type elem in c3)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct with an iterator range and an ordering rule
    Myhash_map c4(c1.begin(), c1.end(),
        cliext::greater_equal<wchar_t>());
    for each (Myhash_map::value_type elem in c4)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct with an iterator range and an ordering rule and hash function
    Myhash_map c4h(c1.begin(), c1.end(),
        cliext::greater_equal<wchar_t>(),
        gcnew Myhash_map::hasher(&myfun));
    for each (Myhash_map::value_type elem in c4h)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    System::Console::WriteLine();

    // construct with an enumeration
    Myhash_map c5(   // NOTE: cast is not needed
        (System::Collections::Generic::IEnumerable<
            Myhash_map::value_type>^)%c3);
    for each (Myhash_map::value_type elem in c5)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct with an enumeration and an ordering rule
    Myhash_map c6(   // NOTE: cast is not needed
        (System::Collections::Generic::IEnumerable<
            Myhash_map::value_type>^)%c3,
                cliext::greater_equal<wchar_t>());
    for each (Myhash_map::value_type elem in c6)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct with an enumeration and an ordering rule and hash function
    Myhash_map c6h(   // NOTE: cast is not needed
        (System::Collections::Generic::IEnumerable<
            Myhash_map::value_type>^)%c3,
                cliext::greater_equal<wchar_t>(),
                gcnew Myhash_map::hasher(&myfun));
    for each (Myhash_map::value_type elem in c6h)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    System::Console::WriteLine();

    // construct by copying another container
    Myhash_map c7(c4);
    for each (Myhash_map::value_type elem in c7)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct by copying a container handle
    Myhash_map c8(%c3);
    for each (Myhash_map::value_type elem in c8)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
size() = 0
[a 1] [b 2] [c 3]
size() = 0
[a 1] [b 2] [c 3]
size() = 0
[c 3] [b 2] [a 1]

[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[c 3] [b 2] [a 1]

[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[c 3] [b 2] [a 1]

[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]

hash_map::hasher (STL/CLR)hash_map::hasher (STL/CLR)

El delegado de hash para una clave.The hashing delegate for a key.

SintaxisSyntax

Microsoft::VisualC::StlClr::UnaryDelegate<GKey, int>
    hasher;

ComentariosRemarks

El tipo describe a un delegado que convierte un valor de clave en un entero.The type describes a delegate that converts a key value to an integer.

EjemploExample

// cliext_hash_map_hasher.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    Myhash_map::hasher^ myhash = c1.hash_delegate();

    System::Console::WriteLine("hash(L'a') = {0}", myhash(L'a'));
    System::Console::WriteLine("hash(L'b') = {0}", myhash(L'b'));
    return (0);
    }
hash(L'a') = 1616896120
hash(L'b') = 570892832

hash_map::insert (STL/CLR)hash_map::insert (STL/CLR)

Agrega elementos.Adds elements.

SintaxisSyntax

cliext::pair<iterator, bool> insert(value_type val);
iterator insert(iterator where, value_type val);
template<typename InIter>
    void insert(InIter first, InIter last);
void insert(System::Collections::Generic::IEnumerable<value_type>^ right);

ParámetrosParameters

firstfirst
Principio del intervalo que se va a insertar.Beginning of range to insert.

lastlast
Fin del intervalo que se va a insertar.End of range to insert.

rightright
Enumeración que se va a insertar.Enumeration to insert.

valval
Valor de clave se va a insertar.Key value to insert.

wherewhere
Lugar en el contenedor que se va a insertar (sugerencia solo).Where in container to insert (hint only).

ComentariosRemarks

Cada una de las funciones miembro inserta una secuencia especificada por los operandos restantes.Each of the member functions inserts a sequence specified by the remaining operands.

La primera función miembro protegida intenta insertar un elemento con el valor valy devuelve un par de valores X.The first member function endeavors to insert an element with value val, and returns a pair of values X. Si X.second es true, X.first designa el elemento recién insertado; en caso contrario X.first designa un elemento con el equivalente de ordenación que ya existe y no se inserta ningún elemento nuevo.If X.second is true, X.first designates the newly inserted element; otherwise X.first designates an element with equivalent ordering that already exists and no new element is inserted. Usarlo para insertar un elemento único.You use it to insert a single element.

La segunda función miembro inserta un elemento con el valor valcon donde como una sugerencia (para mejorar el rendimiento) y devuelve un iterador que designa el elemento recién insertado.The second member function inserts an element with value val, using where as a hint (to improve performance), and returns an iterator that designates the newly inserted element. Usarlo para insertar un elemento único que podría ser adyacente a un elemento que conoce.You use it to insert a single element which might be adjacent to an element you know.

La tercera función miembro inserta la secuencia [first, last).The third member function inserts the sequence [first, last). Usa para insertar cero o más de los elementos copiados desde la otra secuencia.You use it to insert zero or more elements copied from another sequence.

La cuarta función miembro inserta la secuencia designada por el derecho.The fourth member function inserts the sequence designated by the right. Usa para insertar una secuencia descrita por un enumerador.You use it to insert a sequence described by an enumerator.

Inserción de cada elemento tarda tiempo proporcional al logaritmo del número de elementos de la secuencia controlada.Each element insertion takes time proportional to the logarithm of the number of elements in the controlled sequence. Inserción puede producirse en tiempo constante amortizado, sin embargo, dada una sugerencia que designa un elemento adyacente al punto de inserción.Insertion can occur in amortized constant time, however, given a hint that designates an element adjacent to the insertion point.

EjemploExample

// cliext_hash_map_insert.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
typedef Myhash_map::pair_iter_bool Pairib;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // insert a single value, unique and duplicate
    Pairib pair1 =
        c1.insert(Myhash_map::make_value(L'x', 24));
    System::Console::WriteLine("insert([L'x' 24]) = [{0} {1}] {2}",
        pair1.first->first, pair1.first->second, pair1.second);

    pair1 = c1.insert(Myhash_map::make_value(L'b', 2));
    System::Console::WriteLine("insert([L'b' 2]) = [{0} {1}] {2}",
        pair1.first->first, pair1.first->second, pair1.second);

    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // insert a single value with hint
    Myhash_map::iterator it =
        c1.insert(c1.begin(), Myhash_map::make_value(L'y', 25));
    System::Console::WriteLine("insert(begin(), [L'y' 25]) = [{0} {1}]",
        it->first, it->second);
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // insert an iterator range
    Myhash_map c2;
    it = c1.end();
    c2.insert(c1.begin(), --it);
    for each (Myhash_map::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // insert an enumeration
    Myhash_map c3;
    c3.insert(   // NOTE: cast is not needed
        (System::Collections::Generic::
            IEnumerable<Myhash_map::value_type>^)%c1);
    for each (Myhash_map::value_type elem in c3)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
insert([L'x' 24]) = [x 24] True
insert([L'b' 2]) = [b 2] False
[a 1] [b 2] [c 3] [x 24]
insert(begin(), [L'y' 25]) = [y 25]
[a 1] [b 2] [c 3] [x 24] [y 25]
[a 1] [b 2] [c 3] [x 24]
[a 1] [b 2] [c 3] [x 24] [y 25]

hash_map::iterator (STL/CLR)hash_map::iterator (STL/CLR)

El tipo de un iterador para la secuencia controlada.The type of an iterator for the controlled sequence.

SintaxisSyntax

typedef T1 iterator;

ComentariosRemarks

El tipo describe un objeto de tipo sin especificar T1 que puede actuar como un iterador bidireccional para la secuencia controlada.The type describes an object of unspecified type T1 that can serve as a bidirectional iterator for the controlled sequence.

EjemploExample

// cliext_hash_map_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    Myhash_map::iterator it = c1.begin();
    for (; it != c1.end(); ++it)
        System::Console::Write("[{0} {1}] ", it->first, it->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

hash_map::key_comp (STL/CLR)hash_map::key_comp (STL/CLR)

Copia al delegado de ordenación de dos claves.Copies the ordering delegate for two keys.

SintaxisSyntax

key_compare^key_comp();

ComentariosRemarks

La función miembro devuelve al delegado de ordenación utilizado para ordenar la secuencia controlada.The member function returns the ordering delegate used to order the controlled sequence. Usa para comparar dos claves.You use it to compare two keys.

EjemploExample

// cliext_hash_map_key_comp.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    Myhash_map::key_compare^ kcomp = c1.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    System::Console::WriteLine();

    // test a different ordering rule
    Myhash_map c2 = cliext::greater<wchar_t>();
    kcomp = c2.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    return (0);
    }
compare(L'a', L'a') = True
compare(L'a', L'b') = True
compare(L'b', L'a') = False

compare(L'a', L'a') = False
compare(L'a', L'b') = False
compare(L'b', L'a') = True

hash_map::key_compare (STL/CLR)hash_map::key_compare (STL/CLR)

Delegado de ordenación para dos claves.The ordering delegate for two keys.

SintaxisSyntax

Microsoft::VisualC::StlClr::BinaryDelegate<GKey, GKey, bool>
    key_compare;

ComentariosRemarks

El tipo es un sinónimo para el delegado que determina el orden de sus argumentos de la claves.The type is a synonym for the delegate that determines the ordering of its key arguments.

EjemploExample

// cliext_hash_map_key_compare.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    Myhash_map::key_compare^ kcomp = c1.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    System::Console::WriteLine();

    // test a different ordering rule
    Myhash_map c2 = cliext::greater<wchar_t>();
    kcomp = c2.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    return (0);
    }
compare(L'a', L'a') = True
compare(L'a', L'b') = True
compare(L'b', L'a') = False

compare(L'a', L'a') = False
compare(L'a', L'b') = False
compare(L'b', L'a') = True

hash_map::key_type (STL/CLR)hash_map::key_type (STL/CLR)

El tipo de una clave de ordenación.The type of an ordering key.

SintaxisSyntax

typedef Key key_type;

ComentariosRemarks

El tipo es un sinónimo del parámetro de plantilla clave.The type is a synonym for the template parameter Key.

EjemploExample

// cliext_hash_map_key_type.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]" using key_type
    for (Myhash_map::iterator it = c1.begin(); it != c1.end(); ++it)
        {   // store element in key_type object
        Myhash_map::key_type val = it->first;

        System::Console::Write("{0} ", val);
        }
    System::Console::WriteLine();
    return (0);
    }
a b c

hash_map::load_factor (STL/CLR)hash_map::load_factor (STL/CLR)

Cuenta los elementos promedio por depósito.Counts the average elements per bucket.

SintaxisSyntax

float load_factor();

ComentariosRemarks

La función miembro devuelve (float) hash_map:: Size (STL/CLR) () / hash_map::bucket_count (STL/CLR)().The member function returns (float)hash_map::size (STL/CLR)() / hash_map::bucket_count (STL/CLR)(). Se usa para determinar el tamaño de depósito promedio.You use it to determine the average bucket size.

EjemploExample

// cliext_hash_map_load_factor.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1 = gcnew Myhash_map;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect current parameters
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // change max_load_factor and redisplay
    c1.max_load_factor(0.25f);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // rehash and redisplay
    c1.rehash(100);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    return (0);
    }
[a 1] [b 2] [c 3]
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4

bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25

bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25

hash_map::lower_bound (STL/CLR)hash_map::lower_bound (STL/CLR)

Busca el principio del intervalo que coincide con una clave especificada.Finds beginning of range that matches a specified key.

SintaxisSyntax

iterator lower_bound(key_type key);

ParámetrosParameters

keykey
Valor de clave que se va a buscar.Key value to search for.

ComentariosRemarks

La función miembro determina el primer elemento X en la secuencia controlada que aplica un algoritmo hash al mismo depósito que clave y tiene una ordenación equivalente a clave.The member function determines the first element X in the controlled sequence that hashes to the same bucket as key and has equivalent ordering to key. Si no existe ese elemento, devuelve hash_map:: end (STL/CLR)(); en caso contrario, devuelve un iterador que designa X.If no such element exists, it returns hash_map::end (STL/CLR)(); otherwise it returns an iterator that designates X. Usa para buscar el principio de una secuencia de elementos actualmente en la secuencia controlada que coinciden con una clave especificada.You use it to locate the beginning of a sequence of elements currently in the controlled sequence that match a specified key.

EjemploExample

// cliext_hash_map_lower_bound.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("lower_bound(L'x')==end() = {0}",
        c1.lower_bound(L'x') == c1.end());

    Myhash_map::iterator it = c1.lower_bound(L'a');
    System::Console::WriteLine("*lower_bound(L'a') = [{0} {1}]",
        it->first, it->second);
    it = c1.lower_bound(L'b');
    System::Console::WriteLine("*lower_bound(L'b') = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
lower_bound(L'x')==end() = True
*lower_bound(L'a') = [a 1]
*lower_bound(L'b') = [b 2]

hash_map::make_value (STL/CLR)hash_map::make_value (STL/CLR)

Construye un objeto de valor.Constructs a value object.

SintaxisSyntax

static value_type make_value(key_type key, mapped_type mapped);

ParámetrosParameters

keykey
Valor de clave para usar.Key value to use.

mappedmapped
Valor asignado a buscar.Mapped value to search for.

ComentariosRemarks

La función miembro devuelve un value_type objeto cuya clave es clave y cuyo valor asignado es asignado.The member function returns a value_type object whose key is key and whose mapped value is mapped. Usarlo para crear un objeto adecuado para su uso con otras funciones de miembro.You use it to compose an object suitable for use with several other member functions.

EjemploExample

// cliext_hash_map_make_value.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

hash_map::mapped_type (STL/CLR)hash_map::mapped_type (STL/CLR)

El tipo de un valor asignado asociado a cada clave.The type of a mapped value associated with each key.

SintaxisSyntax

typedef Mapped mapped_type;

ComentariosRemarks

El tipo es un sinónimo del parámetro de plantilla Mapped.The type is a synonym for the template parameter Mapped.

EjemploExample

// cliext_hash_map_mapped_type.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]" using mapped_type
    for (Myhash_map::iterator it = c1.begin(); it != c1.end(); ++it)
        {   // store element in mapped_type object
        Myhash_map::mapped_type val = it->second;

        System::Console::Write("{0} ", val);
        }
    System::Console::WriteLine();
    return (0);
    }
1 2 3

hash_map::max_load_factor (STL/CLR)hash_map::max_load_factor (STL/CLR)

Obtiene o establece los elementos máximos por depósito.Gets or sets the maximum elements per bucket.

SintaxisSyntax

float max_load_factor();
void max_load_factor(float new_factor);

ParámetrosParameters

new_factornew_factor
Nuevo máximo cargar factor que hay que almacenar.New maximum load factor to store.

ComentariosRemarks

La primera función miembro devuelve el factor de carga máxima almacenado actual.The first member function returns the current stored maximum load factor. Se usa para determinar el tamaño máximo de depósito promedio.You use it to determine the maximum average bucket size.

La segunda función miembro reemplaza el factor de carga máxima de la tienda con new_factor.The second member function replaces the store maximum load factor with new_factor. Ningún recombinando automática se produce hasta que una inserción posteriores.No automatic rehashing occurs until a subsequent insert.

EjemploExample

// cliext_hash_map_max_load_factor.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1 = gcnew Myhash_map;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect current parameters
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // change max_load_factor and redisplay
    c1.max_load_factor(0.25f);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // rehash and redisplay
    c1.rehash(100);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    return (0);
    }
[a 1] [b 2] [c 3]
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4

bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25

bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25

hash_map::operator= (STL/CLR)hash_map::operator= (STL/CLR)

Reemplaza la secuencia controlada.Replaces the controlled sequence.

SintaxisSyntax

hash_map<Key, Mapped>% operator=(hash_map<Key, Mapped>% right);

ParámetrosParameters

rightright
Contenedor que se va a copiar.Container to copy.

ComentariosRemarks

Las copias de operador miembro derecho al objeto, a continuación, devuelve *this.The member operator copies right to the object, then returns *this. Se usa para reemplazar la secuencia controlada por una copia de la secuencia controlada en derecho.You use it to replace the controlled sequence with a copy of the controlled sequence in right.

EjemploExample

// cliext_hash_map_operator_as.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // assign to a new container
    Myhash_map c2;
    c2 = c1;
// display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]

hash_map::operator(STL/CLR)hash_map::operator(STL/CLR)

Asigna una clave a su valor asignado asociado.Maps a key to its associated mapped value.

SintaxisSyntax

mapped_type operator[](key_type key);

ParámetrosParameters

keykey
Valor de clave que se va a buscar.Key value to search for.

ComentariosRemarks

Las funciones miembro para encontrar un elemento con una ordenación equivalente a los esfuerzos de clave.The member functions endeavors to find an element with equivalent ordering to key. Si lo encuentra, devuelve el valor asignado asociado; en caso contrario, inserta value_type(key, mapped_type()) y devuelve los asociados (valor predeterminado) asigna el valor.If it finds one, it returns the associated mapped value; otherwise, it inserts value_type(key, mapped_type()) and returns the associated (default) mapped value. Usa para buscar un valor asignado tiene su clave asociada, o para asegurarse de que existe una entrada para la clave si se encuentra ninguno.You use it to look up a mapped value given its associated key, or to ensure that an entry exists for the key if none is found.

EjemploExample

// cliext_hash_map_operator_sub.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("c1[{0}] = {1}",
        L'A', c1[L'A']);
    System::Console::WriteLine("c1[{0}] = {1}",
        L'b', c1[L'b']);

    // redisplay altered contents
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // alter mapped values and redisplay
    c1[L'A'] = 10;
    c1[L'c'] = 13;
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
c1[A] = 0
c1[b] = 2
[a 1] [A 0] [b 2] [c 3]
[a 1] [A 10] [b 2] [c 13]

hash_map::rbegin (STL/CLR)hash_map::rbegin (STL/CLR)

Designa el principio de la secuencia controlada inversa.Designates the beginning of the reversed controlled sequence.

SintaxisSyntax

reverse_iterator rbegin();

ComentariosRemarks

La función miembro devuelve un iterador inverso que designa el último elemento de la secuencia controlada o inmediatamente después del principio de una secuencia vacía.The member function returns a reverse iterator that designates the last element of the controlled sequence, or just beyond the beginning of an empty sequence. Por tanto, designa el beginning de la secuencia inversa.Hence, it designates the beginning of the reverse sequence. Se usa para obtener un iterador que designa el current principio de la secuencia controlada mostrada en orden inverso, pero su estado puede cambiar si cambia la longitud de la secuencia controlada.You use it to obtain an iterator that designates the current beginning of the controlled sequence seen in reverse order, but its status can change if the length of the controlled sequence changes.

EjemploExample

// cliext_hash_map_rbegin.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect first two items in reversed sequence
    Myhash_map::reverse_iterator rit = c1.rbegin();
    System::Console::WriteLine("*rbegin() = [{0} {1}]",
        rit->first, rit->second);
    ++rit;
    System::Console::WriteLine("*++rbegin() = [{0} {1}]",
        rit->first, rit->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*rbegin() = [c 3]
*++rbegin() = [b 2]

hash_map::reference (STL/CLR)hash_map::reference (STL/CLR)

El tipo de una referencia a un elemento.The type of a reference to an element.

SintaxisSyntax

typedef value_type% reference;

ComentariosRemarks

El tipo describe una referencia a un elemento.The type describes a reference to an element.

EjemploExample

// cliext_hash_map_reference.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    Myhash_map::iterator it = c1.begin();
    for (; it != c1.end(); ++it)
        {   // get a reference to an element
        Myhash_map::reference ref = *it;
        System::Console::Write("[{0} {1}] ", ref->first, ref->second);
        }
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

hash_map::rehash (STL/CLR)hash_map::rehash (STL/CLR)

Recompila la tabla hash.Rebuilds the hash table.

SintaxisSyntax

void rehash();

ComentariosRemarks

La función miembro se vuelve a generar la tabla hash, lo que garantiza que hash_map::load_factor (STL/CLR) () <= hash_map::max_load_factor (STL/CLR).The member function rebuilds the hash table, ensuring that hash_map::load_factor (STL/CLR)() <= hash_map::max_load_factor (STL/CLR). En caso contrario, la tabla hash aumenta de tamaño según sea necesario después de una inserción.Otherwise, the hash table increases in size only as needed after an insertion. (Nunca disminuye de tamaño automáticamente.) Usa para ajustar el tamaño de la tabla hash.(It never automatically decreases in size.) You use it to adjust the size of the hash table.

EjemploExample

// cliext_hash_map_rehash.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1 = gcnew Myhash_map;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect current parameters
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // change max_load_factor and redisplay
    c1.max_load_factor(0.25f);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    System::Console::WriteLine();

    // rehash and redisplay
    c1.rehash(100);
    System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
    System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
    System::Console::WriteLine("max_load_factor() = {0}",
        c1.max_load_factor());
    return (0);
    }
[a 1] [b 2] [c 3]
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4

bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25

bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25

hash_map::rend (STL/CLR)hash_map::rend (STL/CLR)

Designa el final de la secuencia controlada inversa.Designates the end of the reversed controlled sequence.

SintaxisSyntax

reverse_iterator rend();

ComentariosRemarks

La función miembro devuelve un iterador inverso que apunta inmediatamente después del principio de la secuencia controlada.The member function returns a reverse iterator that points just beyond the beginning of the controlled sequence. Por tanto, designa el end de la secuencia inversa.Hence, it designates the end of the reverse sequence. Se usa para obtener un iterador que designa el current final de la secuencia controlada mostrada en orden inverso, pero su estado puede cambiar si cambia la longitud de la secuencia controlada.You use it to obtain an iterator that designates the current end of the controlled sequence seen in reverse order, but its status can change if the length of the controlled sequence changes.

EjemploExample

// cliext_hash_map_rend.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect first two items in reversed sequence
    Myhash_map::reverse_iterator rit = c1.rend();
    --rit;
    --rit;
    System::Console::WriteLine("*-- --rend() = [{0} {1}]",
        rit->first, rit->second);
    ++rit;
    System::Console::WriteLine("*--rend() = [{0} {1}]",
        rit->first, rit->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*-- --rend() = [b 2]
*--rend() = [a 1]

hash_map::reverse_iterator (STL/CLR)hash_map::reverse_iterator (STL/CLR)

El tipo de un iterador invertido para la secuencia controlada.The type of a reverse iterator for the controlled sequence.

SintaxisSyntax

typedef T3 reverse_iterator;

ComentariosRemarks

El tipo describe un objeto de tipo sin especificar T3 que puede actuar como un iterador inverso de la secuencia controlada.The type describes an object of unspecified type T3 that can serve as a reverse iterator for the controlled sequence.

EjemploExample

// cliext_hash_map_reverse_iterator.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]" reversed
    Myhash_map::reverse_iterator rit = c1.rbegin();
    for (; rit != c1.rend(); ++rit)
        System::Console::Write("[{0} {1}] ", rit->first, rit->second);
    System::Console::WriteLine();
    return (0);
    }
[c 3] [b 2] [a 1]

hash_map::size (STL/CLR)hash_map::size (STL/CLR)

Cuenta el número de elementos.Counts the number of elements.

SintaxisSyntax

size_type size();

ComentariosRemarks

La función miembro devuelve la longitud de la secuencia controlada.The member function returns the length of the controlled sequence. Se usa para determinar el número de elementos actualmente en la secuencia controlada.You use it to determine the number of elements currently in the controlled sequence. Si lo único que interesa es si la secuencia tiene un tamaño distinto de cero, vea hash_map:: Empty (STL/CLR)().If all you care about is whether the sequence has nonzero size, see hash_map::empty (STL/CLR)().

EjemploExample

// cliext_hash_map_size.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // clear the container and reinspect
    c1.clear();
    System::Console::WriteLine("size() = {0} after clearing", c1.size());

    // add elements and clear again
    c1.insert(Myhash_map::make_value(L'd', 4));
    c1.insert(Myhash_map::make_value(L'e', 5));
    System::Console::WriteLine("size() = {0} after adding 2", c1.size());
    return (0);
    }
[a 1] [b 2] [c 3]
size() = 0 after clearing
size() = 2 after adding 2

hash_map::size_type (STL/CLR)hash_map::size_type (STL/CLR)

El tipo de una distancia con signo entre dos elementos.The type of a signed distance between two element.

SintaxisSyntax

typedef int size_type;

ComentariosRemarks

El tipo describe un recuento de elemento no negativo.The type describes a non-negative element count.

EjemploExample

// cliext_hash_map_size_type.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // compute positive difference
    Myhash_map::size_type diff = 0;
    for (Myhash_map::iterator it = c1.begin(); it != c1.end(); ++it)
        ++diff;
    System::Console::WriteLine("end()-begin() = {0}", diff);
    return (0);
    }
[a 1] [b 2] [c 3]
end()-begin() = 3

hash_map::swap (STL/CLR)hash_map::swap (STL/CLR)

Intercambia el contenido de dos contenedores.Swaps the contents of two containers.

SintaxisSyntax

void swap(hash_map<Key, Mapped>% right);

ParámetrosParameters

rightright
Contenedor con el que se va a intercambiar el contenido.Container to swap contents with.

ComentariosRemarks

La función miembro intercambia las secuencias controladas entre this y derecho.The member function swaps the controlled sequences between this and right. Lo hace en tiempo constante y no inicia ninguna excepción.It does so in constant time and it throws no exceptions. Úselo como una forma rápida para intercambiar el contenido de dos contenedores.You use it as a quick way to exchange the contents of two containers.

EjemploExample

// cliext_hash_map_swap.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct another container with repetition of values
    Myhash_map c2;
    c2.insert(Myhash_map::make_value(L'd', 4));
    c2.insert(Myhash_map::make_value(L'e', 5));
    c2.insert(Myhash_map::make_value(L'f', 6));
    for each (Myhash_map::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // swap and redisplay
    c1.swap(c2);
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    for each (Myhash_map::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[d 4] [e 5] [f 6]
[d 4] [e 5] [f 6]
[a 1] [b 2] [c 3]

hash_map::to_array (STL/CLR)hash_map::to_array (STL/CLR)

Copia la secuencia controlada a una nueva matriz.Copies the controlled sequence to a new array.

SintaxisSyntax

cli::array<value_type>^ to_array();

ComentariosRemarks

La función miembro devuelve una matriz que contiene la secuencia controlada.The member function returns an array containing the controlled sequence. Se usa para obtener una copia de la secuencia controlada en forma de matriz.You use it to obtain a copy of the controlled sequence in array form.

EjemploExample

// cliext_hash_map_to_array.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // copy the container and modify it
    cli::array<Myhash_map::value_type>^ a1 = c1.to_array();

    c1.insert(Myhash_map::make_value(L'd', 4));
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // display the earlier array copy
    for each (Myhash_map::value_type elem in a1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3] [d 4]
[a 1] [b 2] [c 3]

hash_map::upper_bound (STL/CLR)hash_map::upper_bound (STL/CLR)

Busca el final del intervalo que coincide con una clave especificada.Finds end of range that matches a specified key.

SintaxisSyntax

iterator upper_bound(key_type key);

ParámetrosParameters

keykey
Valor de clave que se va a buscar.Key value to search for.

ComentariosRemarks

La función miembro determina el último elemento X en la secuencia controlada que aplica un algoritmo hash al mismo depósito que clave y tiene una ordenación equivalente a clave.The member function determines the last element X in the controlled sequence that hashes to the same bucket as key and has equivalent ordering to key. Si no existe ese elemento, o si X es el último elemento de la secuencia controlada, se devuelve hash_map:: end (STL/CLR)(); en caso contrario, devuelve un iterador que designa el primer elemento más allá de X.If no such element exists, or if X is the last element in the controlled sequence, it returns hash_map::end (STL/CLR)(); otherwise it returns an iterator that designates the first element beyond X. Utiliza para localizar el final de una secuencia de elementos actualmente en la secuencia controlada que coinciden con una clave especificada.You use it to locate the end of a sequence of elements currently in the controlled sequence that match a specified key.

EjemploExample

// cliext_hash_map_upper_bound.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Myhash_map::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("upper_bound(L'x')==end() = {0}",
        c1.upper_bound(L'x') == c1.end());

    Myhash_map::iterator it = c1.upper_bound(L'a');
    System::Console::WriteLine("*upper_bound(L'a') = [{0} {1}]",
        it->first, it->second);
    it = c1.upper_bound(L'b');
    System::Console::WriteLine("*upper_bound(L'b') = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
upper_bound(L'x')==end() = True
*upper_bound(L'a') = [b 2]
*upper_bound(L'b') = [c 3]

hash_map::value_comp (STL/CLR)hash_map::value_comp (STL/CLR)

Copia al delegado de ordenación de dos valores de elemento.Copies the ordering delegate for two element values.

SintaxisSyntax

value_compare^ value_comp();

ComentariosRemarks

La función miembro devuelve al delegado de ordenación utilizado para ordenar la secuencia controlada.The member function returns the ordering delegate used to order the controlled sequence. Usa para comparar dos valores de elemento.You use it to compare two element values.

EjemploExample

// cliext_hash_map_value_comp.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    Myhash_map::value_compare^ kcomp = c1.value_comp();

    System::Console::WriteLine("compare([L'a', 1], [L'a', 1]) = {0}",
        kcomp(Myhash_map::make_value(L'a', 1),
            Myhash_map::make_value(L'a', 1)));
    System::Console::WriteLine("compare([L'a', 1], [L'b', 2]) = {0}",
        kcomp(Myhash_map::make_value(L'a', 1),
            Myhash_map::make_value(L'b', 2)));
    System::Console::WriteLine("compare([L'b', 2], [L'a', 1]) = {0}",
        kcomp(Myhash_map::make_value(L'b', 2),
            Myhash_map::make_value(L'a', 1)));
    System::Console::WriteLine();
    return (0);
    }
compare([L'a', 1], [L'a', 1]) = True
compare([L'a', 1], [L'b', 2]) = True
compare([L'b', 2], [L'a', 1]) = False

hash_map::value_compare (STL/CLR)hash_map::value_compare (STL/CLR)

Delegado de ordenación para dos valores de elemento.The ordering delegate for two element values.

SintaxisSyntax

Microsoft::VisualC::StlClr::BinaryDelegate<generic_value, generic_value, bool>
    value_compare;

ComentariosRemarks

El tipo es un sinónimo para el delegado que determina el orden de sus argumentos de valor.The type is a synonym for the delegate that determines the ordering of its value arguments.

EjemploExample

// cliext_hash_map_value_compare.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    Myhash_map::value_compare^ kcomp = c1.value_comp();

    System::Console::WriteLine("compare([L'a', 1], [L'a', 1]) = {0}",
        kcomp(Myhash_map::make_value(L'a', 1),
            Myhash_map::make_value(L'a', 1)));
    System::Console::WriteLine("compare([L'a', 1], [L'b', 2]) = {0}",
        kcomp(Myhash_map::make_value(L'a', 1),
            Myhash_map::make_value(L'b', 2)));
    System::Console::WriteLine("compare([L'b', 2], [L'a', 1]) = {0}",
        kcomp(Myhash_map::make_value(L'b', 2),
            Myhash_map::make_value(L'a', 1)));
    System::Console::WriteLine();
    return (0);
    }
compare([L'a', 1], [L'a', 1]) = True
compare([L'a', 1], [L'b', 2]) = True
compare([L'b', 2], [L'a', 1]) = False

hash_map::value_type (STL/CLR)hash_map::value_type (STL/CLR)

El tipo de un elemento.The type of an element.

SintaxisSyntax

typedef generic_value value_type;

ComentariosRemarks

El tipo es un sinónimo de generic_value.The type is a synonym for generic_value.

EjemploExample

// cliext_hash_map_value_type.cpp
// compile with: /clr
#include <cliext/hash_map>

typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
    {
    Myhash_map c1;
    c1.insert(Myhash_map::make_value(L'a', 1));
    c1.insert(Myhash_map::make_value(L'b', 2));
    c1.insert(Myhash_map::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]" using value_type
    for (Myhash_map::iterator it = c1.begin(); it != c1.end(); ++it)
        {   // store element in value_type object
        Myhash_map::value_type val = *it;
        System::Console::Write("[{0} {1}] ", val->first, val->second);
        }
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]