Class ConcurrentDictionary
Template for unordered dictionary with mapped key with value pairs that supports asynchronous data reading and writing. Implemented via reader-writer lock pattern, so multiple threads can read data at the same time, but only one thread can write data and it blocks all other threads (including readers) until the write operation is finished. Optimized for frequent reads (no lock operation).
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Core/Collections/Dictionary.h
Syntax
public class ConcurrentDictionary<KeyType, ValueType, AllocationType> : public Dictionary
Type Parameters
|
KeyType
The type of the keys in the dictionary. |
|
ValueType
The type of the values in the dictionary. |
|
AllocationType
The type of memory allocator. |
Constructors
~ConcurrentDictionary()
ConcurrentDictionary()
Initializes an empty ConcurrentDictionary without reserving any space.
Declaration
public ConcurrentDictionary()
ConcurrentDictionary(AllocationTag tag)
Initializes an empty ConcurrentDictionary without reserving any space.
Declaration
public ConcurrentDictionary(AllocationTag tag)
Parameters
|
AllocationTag
tag
The custom allocation tag. |
Methods
Add(const KeyComparableType& key, const ValueType& value)
Adds a pair of key and value to the collection.
Declaration
public bool Add(const KeyComparableType& key, const ValueType& value)
Parameters
|
KeyComparableType
key
The key. |
|
ValueType
value
The value. |
Returns
|
bool
True if added element, otherwise false if it already exists (or other thread added it). |
Type Parameters
|
typename KeyComparableType
|
begin()
Declaration
public ConstIterator begin() const
Returns
|
ConstIterator
|
Capacity()
Gets the amount of the elements that can be contained by the collection.
Declaration
public int32 Capacity() const
Returns
|
int32
|
Clear()
Removes all elements from the collection.
Declaration
public void Clear()
Count()
Gets the amount of the elements in the collection.
Declaration
public int32 Count() const
Returns
|
int32
|
end()
Declaration
public ConstIterator end() const
Returns
|
ConstIterator
|
Remove(const KeyComparableType& key)
Removes element with a specified key.
Declaration
public bool Remove(const KeyComparableType& key)
Parameters
|
KeyComparableType
key
The element key to remove. |
Returns
|
bool
True if item was removed from collection, otherwise false. |
Type Parameters
|
typename KeyComparableType
|
TryGet(const KeyComparableType& key, ValueType& result)
Tries to get element with given key.
Declaration
public bool TryGet(const KeyComparableType& key, ValueType& result) const
Parameters
|
KeyComparableType
key
The key of the element. |
|
ValueType
result
The result value. |
Returns
|
bool
True if element of given key has been found, otherwise false. |
Type Parameters
|
typename KeyComparableType
|