CachedSynchronizedDictionary
Represents a thread-safe dictionary with cached keys, values, and key-value pairs for improved performance.
Erbt von: SynchronizedDictionary<T, T>
Konstruktoren
public CachedSynchronizedDictionary()
cachedSynchronizedDictionary = CachedSynchronizedDictionary()
Initializes a new instance of the CachedSynchronizedDictionary class.
public CachedSynchronizedDictionary(int capacity)
cachedSynchronizedDictionary = CachedSynchronizedDictionary(capacity)
Initializes a new instance of the CachedSynchronizedDictionary class with the specified initial capacity.
- capacity
- The initial number of elements that the dictionary can contain.
public CachedSynchronizedDictionary(IEqualityComparer<TKey> comparer)
cachedSynchronizedDictionary = CachedSynchronizedDictionary(comparer)
Initializes a new instance of the CachedSynchronizedDictionary class with the specified equality comparer.
- comparer
- The equality comparer to use when comparing keys.
public CachedSynchronizedDictionary(int capacity, IEqualityComparer<TKey> comparer)
cachedSynchronizedDictionary = CachedSynchronizedDictionary(capacity, comparer)
Initializes a new instance of the CachedSynchronizedDictionary class with the specified initial capacity and equality comparer.
- capacity
- The initial number of elements that the dictionary can contain.
- comparer
- The equality comparer to use when comparing keys.
Eigenschaften
public TKey[] CachedKeys { get; }
value = cachedSynchronizedDictionary.CachedKeys
Gets an array of cached keys from the dictionary.
public KeyValuePair<TKey, TValue>[] CachedPairs { get; }
value = cachedSynchronizedDictionary.CachedPairs
Gets an array of cached key-value pairs from the dictionary.
public TValue[] CachedValues { get; }
value = cachedSynchronizedDictionary.CachedValues
Gets an array of cached values from the dictionary.
public override TValue Item { set; }
cachedSynchronizedDictionary.Item = value
Gets or sets the value associated with the specified key.
- key
- The key of the value to get or set.
Rückgabe: The value associated with the specified key.
Methoden
public override void Add(TKey key, TValue value)
cachedSynchronizedDictionary.Add(key, value)
Adds the specified key and value to the dictionary.
- key
- The key of the element to add.
- value
- The value of the element to add.
public override void Clear()
cachedSynchronizedDictionary.Clear()
Removes all keys and values from the dictionary.
protected virtual void OnResetCache(bool isKey)
cachedSynchronizedDictionary.OnResetCache(isKey)
Resets the cached keys, values, and key-value pairs when the dictionary is modified.
- isKey
- Indicates whether the cache reset is due to a key modification.
public override bool Remove(TKey key)
result = cachedSynchronizedDictionary.Remove(key)
Removes the value with the specified key from the dictionary.
- key
- The key of the element to remove.
Rückgabe: true if the element is successfully found and removed; otherwise, false.