CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
concurrent_dictionary.h
1
2#ifndef _aspose_system_collections_concurrent_dictionary_h_
3#define _aspose_system_collections_concurrent_dictionary_h_
4
5#include <system/collections/dictionary.h>
6#include <system/collections/keyvalue_pair.h>
7
8namespace System {
9namespace Collections {
10namespace Concurrent {
11
48template<class TKey, class TValue>
49class ASPOSECPP_SHARED_CLASS ConcurrentDictionary : public System::Collections::Generic::Dictionary<TKey, TValue>
50{
51public:
56
57private:
59 RTTI_INFO_TEMPLATE_CLASS(ThisType, System::BaseTypesInfo<BaseType>);
60
61public:
65 virtual void idx_set(const TKey& key, TValue value) override
66 {
67 LockContext __guard(this);
68 BaseType::idx_set(key, value);
69 }
73 {
75 {
76 LockContext __guard(const_cast<ThisType*>(this));
77 keys = BaseType::get_KeysInternal();
78 }
79 return keys;
80 }
81protected:
84
88 {
90 {
91 LockContext __guard(const_cast<ThisType*>(this));
92 values = BaseType::get_ValuesInternal();
93 }
94 return values;
95 }
96public:
101 bool TryAdd(const TKey& key, const TValue& value)
102 {
103 bool result = false;
104 {
105 LockContext __guard(this);
106 if (!BaseType::ContainsKey(key))
107 {
108 BaseType::Add(key, value);
109 result = true;
110 }
111 }
112 return result;
113 }
117 virtual void Add(const TKey& key, const TValue& value) override
118 {
119 LockContext __guard(this);
120 BaseType::Add(key, value);
121 }
123 virtual void Clear() override
124 {
125 LockContext __guard(this);
126 BaseType::Clear();
127 }
132 {
133 LockContext __guard(this);
134 BaseType::CopyTo(arr, index);
135 }
139 virtual bool Remove(const TKey& key) override
140 {
141 bool value = false;
142 {
143 LockContext __guard(this);
144 value = BaseType::Remove(key);
145 }
146 return value;
147 }
148};
149
150} // namespace ConcurrentGeneric
151} // namespace Collections
152} // namespace System
153
154#endif // _aspose_system_collections_concurrent_dictionary_h_
Thread-safe dictionary implementation. Objects of this class should only be allocated using System::M...
Definition: concurrent_dictionary.h:50
virtual void Add(const TKey &key, const TValue &value) override
Adds value into dictionary.
Definition: concurrent_dictionary.h:117
virtual SharedPtr< typename ThisType::ValueCollection > get_ValuesInternal() const override
Gets wrapper collection to access dictionary values.
Definition: concurrent_dictionary.h:87
~ConcurrentDictionary() override
Destructor.
Definition: concurrent_dictionary.h:83
virtual SharedPtr< typename ThisType::KeyCollection > get_KeysInternal() const override
Gets wrapper collection to access dictionary keys.
Definition: concurrent_dictionary.h:72
virtual void CopyTo(ArrayPtr< System::Collections::Generic::KeyValuePair< TKey, TValue > > arr, int index) override
Copies container elements to existing array elements.
Definition: concurrent_dictionary.h:131
virtual void idx_set(const TKey &key, TValue value) override
Sets element at specific position.
Definition: concurrent_dictionary.h:65
virtual bool Remove(const TKey &key) override
Removes element from container.
Definition: concurrent_dictionary.h:139
bool TryAdd(const TKey &key, const TValue &value)
Tries to add key/value pair into the dictionary.
Definition: concurrent_dictionary.h:101
virtual void Clear() override
Deletes all elements in container.
Definition: concurrent_dictionary.h:123
Forward declaration of Dictionary class.
Definition: dictionary.h:96
Pair of key and value. This type should be allocated on stack and passed to functions by value or by ...
Definition: keyvalue_pair.h:20
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Definition: db_command.h:9