Represents a thread-safe collection of key-value pairs that can be accessed by multiple threads concurrently. If using the Net 4.0 framework you should consider to use the new System.Collections.Concurrent.ConcurrentDictionary. The SynchronizedDictionary provides methods similar to the ConcurrentDictionary to provide a thread safe Dictionary for .NET 3.5 and earlier. More...
Public Member Functions | |
SynchronizedDictionary () | |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class. More... | |
SynchronizedDictionary (int capacity) | |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class. More... | |
SynchronizedDictionary (IEqualityComparer< TKey > comparer) | |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class. More... | |
SynchronizedDictionary (int capacity, IEqualityComparer< TKey > comparer) | |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class. More... | |
SynchronizedDictionary (IDictionary< TKey, TValue > dictionary) | |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class. More... | |
SynchronizedDictionary (IDictionary< TKey, TValue > dictionary, IEqualityComparer< TKey > comparer) | |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class. More... | |
TValue | AddOrUpdate (TKey key, TValue addValue, Func< TKey, TValue, TValue > updateValueFactory) |
Adds a key/value pair to the dictionary if the key does not already exist, or updates a key/value pair in the dictionary if the key already exists. More... | |
TValue | AddOrUpdate (TKey key, Func< TKey, TValue > addValueFactory, Func< TKey, TValue, TValue > updateValueFactory) |
Adds a key/value pair to the dictionary if the key does not already exist, or updates a key/value pair in the dictionary if the key already exists. More... | |
void | Clear () |
Removes all keys and values from the SynchronizedDictionary<Key, TValue>. More... | |
bool | ContainsKey (TKey key) |
Determines whether the SynchronizedDictionary<Key, TValue> contains the specified key. More... | |
TValue | GetOrAdd (TKey key, Func< TKey, TValue > valueFactory) |
Adds a key/value pair to the SynchronizedDictionary<Key, TValue> if the key does not already exist More... | |
bool | Remove (TKey key) |
Removes the value with the specified key from the SynchronizedDictionary<Key, TValue>. More... | |
bool | TryAdd (TKey key, TValue value) |
Attempts to add the specified key and value to the SynchronizedDictionary<Key, TValue>. More... | |
bool | TryGetValue (TKey key, out TValue value) |
Attempts to get the value associated with the specified key from the SynchronizedDictionary<Key, TValue>. More... | |
bool | TryRemove (TKey key, out TValue value) |
Attempts to remove and return the value with the specified key from the SynchronizedDictionary<Key, TValue>. More... | |
bool | TryUpdate (TKey key, TValue newValue, TValue comparisonValue) |
Compares the existing value for the specified key with a specified value, and if they are equal, updates the key with a third value. More... | |
void | Dispose () |
Releases all resources used by the current instance of the SynchronizedDictionary<TKey, TValue> class. More... | |
Protected Member Functions | |
virtual void | Dispose (bool disposing) |
Releases unmanaged and - optionally - managed resources More... | |
Properties | |
int | Count [get] |
Gets the number of key/value pairs contained in the SynchronizedDictionary<Key, TValue>. More... | |
TValue | this[TKey key] [get, set] |
Gets or sets the value associated with the specified key. More... | |
Represents a thread-safe collection of key-value pairs that can be accessed by multiple threads concurrently. If using the Net 4.0 framework you should consider to use the new System.Collections.Concurrent.ConcurrentDictionary. The SynchronizedDictionary provides methods similar to the ConcurrentDictionary to provide a thread safe Dictionary for .NET 3.5 and earlier.
TKey | The type of the keys in the dictionary. |
TValue | The type of the values in the dictionary. |
|
inline |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class.
|
inline |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class.
capacity | The initial number of elements that the SynchronizedDictionary can contain. |
|
inline |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class.
comparer | The IEqualityComparer<TKey> implementation to use when comparing keys. |
|
inline |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class.
capacity | The initial number of elements that the SynchronizedDictionary can contain. |
comparer | The IEqualityComparer<TKey> implementation to use when comparing keys. |
|
inline |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class.
dictionary | The IDictionary<TKey, TValue> whose elements are copied to the new SynchronizedDictionary. |
|
inline |
Initializes a new instance of the SynchronizedDictionary<TKey,TValue> class. Initializes a new instance of the SynchronizedDictionary<TKey, TValue> class.
dictionary | The IDictionary<TKey, TValue> whose elements are copied to the new SynchronizedDictionary. |
comparer | The IEqualityComparer<TKey> implementation to use when comparing keys. |
|
inline |
Adds a key/value pair to the dictionary if the key does not already exist, or updates a key/value pair in the dictionary if the key already exists.
key | The key to be added or whose value should be updated. |
addValueFactory | The function used to generate a value for an absent key. |
updateValueFactory | The function used to generate a new value for an existing key based on the key's existing value. |
|
inline |
Adds a key/value pair to the dictionary if the key does not already exist, or updates a key/value pair in the dictionary if the key already exists.
key | The key to be added or whose value should be updated. |
addValue | The value to be added for an absent key. |
updateValueFactory | The function used to generate a new value for an existing key based on the key's existing value. |
|
inline |
Removes all keys and values from the SynchronizedDictionary<Key, TValue>.
|
inline |
Determines whether the SynchronizedDictionary<Key, TValue> contains the specified key.
key | The key to locate. |
|
inline |
Releases all resources used by the current instance of the SynchronizedDictionary<TKey, TValue> class.
|
inlineprotectedvirtual |
Releases unmanaged and - optionally - managed resources
disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
Dispose(bool disposing) executes in two distinct scenarios. If disposing equals true, the method has been called directly or indirectly by a user's code. Managed and unmanaged resources can be disposed. If disposing equals false, the method has been called by the runtime from inside the finalizer and you should not reference other objects. Only unmanaged resources can be disposed.
|
inline |
Adds a key/value pair to the SynchronizedDictionary<Key, TValue> if the key does not already exist
key | The key of the element to get or add. |
valueFactory | The function used to generate a value for the key |
|
inline |
Removes the value with the specified key from the SynchronizedDictionary<Key, TValue>.
key | The key of the element to remove. |
|
inline |
Attempts to add the specified key and value to the SynchronizedDictionary<Key, TValue>.
key | The key of the element to add. |
value | The value of the element to add. The value can be a null reference (Nothing in Visual Basic) for reference types. |
|
inline |
Attempts to get the value associated with the specified key from the SynchronizedDictionary<Key, TValue>.
key | The key of the value to get. |
value | When this method returns true, value contains the object from the SynchronizedDictionary<Key, TValue> with the specified key. |
|
inline |
Attempts to remove and return the value with the specified key from the SynchronizedDictionary<Key, TValue>.
key | The key of the element to remove and return. |
value | When this method returns true, value contains the object removed from the SynchronizedDictionary<Key, TValue> or the default value of if the operation failed. |
|
inline |
Compares the existing value for the specified key with a specified value, and if they are equal, updates the key with a third value.
key | The key whose value is compared with comparisonValue and possibly replaced. |
newValue | The value that replaces the value of the element with key if the comparison results in equality |
comparisonValue | The value that is compared to the value of the element with key |
|
get |
Gets the number of key/value pairs contained in the SynchronizedDictionary<Key, TValue>.
The number of key/value pairs contained in the SynchronizedDictionary<Key, TValue>
|
getset |
Gets or sets the value associated with the specified key.
key | The key of the value to get or set. |