System::Collections::Generic::Dictionary κλάση
περιεχόμενα
[
κρύβω
]Dictionary class
Προώθηση δήλωσης της κλάσης 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 | Περιγραφή |
|---|---|
| TKey | Τύπος κλειδιού. |
| TValue | Τύπος τιμής. |
Nested classes
- Class Enumerator
Μέθοδοι
| Μέθοδος | Περιγραφή |
|---|---|
| Dictionary() | Δημιουργεί κενό λεξικό. |
| Dictionary(const map_t&) | Αντιγράφει δεδομένα από το map. |
| Dictionary(int) | Υπερφόρτωση που αντιστοιχεί στη δημιουργία προ-κατανεμημένου λεξικού· στην πραγματικότητα δεν κάνει κατανομή. |
| Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&) | Κατασκευαστής αντιγραφής. |
| Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&, const SharedPtr<IEqualityComparer<TKey>>&) | Κατασκευαστής αντιγραφής. |
| Dictionary(const SharedPtr<IEqualityComparer<TKey>>&) | Δημιουργεί κενό λεξικό. |
| Dictionary(int, const SharedPtr<IEqualityComparer<TKey>>&) | Δημιουργεί κενό λεξικό. |
| GetEnumerator() override | Δημιουργεί αντικείμενο enumerator. |
Typedefs
| Typedef | Περιγραφή |
|---|---|
| IEnumerablePtr | Δείκτης προς διεπαφή enumerable. |
| IEnumeratorPtr | Δείκτης προς enumerator. |
| KeyCollection | Πληροφορίες RTTI. |
| KVPair | Τύπος ζεύγους κλειδιού-τιμής. |
| map_t | Βασικός τύπος δεδομένων. |
| Ptr | Τύπος δείκτη. |
| ValueCollection | Συλλογή τιμών για εξαγωγή. |
Παρατηρήσεις
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()
{
// Δημιουργήστε την παρουσία της κλάσης Dictionary.
auto dictionary = MakeObject<Dictionary<int, String>>();
// Γεμίστε το λεξικό.
dictionary->Add(0, u"Foo");
dictionary->Add(1, u"Bar");
dictionary->Add(2, u"Baz");
// Εκτυπώστε τα στοιχεία του λεξικού.
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
*/
Δείτε επίσης
- Class BaseDictionary
- Namespace System::Collections::Generic
- Library Aspose.Page for C++