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)>>
パラメーター説明
TKeyキーの種類です。
TValue値型です。

Nested classes

メソッド

メソッド説明
Dictionary()空の Dictionary を作成します。
Dictionary(const map_t&)map からデータをコピーします。
Dictionary(int)事前に割り当てられた Dictionary を作成することに対応するオーバーロードです。実際には割り当てを行いません。
Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&)コピーコンストラクタ。
Dictionary(const SharedPtr<IDictionary<TKey, TValue>>&, const SharedPtr<IEqualityComparer<TKey>>&)コピーコンストラクタ。
Dictionary(const SharedPtr<IEqualityComparer<TKey>>&)空の Dictionary を作成します。
Dictionary(int, const SharedPtr<IEqualityComparer<TKey>>&)空の Dictionary を作成します。
GetEnumerator() override列挙子オブジェクトを作成します。

Typedefs

型定義説明
IEnumerablePtr列挙可能インターフェイスへのポインタです。
IEnumeratorPtr列挙子へのポインタです。
KeyCollectionRTTI 情報。
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 を埋めます。
  dictionary->Add(0, u"Foo");
  dictionary->Add(1, u"Bar");
  dictionary->Add(2, u"Baz");

  // Dictionary の項目を出力します。
  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
*/

参照