Class ConcurrentTwoLevelDictionary<TMainKey, TSubKey, TData>
A thread-safe two-level dictionary that uses a main key to access a sub-dictionary keyed by a sub key.
public class ConcurrentTwoLevelDictionary<TMainKey, TSubKey, TData>
Type Parameters
TMainKeyThe type of the main dictionary key.
TSubKeyThe type of the sub-dictionary key.
TDataThe type of the stored data values.
- Inheritance
-
ConcurrentTwoLevelDictionary<TMainKey, TSubKey, TData>
- Inherited Members
- Extension Methods
Methods
AddOrUpdate(TMainKey, TSubKey, TData)
Adds or updates a value in the two-level dictionary under the specified main key and sub key.
public (TData Before, TData After) AddOrUpdate(TMainKey mainKey, TSubKey subKey, TData data)
Parameters
mainKeyTMainKeyThe main dictionary key.
subKeyTSubKeyThe sub-dictionary key.
dataTDataThe data value to store.
Returns
- (TData Before, TData After)
A tuple containing the previous value (Before) and the new value (After).
TryGetSubDictonary(TMainKey, out ConcurrentDictionary<TSubKey, TData>)
Attempts to retrieve the sub-dictionary associated with the specified main key.
public bool TryGetSubDictonary(TMainKey mainKey, out ConcurrentDictionary<TSubKey, TData> dictionary)
Parameters
mainKeyTMainKeyThe main dictionary key.
dictionaryConcurrentDictionary<TSubKey, TData>When this method returns, contains the sub-dictionary if found; otherwise, null.
Returns
- bool
True if the sub-dictionary was found; otherwise, false.
TryRemove(TMainKey, out ConcurrentDictionary<TSubKey, TData>)
Attempts to remove the sub-dictionary associated with the specified main key.
public bool TryRemove(TMainKey mainKey, out ConcurrentDictionary<TSubKey, TData> dictionary)
Parameters
mainKeyTMainKeyThe main dictionary key.
dictionaryConcurrentDictionary<TSubKey, TData>When this method returns, contains the removed sub-dictionary if successful; otherwise, null.
Returns
- bool
True if the sub-dictionary was removed; otherwise, false.