Table of Contents

Class CachedSynchronizedPairSet<TKey, TValue>

Namespace
Ecng.Collections
Assembly
Ecng.Collections.dll

Represents a thread-safe set of key-value pairs with cached keys, values, and pairs for improved performance.

public class CachedSynchronizedPairSet<TKey, TValue> : SynchronizedPairSet<TKey, TValue>, IDictionary<TKey, TValue>, ISynchronizedCollection<KeyValuePair<TKey, TValue>>, ISynchronizedCollection, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable

Type Parameters

TKey

The type of keys in the set.

TValue

The type of values in the set.

Inheritance
KeyedCollection<TKey, TValue>
SynchronizedPairSet<TKey, TValue>
CachedSynchronizedPairSet<TKey, TValue>
Implements
IDictionary<TKey, TValue>
ICollection<KeyValuePair<TKey, TValue>>
IEnumerable<KeyValuePair<TKey, TValue>>
Derived
Inherited Members
Extension Methods

Constructors

CachedSynchronizedPairSet()

Initializes a new instance of the CachedSynchronizedPairSet<TKey, TValue> class.

public CachedSynchronizedPairSet()

CachedSynchronizedPairSet(IEqualityComparer<TKey>)

Initializes a new instance of the CachedSynchronizedPairSet<TKey, TValue> class with the specified key comparer.

public CachedSynchronizedPairSet(IEqualityComparer<TKey> comparer)

Parameters

comparer IEqualityComparer<TKey>

The equality comparer to use when comparing keys.

CachedSynchronizedPairSet(IEqualityComparer<TKey>, IEqualityComparer<TValue>)

Initializes a new instance of the CachedSynchronizedPairSet<TKey, TValue> class with the specified key and value comparers.

public CachedSynchronizedPairSet(IEqualityComparer<TKey> keyComparer, IEqualityComparer<TValue> valueComparer)

Parameters

keyComparer IEqualityComparer<TKey>

The equality comparer to use when comparing keys.

valueComparer IEqualityComparer<TValue>

The equality comparer to use when comparing values.

Properties

CachedKeys

Gets an array of cached keys from the set.

public TKey[] CachedKeys { get; }

Property Value

TKey[]

Remarks

The keys are cached for performance and are reset when the set is modified.

CachedPairs

Gets an array of cached key-value pairs from the set.

public KeyValuePair<TKey, TValue>[] CachedPairs { get; }

Property Value

KeyValuePair<TKey, TValue>[]

Remarks

The key-value pairs are cached for performance and are reset when the set is modified.

CachedValues

Gets an array of cached values from the set.

public TValue[] CachedValues { get; }

Property Value

TValue[]

Remarks

The values are cached for performance and are reset when the set is modified.

this[TKey]

Gets or sets the value associated with the specified key.

public override TValue this[TKey key] { set; }

Parameters

key TKey

The key of the value to get or set.

Property Value

TValue

The value associated with the specified key.

Methods

Add(TKey, TValue)

Adds the specified key and value to the set.

public override void Add(TKey key, TValue value)

Parameters

key TKey

The key of the element to add.

value TValue

The value of the element to add.

Clear()

Removes all keys and values from the set.

public override void Clear()

OnResetCache(bool)

Resets the cached keys, values, and key-value pairs when the set is modified.

protected virtual void OnResetCache(bool isKey)

Parameters

isKey bool

Indicates whether the cache reset is due to a key modification.

Remove(TKey)

Removes the value with the specified key from the set.

public override bool Remove(TKey key)

Parameters

key TKey

The key of the element to remove.

Returns

bool

true if the element is successfully found and removed; otherwise, false.