System::Collections::Generic::Dictionary klasse
inhoud
[
verbergen
]Dictionary class
Voorwaartse declaratie van de Dictionary klasse.
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 | Beschrijving |
|---|---|
| TKey | Sleuteltype. |
| TValue | Waarde‑type. |
Nested classes
- Class Enumerator
Methoden
| Methode | Beschrijving |
|---|---|
| Dictionary() | Maakt een leeg woordenboek. |
| Dictionary(const map_t&) | Kopieert gegevens van de map. |
| Dictionary(int) | Overload die overeenkomt met het maken van een vooraf toegewezen woordenboek; doet eigenlijk geen toewijzing. |
| Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&) | Copy-constructor. |
| Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&, const SharedPtr<IEqualityComparer<TKey>>&) | Copy-constructor. |
| Dictionary(const SharedPtr<IEqualityComparer<TKey>>&) | Maakt een leeg woordenboek. |
| Dictionary(int, const SharedPtr<IEqualityComparer<TKey>>&) | Maakt een leeg woordenboek. |
| GetEnumerator() override | Maakt een enumerator‑object aan. |
Typedefs
| Typedef | Beschrijving |
|---|---|
| IEnumerablePtr | Pointer naar de enumerable interface. |
| IEnumeratorPtr | Pointer naar enumerator. |
| KeyCollection | RTTI-informatie. |
| KVPair | Sleutel‑waarde‑paartype. |
| map_t | Onderliggend datatype. |
| Ptr | Pointertype. |
| ValueCollection | Collectie van waarden om te extraheren. |
Opmerkingen
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()
{
// Maak de Dictionary-klasse instantie aan.
auto dictionary = MakeObject<Dictionary<int, String>>();
// Vul het woordenboek.
dictionary->Add(0, u"Foo");
dictionary->Add(1, u"Bar");
dictionary->Add(2, u"Baz");
// Print de items van het woordenboek.
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
*/
Zie ook
- Class BaseDictionary
- Namespace System::Collections::Generic
- Library Aspose.Page for C++