System::Collections::Generic::Dictionary klass
Innehåll
[
Dölj
]Dictionary class
Framåtriktad deklaration av Dictionary klass.
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)>>
| Parameter | Beskrivning |
|---|---|
| TKey | Nyckeltyp. |
| TValue | Värdetyp. |
Nested classes
- Class Enumerator
Metoder
| Metod | Beskrivning |
|---|---|
| Dictionary() | Skapar tomt dictionary. |
| Dictionary(const map_t&) | Kopierar data från map. |
| Dictionary(int) | Överlagring som motsvarar att skapa en förallokerad dictionary; allokerar faktiskt inget. |
| Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&) | Kopieringskonstruktor. |
| Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&, const SharedPtr<IEqualityComparer<TKey>>&) | Kopieringskonstruktor. |
| Dictionary(const SharedPtr<IEqualityComparer<TKey>>&) | Skapar tomt dictionary. |
| Dictionary(int, const SharedPtr<IEqualityComparer<TKey>>&) | Skapar tomt dictionary. |
| GetEnumerator() override | Skapar enumeratorobjekt. |
Typedefs
| Typedef | Beskrivning |
|---|---|
| IEnumerablePtr | Pekare till enumerable-gränssnitt. |
| IEnumeratorPtr | Pekare till enumerator. |
| KeyCollection | RTTI-information. |
| KVPair | Nyckel‑värde‑par‑typ. |
| map_t | Underliggande datatyp. |
| Ptr | Pekartyp. |
| ValueCollection | Samling av värden att extrahera. |
Anmärkningar
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()
{
// Skapa instansen av Dictionary-klassen.
auto dictionary = MakeObject<Dictionary<int, String>>();
// Fyll dictionary.
dictionary->Add(0, u"Foo");
dictionary->Add(1, u"Bar");
dictionary->Add(2, u"Baz");
// Skriv ut dictionary-elementen.
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
*/
Se även
- Class BaseDictionary
- Namespace System::Collections::Generic
- Library Aspose.Page for C++