Table of Contents

Class CachedSynchronizedOrderedDictionary<TKey, TValue>

Namespace
Ecng.Collections
Assembly
Ecng.Collections.dll

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

public class CachedSynchronizedOrderedDictionary<TKey, TValue> : SynchronizedOrderedDictionary<TKey, TValue>, ISynchronizedCollection<KeyValuePair<TKey, TValue>>, ISynchronizedCollection, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable

Type Parameters

TKey

The type of keys in the dictionary.

TValue

The type of values in the dictionary.

Inheritance
CachedSynchronizedOrderedDictionary<TKey, TValue>
Implements
IDictionary<TKey, TValue>
ICollection<KeyValuePair<TKey, TValue>>
IEnumerable<KeyValuePair<TKey, TValue>>
Inherited Members
Extension Methods

Constructors

CachedSynchronizedOrderedDictionary()

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

public CachedSynchronizedOrderedDictionary()

CachedSynchronizedOrderedDictionary(IComparer<TKey>)

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

public CachedSynchronizedOrderedDictionary(IComparer<TKey> comparer)

Parameters

comparer IComparer<TKey>

The comparer to use when comparing keys.

CachedSynchronizedOrderedDictionary(Func<TKey, TKey, int>)

Initializes a new instance of the CachedSynchronizedOrderedDictionary<TKey, TValue> class with the specified key comparison function.

public CachedSynchronizedOrderedDictionary(Func<TKey, TKey, int> comparer)

Parameters

comparer Func<TKey, TKey, int>

The function to use when comparing keys.

Properties

CachedKeys

Gets an array of cached keys from the dictionary.

public TKey[] CachedKeys { get; }

Property Value

TKey[]

Remarks

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

CachedPairs

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

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 dictionary is modified.

CachedValues

Gets an array of cached values from the dictionary.

public TValue[] CachedValues { get; }

Property Value

TValue[]

Remarks

The values are cached for performance and are reset when the dictionary 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 dictionary.

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 dictionary.

public override void Clear()

OnResetCache(bool)

Resets the cached keys, values, and key-value pairs when the dictionary 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 dictionary.

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.