Clase System::Collections::Generic::Dictionary
Contenido
[
Ocultar
]Dictionary class
Declaración adelantada de la clase Dictionary.
template<typename TKey,typename TValue>class Dictionary : public System::Collections::Generic::BaseDictionary<std::unordered_map<TKey, TValue, EqualityComparerHashAdapter<TKey>, EqualityComparerAdapter<TKey>, ASPOSE_MAP_ALLOCATOR_TYPE(TKey, TValue)>>
| Parámetro | Descripción |
|---|---|
| TKey | Tipo de clave. |
| TValue | Tipo de valor. |
Nested classes
- Class Enumerator
Métodos
| Método | Descripción |
|---|---|
| Dictionary() | Crea un diccionario vacío. |
| Dictionary(const map_t&) | Copia datos del mapa. |
| Dictionary(int) | Sobrecarga que corresponde a crear un diccionario preasignado; en realidad no realiza asignación. |
| Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&) | Constructor de copia. |
| Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&, const SharedPtr<IEqualityComparer<TKey>>&) | Constructor de copia. |
| Dictionary(const SharedPtr<IEqualityComparer<TKey>>&) | Crea un diccionario vacío. |
| Dictionary(int, const SharedPtr<IEqualityComparer<TKey>>&) | Crea un diccionario vacío. |
| GetEnumerator() override | Crea un objeto enumerador. |
Typedefs
| Typedef | Descripción |
|---|---|
| IEnumerablePtr | Puntero a la interfaz enumerable. |
| IEnumeratorPtr | Puntero al enumerador. |
| KeyCollection | Información RTTI. |
| KVPair | Tipo de par clave-valor. |
| map_t | Tipo de datos subyacente. |
| Ptr | Tipo de puntero. |
| ValueCollection | Colección de valores a extraer. |
Observaciones
Dictionary that maps values to keys. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.
#include <system/collections/dictionary.h>
#include <system/smart_ptr.h>
using namespace System;
using namespace System::Collections::Generic;
int main()
{
// Crea la instancia de la clase Dictionary.
auto dictionary = MakeObject<Dictionary<int, String>>();
// Llena el diccionario.
dictionary->Add(0, u"Foo");
dictionary->Add(1, u"Bar");
dictionary->Add(2, u"Baz");
// Imprime los elementos del diccionario.
for (const auto &pair: dictionary)
{
std::cout << pair.get_Key() << " - " << pair.get_Value() << std::endl;
}
return 0;
}
/*
This code example produces the following output:
0 - Foo
1 - Bar
2 - Baz
*/
Ver también
- Class BaseDictionary
- Namespace System::Collections::Generic
- Library Aspose.Page for C++