System::Collections::Concurrent::ConcurrentDictionary クラス

ConcurrentDictionary class

スレッドセーフな辞書実装です。このクラスのオブジェクトは System::MakeObject() 関数を使用してのみ割り当てるべきです。スタック上や operator new を使ってインスタンスを作成しないでください。そうしないと実行時エラーやアサーション違反が発生します。このクラスは常に System::SmartPtr ポインタでラップし、そのポインタを関数の引数として渡す際に使用してください。

template<class TKey,class TValue>class ConcurrentDictionary : public System::Collections::Generic::Dictionary<TKey, TValue>
パラメーター説明
TKeyキーの種類です。
TValue値型です。

メソッド

メソッド説明
Add(const TKey&, const TValue&) override辞書に値を追加します。
Clear() overrideコンテナ内のすべての要素を削除します。
CopyTo(ArrayPtr<System::Collections::Generic::KeyValuePair<TKey, TValue>>, int) overrideコンテナの要素を既存の配列要素にコピーします。
get_KeysInternal() const override辞書のキーにアクセスするためのラッパーコレクションを取得します。
idx_set(const TKey&, TValue) overrideRTTI 情報。
Remove(const TKey&) overrideコンテナから要素を削除します。
TryAdd(const TKey&, const TValue&)辞書にキーと値のペアを追加しようとします。

Typedefs

型定義説明
BaseType実装型です。
ThisTypeこのタイプ。

備考

#include <system/collections/concurrent/concurrent_dictionary.h>
#include <system/smart_ptr.h>

using namespace System;
using namespace System::Collections::Generic;

int main()
{
  const int itemsCount = 32;

  // ConcurrentDictionary クラスのインスタンスを作成します。
  auto concurrentDictionary = MakeObject<ConcurrentDictionary<int, int>>();

  // ConcurrentDictionary にデータを追加します。
  for (auto i = 0; i < itemsCount; ++i)
  {
    concurrentDictionary->Add(i, i * i);
  }

  Console::WriteLine(concurrentDictionary->idx_get(3));

  return 0;
}
/*
This code example produces the following output:
9
*/

参照