kelas System::Collections::Generic::Dictionary
isi
[
bersembunyi
]Dictionary class
Deklarasi maju kelas 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)>>
| Parameter | Deskripsi |
|---|---|
| TKey | Tipe kunci. |
| TValue | Tipe nilai. |
Nested classes
- Class Enumerator
Metode
| Metode | Deskripsi |
|---|---|
| Dictionary() | Membuat kamus kosong. |
| Dictionary(const map_t&) | Menyalin data dari peta. |
| Dictionary(int) | Overload yang sesuai dengan pembuatan kamus yang telah dialokasikan sebelumnya; sebenarnya tidak melakukan alokasi. |
| Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&) | Konstruktor penyalinan. |
| Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&, const SharedPtr<IEqualityComparer<TKey>>&) | Konstruktor penyalinan. |
| Dictionary(const SharedPtr<IEqualityComparer<TKey>>&) | Membuat kamus kosong. |
| Dictionary(int, const SharedPtr<IEqualityComparer<TKey>>&) | Membuat kamus kosong. |
| GetEnumerator() override | Membuat objek enumerator. |
Typedefs
| Typedef | Deskripsi |
|---|---|
| IEnumerablePtr | Penunjuk ke antarmuka enumerable. |
| IEnumeratorPtr | Penunjuk ke enumerator. |
| KeyCollection | Informasi RTTI. |
| KVPair | Tipe pasangan kunci-nilai. |
| map_t | Tipe data dasar. |
| Ptr | Tipe pointer. |
| ValueCollection | Koleksi nilai untuk diekstrak. |
Catatan
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()
{
// Buat instance kelas Dictionary.
auto dictionary = MakeObject<Dictionary<int, String>>();
// Isi kamus.
dictionary->Add(0, u"Foo");
dictionary->Add(1, u"Bar");
dictionary->Add(2, u"Baz");
// Cetak item kamus.
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
*/
Lihat Juga
- Class BaseDictionary
- Namespace System::Collections::Generic
- Library Aspose.Page for C++