System::Collections::Generic::Dictionary Klasse

Dictionary class

Vorwärtsdeklaration der 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)>>
ParameterBeschreibung
TKeySchlüsseltyp.
TValueWerttyp.

Nested classes

Methoden

MethodeBeschreibung
Dictionary()Erstellt ein leeres Wörterbuch.
Dictionary(const map_t&)Kopiert Daten von einer Map.
Dictionary(int)Überladung, die dem Erstellen eines vorab zugewiesenen Wörterbuchs entspricht; führt tatsächlich keine Zuweisung durch.
Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&)Kopierkonstruktor.
Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&, const SharedPtr<IEqualityComparer<TKey>>&)Kopierkonstruktor.
Dictionary(const SharedPtr<IEqualityComparer<TKey>>&)Erstellt ein leeres Wörterbuch.
Dictionary(int, const SharedPtr<IEqualityComparer<TKey>>&)Erstellt ein leeres Wörterbuch.
GetEnumerator() overrideErstellt ein Enumerator-Objekt.

Typedefs

Typedef.Beschreibung
IEnumerablePtrZeiger auf die aufzählbare Schnittstelle.
IEnumeratorPtrZeiger auf den Enumerator.
KeyCollectionRTTI-Informationen.
KVPairTyp für Schlüssel‑Wert‑Paar.
map_tZugrundeliegender Datentyp.
PtrZeigertyp.
ValueCollectionSammlung von Werten zum Extrahieren.

Hinweise

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()
{
  // Erstelle die Instanz der Dictionary-Klasse.
  auto dictionary = MakeObject<Dictionary<int, String>>();

  // Fülle das Wörterbuch.
  dictionary->Add(0, u"Foo");
  dictionary->Add(1, u"Bar");
  dictionary->Add(2, u"Baz");

  // Gib die Wörterbucheinträge aus.
  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
*/

Siehe auch